aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-12-05 16:47:24 -0700
committerSelene ToyKeeper2023-12-05 16:47:24 -0700
commit843dc0ba1c06e4a9b1bf034fff0e6ec5f8c12c84 (patch)
treefa8fdf09bffa0769312e88e7caa5c4dfb6dad8c2 /hw
parentemisar-d3aa: new model number, since this is a new product line (diff)
downloadanduril-843dc0ba1c06e4a9b1bf034fff0e6ec5f8c12c84.tar.gz
anduril-843dc0ba1c06e4a9b1bf034fff0e6ec5f8c12c84.tar.bz2
anduril-843dc0ba1c06e4a9b1bf034fff0e6ec5f8c12c84.zip
d3aa: made it easy to switch between vddio2 and external voltage divider
Diffstat (limited to 'hw')
-rw-r--r--hw/hank/emisar-d3aa/hwdef.c2
-rw-r--r--hw/hank/emisar-d3aa/hwdef.h21
2 files changed, 14 insertions, 9 deletions
diff --git a/hw/hank/emisar-d3aa/hwdef.c b/hw/hank/emisar-d3aa/hwdef.c
index 853e84d..5f41d9d 100644
--- a/hw/hank/emisar-d3aa/hwdef.c
+++ b/hw/hank/emisar-d3aa/hwdef.c
@@ -104,6 +104,7 @@ bool gradual_tick_main(uint8_t gt) {
}
+#ifdef USE_VOLTAGE_DIVIDER
uint8_t voltage_raw2cooked(uint16_t measurement) {
// In : 65535 * BATTLVL / 1.024V
// Out: uint8_t: Vbat * 40
@@ -115,4 +116,5 @@ uint8_t voltage_raw2cooked(uint16_t measurement) {
* 43 / 16128;
return result;
}
+#endif
diff --git a/hw/hank/emisar-d3aa/hwdef.h b/hw/hank/emisar-d3aa/hwdef.h
index 8677609..1001e5d 100644
--- a/hw/hank/emisar-d3aa/hwdef.h
+++ b/hw/hank/emisar-d3aa/hwdef.h
@@ -97,17 +97,20 @@ enum CHANNEL_MODES {
#define SWITCH_INTFLG VPORTA.INTFLAGS
#endif
-// TODO: define stuff for the voltage divider
-// AVR datasheet table 3.1 I/O Multiplexing, PA5 ADC0 = AIN25
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is regulated
-#define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN25_gc
#define DUAL_VOLTAGE_FLOOR (4*21) // for AA/14500 boost drivers, don't indicate low voltage if below this level
#define DUAL_VOLTAGE_LOW_LOW (4*7) // the lower voltage range's danger zone 0.7 volts (NiMH)
-// don't use the default VDD converter
-// convert BATT LVL pin readings to FSM volt units
-#undef voltage_raw2cooked
-uint8_t voltage_raw2cooked(uint16_t measurement);
-
+// comment out to use VDDIO2 instead of external voltage divider
+//#define USE_VOLTAGE_DIVIDER
+#ifdef USE_VOLTAGE_DIVIDER
+ // AVR datasheet table 3.1 I/O Multiplexing, PA5 ADC0 = AIN25
+ #define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN25_gc
+ // don't use the default VDD converter
+ // convert BATT LVL pin readings to FSM volt units
+ #undef voltage_raw2cooked
+ uint8_t voltage_raw2cooked(uint16_t measurement);
+#else
+ #define USE_VOLTAGE_VDDIO2
+#endif
// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
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.