aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/e300/battery
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/e300/battery')
-rw-r--r--firmware/e300/battery/bq2419x.c4
-rw-r--r--firmware/e300/battery/mcu_settings.h2
-rw-r--r--firmware/e300/battery/pmu.c13
3 files changed, 15 insertions, 4 deletions
diff --git a/firmware/e300/battery/bq2419x.c b/firmware/e300/battery/bq2419x.c
index 11b393622..0545fcf56 100644
--- a/firmware/e300/battery/bq2419x.c
+++ b/firmware/e300/battery/bq2419x.c
@@ -571,9 +571,9 @@ int8_t bq2419x_init(void)
ir_comp &= ~BQ2419X_BAT_COMP_MASK;
ir_comp |= (0x02 << BQ2419X_BAT_COMP_SHIFT);
- /* set thermal regulation to 60 C */
+ /* set thermal regulation to 120 C */
ir_comp &= ~BQ2419X_TREG_MASK;
- ir_comp |= (0x00 << BQ2419X_TREG_SHIFT);
+ ir_comp |= (0x03 << BQ2419X_TREG_SHIFT);
ret = bq2419x_write(BQ2419X_REG_THERMAL_REG_CTRL, ir_comp);
if (ret)
diff --git a/firmware/e300/battery/mcu_settings.h b/firmware/e300/battery/mcu_settings.h
index 175cb8f44..1472c183a 100644
--- a/firmware/e300/battery/mcu_settings.h
+++ b/firmware/e300/battery/mcu_settings.h
@@ -23,6 +23,6 @@
#define F_CPU 8000000UL
#define VERSION_MAJ 2
-#define VERSION_MIN 0
+#define VERSION_MIN 1
#endif /* MCU_SETTINGS_H */
diff --git a/firmware/e300/battery/pmu.c b/firmware/e300/battery/pmu.c
index bd337783f..59ba171a3 100644
--- a/firmware/e300/battery/pmu.c
+++ b/firmware/e300/battery/pmu.c
@@ -58,11 +58,14 @@ static io_pin_t AVR_IRQ = IO_PD(5);
static io_pin_t PS_POR = IO_PD(6);
static io_pin_t PS_SRST = IO_PD(7);
static io_pin_t OVERTEMP = IO_PC(2);
+static io_pin_t PANICn = IO_PC(1);
static uint16_t last_full_charge;
static uint16_t charge_on_last_unplug;
static bool battery_present_last;
+static bool panic_last;
+
static const uint8_t PMU_BLINK_ERROR_DELAY_MS = 250;
static const uint8_t PMU_BLINK_ERROR_TICKS_PER_BLINK = 10;
@@ -224,6 +227,10 @@ int8_t pmu_init(void)
state = OFF;
+ /* make panic button an input */
+ io_input_pin(PANICn);
+ panic_last = io_test_pin(PANICn);
+
/* make the LED outputs */
io_output_pin(CHARGE);
io_output_pin(POWER_LED);
@@ -525,6 +532,7 @@ void pmu_handle_events(void)
bool is_charging = false;
bool is_full = false;
bool overtemp = io_test_pin(OVERTEMP);
+ bool panic = io_test_pin(PANICn);
/* check if someone plugged the battery late,
* if so init gauge */
@@ -537,6 +545,10 @@ void pmu_handle_events(void)
}
battery_present_last = battery_present;
+ if (panic != panic_last)
+ pmu_power_down();
+ panic_last = panic;
+
if (overtemp) {
fpga_set_gauge_status(BIT(6));
pmu_error = PMU_ERROR_GLOBAL_TEMP;
@@ -588,7 +600,6 @@ void pmu_handle_events(void)
uint8_t health = pmu_battery_get_health(charger);
switch (health) {
case PMU_HEALTH_OVERHEAT:
- pmu_power_down();
pmu_error = PMU_ERROR_CHARGER_TEMP;
break;
default: