aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-standby.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-08-06 21:27:45 -0600
committerSelene ToyKeeper2018-08-06 21:27:45 -0600
commitce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4 (patch)
treeab5b14203adad80505368f31f8dfa6a87a1cb356 /spaghetti-monster/fsm-standby.c
parentMade it easier to change ramp shape in bin/level_calc.py . (diff)
parentAdded more driver types to Anduril. (diff)
downloadanduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.tar.gz
anduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.tar.bz2
anduril-ce2397cbe9ffd2e5f046f4a51a30becbce3b2fc4.zip
merged updates from fsm branch, including RampingIOS V3 and Werner UIs...
... plus a bunch of other updates, fixes, improvements, etc.
Diffstat (limited to 'spaghetti-monster/fsm-standby.c')
-rw-r--r--spaghetti-monster/fsm-standby.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/spaghetti-monster/fsm-standby.c b/spaghetti-monster/fsm-standby.c
index b90ccea..7d60c1d 100644
--- a/spaghetti-monster/fsm-standby.c
+++ b/spaghetti-monster/fsm-standby.c
@@ -31,7 +31,12 @@
#define standby_mode sleep_until_eswitch_pressed
void sleep_until_eswitch_pressed()
{
+ #ifdef TICK_DURING_STANDBY
+ WDT_slow();
+ #else
WDT_off();
+ #endif
+
ADC_off();
// make sure switch isn't currently pressed
@@ -41,15 +46,29 @@ void sleep_until_eswitch_pressed()
PCINT_on(); // wake on e-switch event
- // configure sleep mode
- set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+ #ifdef TICK_DURING_STANDBY
+ 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);
- sleep_enable();
- sleep_bod_disable();
- sleep_cpu(); // wait here
+ sleep_enable();
+ sleep_bod_disable();
+ sleep_cpu(); // wait here
- // something happened; wake up
- sleep_disable();
+ // something happened; wake up
+ sleep_disable();
+
+ #ifdef TICK_DURING_STANDBY
+ // determine what woke us up... WDT or PCINT
+ if (! f_wdt) { // PCINT went off; wake up
+ go_to_standby = 0;
+ }
+ }
+ #endif
#ifdef USE_THERMAL_REGULATION
// forget what the temperature was last time we were on
@@ -58,7 +77,6 @@ void sleep_until_eswitch_pressed()
// go back to normal running mode
//PCINT_on(); // should be on already
- // FIXME? if button is down, make sure a button press event is added to the current sequence
ADC_on();
WDT_on();
}