aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-standby.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-06-17 19:40:38 -0600
committerSelene ToyKeeper2018-06-17 19:40:38 -0600
commit3dcfc924bf18c48b76f4b950471160436fddb316 (patch)
treef3a7c80d8a2cdb116f3217d6750f6a7faf0852d5 /spaghetti-monster/fsm-standby.c
parentImplemented halfsleep mode. (diff)
downloadanduril-3dcfc924bf18c48b76f4b950471160436fddb316.tar.gz
anduril-3dcfc924bf18c48b76f4b950471160436fddb316.tar.bz2
anduril-3dcfc924bf18c48b76f4b950471160436fddb316.zip
Changed halfsleep mode to TICK_DURING_STANDBY. Added blinking indicator LED support to Anduril.
Diffstat (limited to 'spaghetti-monster/fsm-standby.c')
-rw-r--r--spaghetti-monster/fsm-standby.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/spaghetti-monster/fsm-standby.c b/spaghetti-monster/fsm-standby.c
index 8e51dda..7d60c1d 100644
--- a/spaghetti-monster/fsm-standby.c
+++ b/spaghetti-monster/fsm-standby.c
@@ -31,16 +31,11 @@
#define standby_mode sleep_until_eswitch_pressed
void sleep_until_eswitch_pressed()
{
- #ifdef USE_HALFSLEEP_MODE
- //uint16_t sleep_counter = 0;
- if (halfsleep_mode) {
- // set WDT to slow mode
- wdt_reset();
- WDTCR |= (1<<WDCE) | (1<<WDE); // Start timed sequence
- WDTCR = (1<<WDIE) | 5; // Enable interrupt every 0.5s
- } else
- #endif
+ #ifdef TICK_DURING_STANDBY
+ WDT_slow();
+ #else
WDT_off();
+ #endif
ADC_off();
@@ -51,9 +46,11 @@ void sleep_until_eswitch_pressed()
PCINT_on(); // wake on e-switch event
- #ifdef USE_HALFSLEEP_MODE
- while (halfsleep_mode) {
+ #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);
@@ -65,13 +62,11 @@ void sleep_until_eswitch_pressed()
// something happened; wake up
sleep_disable();
- #ifdef USE_HALFSLEEP_MODE
+ #ifdef TICK_DURING_STANDBY
// determine what woke us up... WDT or PCINT
- if (! f_wdt) { // PCINT went off
- halfsleep_mode = 0;
+ if (! f_wdt) { // PCINT went off; wake up
+ go_to_standby = 0;
}
- #endif
- #ifdef USE_HALFSLEEP_MODE
}
#endif
@@ -82,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();
}