aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-adc.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-18 03:29:21 -0600
committerSelene ToyKeeper2020-03-18 03:29:21 -0600
commit654fab1fa72a2d3a014632779106e57c150296ee (patch)
tree1712d6ecdfd9370573524149817adf893346f0ce /spaghetti-monster/fsm-adc.c
parentremoved more references to THERM_HARD_TURBO_DROP (diff)
parentmerged fsm branch, mostly to get new ADC code (thermal regulation and voltage... (diff)
downloadanduril-654fab1fa72a2d3a014632779106e57c150296ee.tar.gz
anduril-654fab1fa72a2d3a014632779106e57c150296ee.tar.bz2
anduril-654fab1fa72a2d3a014632779106e57c150296ee.zip
merged Noctigon K1 branch, which changes a few things...
- added support for 10-bit PWM - 10-bit ADC voltage divider calibration values instead of 8-bit - added ability to use different DIDR channels on different hardware - made dynamic underclocking configurable per build target - expanded RGB aux LED support - increased resolution of RGB voltage readout (6 colors instead of 3) - made party strobe ontime configurable per build target - added support for an enable/disable pin for a regulator chip
Diffstat (limited to 'spaghetti-monster/fsm-adc.c')
-rw-r--r--spaghetti-monster/fsm-adc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c
index 59d624b..eef3baf 100644
--- a/spaghetti-monster/fsm-adc.c
+++ b/spaghetti-monster/fsm-adc.c
@@ -81,10 +81,10 @@ inline void ADC_on()
set_admux_voltage();
#ifdef USE_VOLTAGE_DIVIDER
// disable digital input on divider pin to reduce power consumption
- DIDR0 |= (1 << VOLTAGE_ADC_DIDR);
+ VOLTAGE_ADC_DIDR |= (1 << VOLTAGE_ADC);
#else
// disable digital input on VCC pin to reduce power consumption
- //DIDR0 |= (1 << ADC_DIDR); // FIXME: unsure how to handle for VCC pin
+ //VOLTAGE_ADC_DIDR |= (1 << VOLTAGE_ADC); // FIXME: unsure how to handle for VCC pin
#endif
#if (ATTINY == 1634)
//ACSRA |= (1 << ACD); // turn off analog comparator to save power
@@ -111,8 +111,8 @@ inline void 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
- uint16_t adc_per_volt = ((ADC_44<<7) - (ADC_22<<7)) / (44-22);
+ // use fixed-point to get sufficient precision
+ uint16_t adc_per_volt = ((ADC_44<<5) - (ADC_22<<5)) / (44-22);
// shift incoming value into a matching position
uint8_t result = ((value>>1) / adc_per_volt) + VOLTAGE_FUDGE_FACTOR;
return result;