diff options
| author | Selene ToyKeeper | 2017-11-06 08:51:57 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2017-11-06 08:51:57 -0700 |
| commit | 9ae4f570a4b56fb3eb60f4c244931c771415944b (patch) | |
| tree | 2856c4deca16ccc29b521044a8d14f89b6b58dcc /spaghetti-monster | |
| parent | Moved indicator_led() from Anduril into FSM. Made it auto-set indicator leve... (diff) | |
| download | anduril-9ae4f570a4b56fb3eb60f4c244931c771415944b.tar.gz anduril-9ae4f570a4b56fb3eb60f4c244931c771415944b.tar.bz2 anduril-9ae4f570a4b56fb3eb60f4c244931c771415944b.zip | |
Made FSM eeprom more atomic by writing marker byte last.
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/fsm-eeprom.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-eeprom.c b/spaghetti-monster/fsm-eeprom.c index 45cd3fa..012e088 100644 --- a/spaghetti-monster/fsm-eeprom.c +++ b/spaghetti-monster/fsm-eeprom.c @@ -41,12 +41,14 @@ uint8_t load_eeprom() { void save_eeprom() { cli(); - eeprom_update_byte((uint8_t *)EEP_START, EEP_MARKER); // save the actual data for(uint8_t i=0; i<EEPROM_BYTES; i++) { eeprom_update_byte((uint8_t *)(EEP_START+1+i), eeprom[i]); } + + // save the marker last, to indicate the transaction is complete + eeprom_update_byte((uint8_t *)EEP_START, EEP_MARKER); sei(); } #endif @@ -93,6 +95,7 @@ void save_eeprom_wl() { if (offset > EEP_WL_SIZE-EEPROM_WL_BYTES-1) offset = 0; eep_wl_prev_offset = offset; // marker byte + // FIXME: write the marker last, to signal completed transaction eeprom_update_byte((uint8_t *)offset, EEP_MARKER); offset ++; // user data |
