aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-adc.h
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-11-14 01:52:50 -0700
committerSelene ToyKeeper2019-11-14 01:52:50 -0700
commit8b59e880614455bd7bc7d8595de847dd6fe9b5b2 (patch)
treea7426296b9fa1471ba2841eba0415bbfaed3e5c7 /spaghetti-monster/fsm-adc.h
parentfixed some compile issues related to delay_4ms() (diff)
downloadanduril-8b59e880614455bd7bc7d8595de847dd6fe9b5b2.tar.gz
anduril-8b59e880614455bd7bc7d8595de847dd6fe9b5b2.tar.bz2
anduril-8b59e880614455bd7bc7d8595de847dd6fe9b5b2.zip
refactored how interrupts work...
set a flag and return immediately, then handle the actual logic later during a less-critical code path Enables smarter responses to standby wakeups. Seems to fix missed button presses during standby, and most of the too-fast sleep ticks. Also eliminated waits from button state measurement, so it can happen easier during standby. (also eliminates the chance of an infinite loop on extra-noisy hardware) Also might improve timing-sensitive interrupts like attiny85 PWM channel 4, or a PWM-DSM hybrid technique I'd like to try. BUT this change also appears to break the thermal sensor, so that needs to be fixed.
Diffstat (limited to '')
-rw-r--r--spaghetti-monster/fsm-adc.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-adc.h b/spaghetti-monster/fsm-adc.h
index 274fb4d..acb3da6 100644
--- a/spaghetti-monster/fsm-adc.h
+++ b/spaghetti-monster/fsm-adc.h
@@ -38,9 +38,15 @@
#define VOLTAGE_FUDGE_FACTOR 5
#endif
#endif
+
+volatile uint8_t irq_adc = 0; // ADC interrupt happened?
+uint16_t adc_value; // last ADC measurement
+uint8_t adcint_enable = 0; // is the current ADC result needed?
+void ADC_inner(); // do the actual ADC-related calculations
+
volatile uint8_t voltage = 0;
-volatile uint8_t adcint_enable; // kludge, because adc auto-retrigger won't turn off
void low_voltage();
+
#ifdef USE_BATTCHECK
void battcheck();
#ifdef BATTCHECK_VpT