aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-wdt.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-16 21:58:42 -0600
committerSelene ToyKeeper2020-03-16 21:58:42 -0600
commited3fcdb8f3363c4ccc87119c985d765bb3457515 (patch)
tree1712d6ecdfd9370573524149817adf893346f0ce /spaghetti-monster/fsm-wdt.c
parentmerged from fsm, mostly to get thermal regulation updates (diff)
parentremoved more references to THERM_HARD_TURBO_DROP (diff)
downloadanduril-ed3fcdb8f3363c4ccc87119c985d765bb3457515.tar.gz
anduril-ed3fcdb8f3363c4ccc87119c985d765bb3457515.tar.bz2
anduril-ed3fcdb8f3363c4ccc87119c985d765bb3457515.zip
merged fsm branch, mostly to get new ADC code (thermal regulation and voltage monitoring)
Diffstat (limited to 'spaghetti-monster/fsm-wdt.c')
-rw-r--r--spaghetti-monster/fsm-wdt.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index 0c49a75..94266c1 100644
--- a/spaghetti-monster/fsm-wdt.c
+++ b/spaghetti-monster/fsm-wdt.c
@@ -111,7 +111,7 @@ void WDT_inner() {
#ifdef TICK_DURING_STANDBY
// handle standby mode specially
if (go_to_standby) {
- // emit a halfsleep tick, and process it
+ // emit a sleep tick, and process it
emit(EV_sleep_tick, ticks_since_last);
process_emissions();
@@ -119,9 +119,9 @@ void WDT_inner() {
return; // no sleep LVP needed if nothing drains power while off
#else
// stop here, usually... but proceed often enough for sleep LVP to work
- if (0 != (ticks_since_last & 0x7f)) return;
+ if (0 != (ticks_since_last & 0x3f)) return;
- adc_trigger = 255; // make sure a measurement will happen
+ adc_trigger = 0; // make sure a measurement will happen
ADC_on(); // enable ADC voltage measurement functions temporarily
#endif
}
@@ -178,13 +178,13 @@ void WDT_inner() {
#endif
#if defined(USE_LVP) || defined(USE_THERMAL_REGULATION)
- // start a new ADC measurement every 4 ticks
- adc_trigger ++;
- if (0 == (adc_trigger & 3)) {
+ // enable the deferred ADC handler once in a while
+ if (! adc_trigger) {
ADC_start_measurement();
- irq_adc_stable = 0;
- adcint_enable = 1;
+ adc_deferred_enable = 1;
}
+ // timing for the ADC handler is every 32 ticks (~2Hz)
+ adc_trigger = (adc_trigger + 1) & 31;
#endif
}