aboutsummaryrefslogtreecommitdiff
path: root/hw/thefreeman/avr32dd20-devkit/hwdef.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-01-30 14:54:13 -0700
committerSelene ToyKeeper2024-01-30 14:54:13 -0700
commitcbfc1a13a9c9a8c08c054658ed26d2350383d209 (patch)
treeecc6218fb4c036dfad4116d3f52b80e6fa0946bc /hw/thefreeman/avr32dd20-devkit/hwdef.c
parentadded "emisar-2ch-fet-joined" build, for D4S w/ lighted switch (diff)
downloadanduril-cbfc1a13a9c9a8c08c054658ed26d2350383d209.tar.gz
anduril-cbfc1a13a9c9a8c08c054658ed26d2350383d209.tar.bz2
anduril-cbfc1a13a9c9a8c08c054658ed26d2350383d209.zip
avr32dd20-devkit: use unimplemented "CH" pin as a boost bypass control
For 3V LEDs on a boost/buck dual fuel driver, this allows routing power around the boost converter in li-ion mode, to reduce resistance and increase maximum output. The AA/NiMH mode is unaffected, and boosts as normal.
Diffstat (limited to 'hw/thefreeman/avr32dd20-devkit/hwdef.c')
-rw-r--r--hw/thefreeman/avr32dd20-devkit/hwdef.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/thefreeman/avr32dd20-devkit/hwdef.c b/hw/thefreeman/avr32dd20-devkit/hwdef.c
index 3e5dd79..460082f 100644
--- a/hw/thefreeman/avr32dd20-devkit/hwdef.c
+++ b/hw/thefreeman/avr32dd20-devkit/hwdef.c
@@ -30,6 +30,11 @@ void set_level_zero() {
delay_4ms(IN_NFET_DELAY_TIME/4);
IN_NFET_ENABLE_PORT &= ~(1 << IN_NFET_ENABLE_PIN);
+ #ifdef USE_BST_BYPASS
+ // turn off bypass
+ BST_BYPASS_PORT |= (1 << BST_BYPASS_PIN);
+ #endif
+
// turn off boost last
BST_ENABLE_PORT &= ~(1 << BST_ENABLE_PIN); // BST off
}
@@ -48,6 +53,14 @@ void set_level_main(uint8_t level) {
// BST on first, to give it a few extra microseconds to spin up
BST_ENABLE_PORT |= (1 << BST_ENABLE_PIN);
+ #ifdef USE_BST_BYPASS
+ // turn on bypass in li-ion mode
+ if (voltage > DUAL_VOLTAGE_FLOOR)
+ BST_BYPASS_PORT &= ~(1 << BST_BYPASS_PIN); // low = bypass
+ else // turn off bypass in AA/NiMH mode
+ BST_BYPASS_PORT |= (1 << BST_BYPASS_PIN); // high = boost
+ #endif
+
// pre-load ramp data so it can be assigned faster later
// DAC level register is left-aligned
PWM1_DATATYPE dac_lvl = PWM1_GET(level) << 6;