Skip to content

Commit 2200f23

Browse files
fix(PeriphDrivers): Flush using a per-instance base address. (#1403)
Signed-off-by: Pete Johanson <pete.johanson@analog.com>
1 parent 6bf3491 commit 2200f23

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Libraries/PeriphDrivers/Source/FLC/flc_me18.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
/* **** Functions **** */
4040

4141
//******************************************************************************
42-
void MXC_FLC_ME18_Flash_Operation(void)
42+
void MXC_FLC_ME18_Flash_Operation(mxc_flc_regs_t *flc)
4343
{
4444
/*
4545
This function should be called after modifying the contents of flash memory.
@@ -62,11 +62,12 @@ void MXC_FLC_ME18_Flash_Operation(void)
6262
MXC_ICC_Flush(MXC_ICC1);
6363

6464
// Clear the line fill buffer by reading 2 pages from flash
65+
uint32_t base = (flc == MXC_FLC0 ? MXC_FLASH0_MEM_BASE : MXC_FLASH1_MEM_BASE);
6566
volatile uint32_t *line_addr;
6667
volatile uint32_t line;
67-
line_addr = (uint32_t *)(MXC_FLASH_MEM_BASE);
68+
line_addr = (uint32_t *)(base);
6869
line = *line_addr;
69-
line_addr = (uint32_t *)(MXC_FLASH_MEM_BASE + MXC_FLASH_PAGE_SIZE);
70+
line_addr = (uint32_t *)(base + MXC_FLASH_PAGE_SIZE);
7071
line = *line_addr;
7172
(void)line; // Silence build warnings that this variable is not used.
7273
}
@@ -141,7 +142,8 @@ int MXC_FLC_MassErase(void)
141142
}
142143

143144
// Flush the cache
144-
MXC_FLC_ME18_Flash_Operation();
145+
MXC_FLC_ME18_Flash_Operation(MXC_FLC0);
146+
MXC_FLC_ME18_Flash_Operation(MXC_FLC1);
145147

146148
return E_NO_ERROR;
147149
}
@@ -171,7 +173,7 @@ int MXC_FLC_PageErase(uint32_t address)
171173
}
172174

173175
// Flush the cache
174-
MXC_FLC_ME18_Flash_Operation();
176+
MXC_FLC_ME18_Flash_Operation(flc);
175177

176178
return E_NO_ERROR;
177179
}
@@ -211,7 +213,7 @@ int MXC_FLC_Write32(uint32_t address, uint32_t data)
211213
err = MXC_FLC_RevA_Write32Using128((mxc_flc_reva_regs_t *)flc, address, data, physicalAddress);
212214

213215
// Flush the cache
214-
MXC_FLC_ME18_Flash_Operation();
216+
MXC_FLC_ME18_Flash_Operation(flc);
215217

216218
return err;
217219
}
@@ -243,7 +245,7 @@ int MXC_FLC_Write128(uint32_t address, uint32_t *data)
243245
}
244246

245247
// Flush the cache
246-
MXC_FLC_ME18_Flash_Operation();
248+
MXC_FLC_ME18_Flash_Operation(flc);
247249

248250
return MXC_FLC_Com_VerifyData(address, 4, data);
249251
}

0 commit comments

Comments
 (0)