aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-16 00:13:44 -0600
committerSelene ToyKeeper2020-03-16 00:13:44 -0600
commit6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1 (patch)
tree7e99a01ee2d002e43fa8241e11a0c0f148d02267 /spaghetti-monster
parentreduced regulation jitter by biasing errors toward zero by a constant amount, (diff)
downloadanduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.tar.gz
anduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.tar.bz2
anduril-6e7884cf5b4756ffba9f6dc9dd1fb94184779bf1.zip
cleaned up WDT ADC timer code slightly, and removed a bit of redundant code
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-wdt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c
index 1d630a4..9858e09 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();
@@ -121,7 +121,7 @@ void WDT_inner() {
// stop here, usually... but proceed often enough for sleep LVP to work
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,18 +178,20 @@ void WDT_inner() {
#endif
#if defined(USE_LVP) || defined(USE_THERMAL_REGULATION)
- // enable the deferred ADC handler every 32 ticks
- adc_trigger ++;
- if (0 == (adc_trigger & 31)) {
+ // enable the deferred ADC handler once in a while
+ if (! adc_trigger) {
+ /* redundant; it was already turned on earlier in this function
// in case we're in standby mode and the ADC is turned off
if (go_to_standby) {
//set_admux_voltage();
ADC_on();
}
+ */
ADC_start_measurement();
- // allow regulation logic to run
adc_deferred_enable = 1;
}
+ // timing for the ADC handler is every 32 ticks (~2Hz)
+ adc_trigger = (adc_trigger + 1) & 31;
#endif
}
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.