aboutsummaryrefslogtreecommitdiff
path: root/hw/thefreeman/avr32dd20-devkit/hwdef.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-04 04:42:09 -0700
committerSelene ToyKeeper2024-03-04 04:42:09 -0700
commit984758be300392d8390c9407b8c58a01f945653a (patch)
treea5087c862d40e4c23976dfe6c9a263d2623f7b39 /hw/thefreeman/avr32dd20-devkit/hwdef.c
parentMerge branch 'trunk' into emisar-d3aa (diff)
parentenabled eeprom read/write stabilization by default on recent MCUs, (diff)
downloadanduril-984758be300392d8390c9407b8c58a01f945653a.tar.gz
anduril-984758be300392d8390c9407b8c58a01f945653a.tar.bz2
anduril-984758be300392d8390c9407b8c58a01f945653a.zip
Merge branch 'trunk' into emisar-d3aa
* trunk: enabled eeprom read/write stabilization by default on recent MCUs, to prevent corrupt data thefreeman-avr32dd20-devkit: enable boost bypass at boot, so AA/NiMH can boot avr32dd20-devkit: use unimplemented "CH" pin as a boost bypass control added "emisar-2ch-fet-joined" build, for D4S w/ lighted switch documented FW3X swapped pins better documented Wurkkos TS25/TS11/FC13 distinctions build.sh: don't require DFPs, newer avr-libc doesn't need them use BLIP_LEVEL instead of 0 for "blip"s clarified which-hex-file.md a bit; make sure the model number matches fw3x: reduced pulsing on low modes
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;