diff options
| author | Selene ToyKeeper | 2023-11-19 01:56:17 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-11-19 01:56:17 -0700 |
| commit | 76db685f66baa7787ad94ce91585e7cba8b94cfb (patch) | |
| tree | 29499c612872908c7232984655aa65bcb70d3056 /fsm/adc.c | |
| parent | added dac-scale.py: short script to calculate avrdd DAC+Vref values from leve... (diff) | |
| download | anduril-76db685f66baa7787ad94ce91585e7cba8b94cfb.tar.gz anduril-76db685f66baa7787ad94ce91585e7cba8b94cfb.tar.bz2 anduril-76db685f66baa7787ad94ce91585e7cba8b94cfb.zip | |
started refactoring fsm/adc.*, but need a checkpoint before continuing
Diffstat (limited to '')
| -rw-r--r-- | fsm/adc.c | 23 |
1 files changed, 4 insertions, 19 deletions
@@ -15,14 +15,14 @@ #include <avr/sleep.h> -static inline void set_admux_therm() { +static inline void adc_therm_mode() { hwdef_set_admux_therm(); adc_channel = 1; adc_sample_count = 0; // first result is unstable ADC_start_measurement(); } -inline void set_admux_voltage() { +void adc_voltage_mode() { hwdef_set_admux_voltage(); adc_channel = 0; adc_sample_count = 0; // first result is unstable @@ -30,21 +30,6 @@ inline void set_admux_voltage() { } -#ifdef TICK_DURING_STANDBY - // needs a special sleep mode to get accurate measurements quickly - // ... full power-down ends up using more power overall, and causes - // some weird issues when the MCU doesn't stay awake enough cycles - // to complete a reading - #define adc_sleep_mode mcu_adc_sleep_mode -#endif - -#define ADC_start_measurement mcu_adc_start_measurement - -// set up ADC for reading battery voltage -#define ADC_on mcu_adc_on -// stop the ADC -#define ADC_off mcu_adc_off - #ifdef USE_VOLTAGE_DIVIDER static inline uint8_t calc_voltage_divider(uint16_t value) { // use 9.7 fixed-point to get sufficient precision @@ -160,7 +145,7 @@ void adc_deferred() { ADC_voltage_handler(); #ifdef USE_THERMAL_REGULATION // set the correct type of measurement for next time - if (! go_to_standby) set_admux_therm(); + if (! go_to_standby) adc_therm_mode(); #endif } #endif @@ -170,7 +155,7 @@ void adc_deferred() { ADC_temperature_handler(); #ifdef USE_LVP // set the correct type of measurement for next time - set_admux_voltage(); + adc_voltage_mode(); #endif } #endif |
