|
@@ -69,20 +69,15 @@ bool PersistentStore::access_start() {
|
69
|
69
|
__disable_irq();
|
70
|
70
|
status = BlankCheckSector(EEPROM_SECTOR, EEPROM_SECTOR, &first_nblank_loc, &first_nblank_val);
|
71
|
71
|
__enable_irq();
|
72
|
|
- SERIAL_PROTOCOLLNPAIR("Blank check status: ", status);
|
|
72
|
+
|
73
|
73
|
if (status == CMD_SUCCESS) {
|
74
|
74
|
// sector is blank so nothing stored yet
|
75
|
|
- SERIAL_PROTOCOLLNPGM("FLASH empty");
|
76
|
75
|
for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE;
|
77
|
76
|
current_slot = EEPROM_SLOTS;
|
78
|
|
- }
|
79
|
|
- else {
|
|
77
|
+ } else {
|
80
|
78
|
// current slot is the first non blank one
|
81
|
79
|
current_slot = first_nblank_loc / EEPROM_SIZE;
|
82
|
|
- SERIAL_PROTOCOLLNPAIR("Flash slot: ", current_slot);
|
83
|
80
|
uint8_t *eeprom_data = SLOT_ADDRESS(EEPROM_SECTOR, current_slot);
|
84
|
|
- SERIAL_PROTOCOLLNPAIR("Address: ", (int)eeprom_data);
|
85
|
|
-
|
86
|
81
|
// load current settings
|
87
|
82
|
for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i];
|
88
|
83
|
}
|
|
@@ -100,15 +95,15 @@ bool PersistentStore::access_finish() {
|
100
|
95
|
PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
101
|
96
|
status = EraseSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
102
|
97
|
__enable_irq();
|
103
|
|
- SERIAL_PROTOCOLLNPAIR("Erase status: ", status);
|
|
98
|
+
|
104
|
99
|
current_slot = EEPROM_SLOTS - 1;
|
105
|
100
|
}
|
106
|
|
- SERIAL_PROTOCOLLNPAIR("Writing data to: ", current_slot);
|
|
101
|
+
|
107
|
102
|
__disable_irq();
|
108
|
103
|
PrepareSector(EEPROM_SECTOR, EEPROM_SECTOR);
|
109
|
104
|
status = CopyRAM2Flash(SLOT_ADDRESS(EEPROM_SECTOR, current_slot), ram_eeprom, IAP_WRITE_4096);
|
110
|
105
|
__enable_irq();
|
111
|
|
- SERIAL_PROTOCOLLNPAIR("CopyRAM2Flash status: ", status);
|
|
106
|
+
|
112
|
107
|
if (status != CMD_SUCCESS) return false;
|
113
|
108
|
eeprom_dirty = false;
|
114
|
109
|
}
|