|
@@ -57,7 +57,7 @@ extern "C" {
|
57
|
57
|
#define EEPROM_ERASE (0xff)
|
58
|
58
|
#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE)
|
59
|
59
|
|
60
|
|
-static uint8_t ram_eeprom[EEPROM_SIZE];
|
|
60
|
+static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0};
|
61
|
61
|
static bool eeprom_dirty = false;
|
62
|
62
|
static int current_slot = 0;
|
63
|
63
|
|
|
@@ -92,7 +92,6 @@ bool PersistentStore::access_finish() {
|
92
|
92
|
if (--current_slot < 0) {
|
93
|
93
|
// all slots have been used, erase everything and start again
|
94
|
94
|
__disable_irq();
|
95
|
|
- PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
96
|
95
|
status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
97
|
96
|
__enable_irq();
|
98
|
97
|
|
|
@@ -100,7 +99,6 @@ bool PersistentStore::access_finish() {
|
100
|
99
|
}
|
101
|
100
|
|
102
|
101
|
__disable_irq();
|
103
|
|
- PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
104
|
102
|
status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
|
105
|
103
|
__enable_irq();
|
106
|
104
|
|