aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-02-27 23:13:15 -0700
committerSelene ToyKeeper2020-02-27 23:13:15 -0700
commitc0ffafddc1c2aea1cde4ab6d7ad805fc4bcc32de (patch)
tree2436490ac66eaacd8dcb71f32cbc9ece10ef8e52 /spaghetti-monster
parentK1 12V needs party strobe slowed down even more (diff)
downloadanduril-c0ffafddc1c2aea1cde4ab6d7ad805fc4bcc32de.tar.gz
anduril-c0ffafddc1c2aea1cde4ab6d7ad805fc4bcc32de.tar.bz2
anduril-c0ffafddc1c2aea1cde4ab6d7ad805fc4bcc32de.zip
fixed eeprom corruption after turning boost chip on/off
(boost chip apparently makes power unstable for a few ms, so we have to wait before accessing eeprom)
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-eeprom.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-eeprom.c b/spaghetti-monster/fsm-eeprom.c
index 277e2b2..77352cf 100644
--- a/spaghetti-monster/fsm-eeprom.c
+++ b/spaghetti-monster/fsm-eeprom.c
@@ -30,6 +30,10 @@ uint8_t eeprom[EEPROM_BYTES];
#endif
uint8_t load_eeprom() {
+ #ifdef LED_ENABLE_PIN
+ delay_4ms(2); // wait for power to stabilize
+ #endif
+
cli();
// check if eeprom has been initialized; abort if it hasn't
uint8_t marker = eeprom_read_byte((uint8_t *)EEP_START);
@@ -44,6 +48,10 @@ uint8_t load_eeprom() {
}
void save_eeprom() {
+ #ifdef LED_ENABLE_PIN
+ delay_4ms(2); // wait for power to stabilize
+ #endif
+
cli();
// save the actual data
@@ -62,6 +70,10 @@ uint8_t eeprom_wl[EEPROM_WL_BYTES];
EEP_OFFSET_T eep_wl_prev_offset;
uint8_t load_eeprom_wl() {
+ #ifdef LED_ENABLE_PIN
+ delay_4ms(2); // wait for power to stabilize
+ #endif
+
cli();
// check if eeprom has been initialized; abort if it hasn't
uint8_t found = 0;
@@ -87,6 +99,10 @@ uint8_t load_eeprom_wl() {
}
void save_eeprom_wl() {
+ #ifdef LED_ENABLE_PIN
+ delay_4ms(2); // wait for power to stabilize
+ #endif
+
cli();
// erase old state
EEP_OFFSET_T offset = eep_wl_prev_offset;