diff options
| author | Selene ToyKeeper | 2019-11-24 16:21:40 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-11-24 16:21:40 -0700 |
| commit | 30510a7948815f3092b8a2eff3321ad85ed5c480 (patch) | |
| tree | 4a1b68628c779bf4092a64ae027917529d03e158 /spaghetti-monster/fsm-standby.c | |
| parent | merged changes from fsm branch, including version check and stuck-button safety (diff) | |
| parent | added -fwhole-program gcc flag, suggested by Agro. Signficantly reduces ROM ... (diff) | |
| download | anduril-30510a7948815f3092b8a2eff3321ad85ed5c480.tar.gz anduril-30510a7948815f3092b8a2eff3321ad85ed5c480.tar.bz2 anduril-30510a7948815f3092b8a2eff3321ad85ed5c480.zip | |
merged from upstream fsm branch to get a whole bunch of kernel-level improvements
Diffstat (limited to 'spaghetti-monster/fsm-standby.c')
| -rw-r--r-- | spaghetti-monster/fsm-standby.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/spaghetti-monster/fsm-standby.c b/spaghetti-monster/fsm-standby.c index 44b047a..9398f52 100644 --- a/spaghetti-monster/fsm-standby.c +++ b/spaghetti-monster/fsm-standby.c @@ -42,16 +42,19 @@ void sleep_until_eswitch_pressed() // make sure switch isn't currently pressed while (button_is_pressed()) {} empty_event_sequence(); // cancel pending input on suspend - //PCINT_since_WDT = 0; // ensure PCINT won't ignore itself PCINT_on(); // wake on e-switch event #ifdef TICK_DURING_STANDBY + // detect which type of event caused a wake-up + irq_adc = 0; + irq_wdt = 0; + irq_pcint = 0; while (go_to_standby) { - f_wdt = 0; // detect if WDT was what caused a wake-up #else go_to_standby = 0; #endif + // configure sleep mode set_sleep_mode(SLEEP_MODE_PWR_DOWN); @@ -65,10 +68,19 @@ void sleep_until_eswitch_pressed() sleep_disable(); #ifdef TICK_DURING_STANDBY - // determine what woke us up... WDT or PCINT - if (! f_wdt) { // PCINT went off; wake up + // determine what woke us up... + if (irq_pcint) { // button pressed; wake up go_to_standby = 0; } + if (irq_adc) { // ADC done measuring + adcint_enable = 1; + ADC_inner(); + //ADC_off(); // takes care of itself + //irq_adc = 0; // takes care of itself + } + if (irq_wdt) { // generate a sleep tick + WDT_inner(); + } } #endif @@ -78,7 +90,10 @@ void sleep_until_eswitch_pressed() #endif // go back to normal running mode - //PCINT_on(); // should be on already + // PCINT not needed any more, and can cause problems if on + // (occasional reboots on wakeup-by-button-press) + PCINT_off(); + // restore normal awake-mode interrupts ADC_on(); WDT_on(); } |
