aboutsummaryrefslogtreecommitdiff
path: root/hw/thefreeman/avr32dd20-devkit
diff options
context:
space:
mode:
Diffstat (limited to 'hw/thefreeman/avr32dd20-devkit')
-rw-r--r--hw/thefreeman/avr32dd20-devkit/anduril.h1
-rw-r--r--hw/thefreeman/avr32dd20-devkit/hwdef.c13
-rw-r--r--hw/thefreeman/avr32dd20-devkit/hwdef.h23
3 files changed, 35 insertions, 2 deletions
diff --git a/hw/thefreeman/avr32dd20-devkit/anduril.h b/hw/thefreeman/avr32dd20-devkit/anduril.h
index 02d5de3..3152183 100644
--- a/hw/thefreeman/avr32dd20-devkit/anduril.h
+++ b/hw/thefreeman/avr32dd20-devkit/anduril.h
@@ -110,6 +110,7 @@
#define PARTY_STROBE_ONTIME 1 // slow down party strobe
#define STROBE_OFF_LEVEL 1 // keep the regulator chip on between pulses
+#define BLIP_LEVEL 1 // same
// smoother candle mode with bigger oscillations
#define CANDLE_AMPLITUDE 40
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;
diff --git a/hw/thefreeman/avr32dd20-devkit/hwdef.h b/hw/thefreeman/avr32dd20-devkit/hwdef.h
index f1b6095..38b508d 100644
--- a/hw/thefreeman/avr32dd20-devkit/hwdef.h
+++ b/hw/thefreeman/avr32dd20-devkit/hwdef.h
@@ -28,6 +28,7 @@
* 18 PA1 G: aux green
* 19 PA2 B: aux blue
* 20 PA3 CH: detect charging
+ * or BBY: boost bypass PFET
*
* BST EN enable the boost regulator and Op-Amp
* DAC sets the current, max current depends on Vset voltage divider and Rsense
@@ -35,6 +36,8 @@
* and low value Rsense (high current range, pin high)
* IN- NFET : pull up after BST enable to eliminate startup flash, pull down otherwise
* CH senses the status of the onboard charger
+ * BBY routes power around the boost converter in li-ion 3V mode
+ * (pin low = bypass, pin high = boost)
* BATT LVL : Vbat * (100.0/(330+100))
* LVB is for OTSM firmware, not used here
*/
@@ -77,6 +80,11 @@ enum CHANNEL_MODES {
#define BST_ENABLE_PIN PIN5_bp
#define BST_ENABLE_PORT PORTD_OUT
+// BST bypass
+#define USE_BST_BYPASS
+#define BST_BYPASS_PIN PIN3_bp
+#define BST_BYPASS_PORT PORTA_OUT
+
// HDR
// turns on HDR FET for the high current range
#define HDR_ENABLE_PIN PIN7_bp
@@ -133,7 +141,9 @@ inline void hwdef_setup() {
VPORTA.DIR = PIN0_bm // R
| PIN1_bm // G
| PIN2_bm // B
- //| PIN3_bm // CH
+ #ifdef USE_BST_BYPASS
+ | PIN3_bm // BBY
+ #endif
| PIN7_bm; // HDR
VPORTD.DIR = PIN5_bm // EN
| PIN6_bm // DAC
@@ -143,7 +153,10 @@ inline void hwdef_setup() {
//PORTA.PIN0CTRL = PORT_PULLUPEN_bm; // R
//PORTA.PIN1CTRL = PORT_PULLUPEN_bm; // G
//PORTA.PIN2CTRL = PORT_PULLUPEN_bm; // B
- //PORTA.PIN3CTRL = PORT_PULLUPEN_bm; // CH
+ #ifdef USE_BST_BYPASS
+ PORTA.PIN3CTRL = PORT_PULLUPEN_bm; // BBY
+ BST_BYPASS_PORT |= (1 << BST_BYPASS_PIN);
+ #endif
PORTA.PIN4CTRL = PORT_PULLUPEN_bm;
PORTA.PIN5CTRL = PORT_PULLUPEN_bm;
//PORTA.PIN6CTRL = PORT_PULLUPEN_bm; // BATT LVL
@@ -177,6 +190,12 @@ inline void hwdef_setup() {
// to generate a zero without spending power on the DAC
// (and do this in set_level_zero() too)
+ // TCA/TCB/TCD aren't being used, so turn them off
+ TCA0.SINGLE.CTRLA = 0;
+ TCB0.CTRLA = 0;
+ TCB1.CTRLA = 0;
+ TCD0.CTRLA = 0;
+
}