diff options
| author | Selene ToyKeeper | 2019-11-14 19:44:57 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-11-14 19:44:57 -0700 |
| commit | 1a85469b00856020e061170c031d47173f298d93 (patch) | |
| tree | b30725c34f27797516f8bc82b49bcf59801b17c8 /spaghetti-monster/fsm-wdt.c | |
| parent | fixed some compile issues related to delay_4ms() (diff) | |
| parent | turned off muggle mode on Q8 and MF01S, to make builds small enough again (diff) | |
| download | anduril-1a85469b00856020e061170c031d47173f298d93.tar.gz anduril-1a85469b00856020e061170c031d47173f298d93.tar.bz2 anduril-1a85469b00856020e061170c031d47173f298d93.zip | |
merged irq-refactor branch, which fixes some small but long-standing issues:
- occasional missed button events while asleep
- occasional short/aborted frames in aux LED sleep animation
- rare case of bogus voltage and/or temperature values
- fixed issue where nice_delay_ms() didn't work in setup()
- fixed theoretical possibility of extra-noisy buttons causing a hang
Also does some other things:
- cleans up the ADC code significantly
- adds a voltage stabilizer/lowpass option (enabled on t1634 builds)
- greatly reduces time spent per interrupt,
which might make a future PWM-DSM technique possible
- moves most interrupt-handling logic to a non-critical code path,
deferring that code until timing doesn't matter as much
- sped up button state measurements
- turned off muggle mode on a couple builds which were too big
Diffstat (limited to 'spaghetti-monster/fsm-wdt.c')
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index 6e61e87..beab1a2 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -82,11 +82,23 @@ inline void WDT_off() // clock tick -- this runs every 16ms (62.5 fps) ISR(WDT_vect) { + irq_wdt = 1; // WDT event happened +} + +void WDT_inner() { + irq_wdt = 0; // WDT event handled; reset flag + static uint8_t adc_trigger = 0; - #ifdef TICK_DURING_STANDBY - f_wdt = 1; // WDT event happened + // detect and emit button change events (even during standby) + uint8_t was_pressed = button_last_state; + uint8_t pressed = button_is_pressed(); + if (was_pressed != pressed) { + go_to_standby = 0; + PCINT_inner(pressed); + } + #ifdef TICK_DURING_STANDBY static uint16_t sleep_counter = 0; // handle standby mode specially if (go_to_standby) { @@ -107,11 +119,6 @@ ISR(WDT_vect) { else { sleep_counter = 0; } #endif - // detect and emit button change events - uint8_t was_pressed = button_last_state; - uint8_t pressed = button_is_pressed(); - if (was_pressed != pressed) PCINT_inner(pressed); - // cache this here to reduce ROM size, because it's volatile uint16_t ticks_since_last = ticks_since_last_event; @@ -178,6 +185,7 @@ ISR(WDT_vect) { if (go_to_standby) ADC_on(); #endif ADC_start_measurement(); + irq_adc_stable = 0; adcint_enable = 1; } #endif |
