Fix problems with LPC1768 EEPROM flash emulation (#12503)
* Remove duplicate calls to PrepareSector Some flash memory API calls require that a call to `PrepareSector` is done before use. However this call is already made by the LPC1768 framework so the calls in this code are not required. * Ensure correct alignment of RAM buffer The LPC176X flash API requires that the RAM buffer used for write operations must be word-aligned. This change ensures that this is the case.
This commit is contained in:
parent
b738972e69
commit
4975b13b74
|
@ -57,7 +57,7 @@ extern "C" {
|
|||
#define EEPROM_ERASE (0xff)
|
||||
#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE)
|
||||
|
||||
static uint8_t ram_eeprom[EEPROM_SIZE];
|
||||
static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0};
|
||||
static bool eeprom_dirty = false;
|
||||
static int current_slot = 0;
|
||||
|
||||
|
@ -92,7 +92,6 @@ bool PersistentStore::access_finish() {
|
|||
if (--current_slot < 0) {
|
||||
// all slots have been used, erase everything and start again
|
||||
__disable_irq();
|
||||
PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
||||
status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
||||
__enable_irq();
|
||||
|
||||
|
@ -100,7 +99,6 @@ bool PersistentStore::access_finish() {
|
|||
}
|
||||
|
||||
__disable_irq();
|
||||
PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
||||
status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
|
||||
__enable_irq();
|
||||
|
||||
|
|
Loading…
Reference in a new issue