From 106405aace27889a4012a918846432d8f70df37b Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 14 Oct 2015 10:03:26 -0700 Subject: firmware: e3xx: Turn off overzealous shutdown. Signed-off-by: Moritz Fischer --- firmware/e300/battery/bq2419x.c | 4 ++-- firmware/e300/battery/pmu.c | 1 - 2 files changed, 2 insertions(+), 3 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/pmu.c b/firmware/e300/battery/pmu.c index bd337783f..afd5036fa 100644 --- a/firmware/e300/battery/pmu.c +++ b/firmware/e300/battery/pmu.c @@ -588,7 +588,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: -- cgit v1.2.3 From 9b8fdb018289219b46974d7a376acb043e1f99c0 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 8 Sep 2015 15:54:35 -0700 Subject: firmware: e3xx: Add panic button functionality. Signed-off-by: Moritz Fischer --- firmware/e300/battery/pmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/firmware/e300/battery/pmu.c b/firmware/e300/battery/pmu.c index afd5036fa..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; -- cgit v1.2.3 From 71bce47ecfc34a4caa0fc508b4ee8e27974e19b7 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Wed, 21 Oct 2015 18:09:16 -0700 Subject: firmware: e3xx: Bump minor version. Signed-off-by: Moritz Fischer --- firmware/e300/battery/mcu_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- cgit v1.2.3 From ea3040da12af46e5d227fe5edeb4d580e42d7658 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 5 Jan 2016 13:57:04 -0800 Subject: firmware: e3xx: Added .eeprom section that gets written. The EEPROM section was not getting written by make install, so whatever was in there is in there. Signed-off-by: Moritz Fischer --- firmware/e300/battery/Makefile | 9 +++++++-- firmware/e300/battery/eeprom.c | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/firmware/e300/battery/Makefile b/firmware/e300/battery/Makefile index 1ce0bf279..7f825cbd8 100644 --- a/firmware/e300/battery/Makefile +++ b/firmware/e300/battery/Makefile @@ -40,17 +40,18 @@ PROGRAMMER = jtag3isp PORT = usb AVRDUDE = avrdude -p $(MMCU) -c $(PROGRAMMER) -P $(PORT) -V FUSES = -U hfuse:w:hfuse.hex:i -U lfuse:w:lfuse.hex:i -U efuse:w:efuse.hex:i -u +EEPROM = -U eeprom:w:$(TARGET).eeprom.hex ################################################## # Global Targets ################################################## -all: $(TARGET).hex size hfuse.hex lfuse.hex efuse.hex +all: $(TARGET).hex $(TARGET).eeprom.hex size hfuse.hex lfuse.hex efuse.hex clean: $(RM) *.o *.elf *.hex install: all - $(AVRDUDE) -U flash:w:$(TARGET).hex:i $(FUSES) + $(AVRDUDE) -U flash:w:$(TARGET).hex:i $(FUSES) $(EEPROM) size: $(TARGET).hex @$(SIZE) --format=SysV --mcu=$(MMCU) $(TARGET).elf @@ -74,6 +75,10 @@ efuse.hex: fuses.hex $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -R .eeprom -R .fuse -O ihex $< $@ +$(TARGET).eeprom.hex: $(TARGET).elf + $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma \ + .eeprom=0 -O ihex $(TARGET).elf $@ + $(TARGET).elf: $(SRCS:.c=.o) $(CC) -mmcu=$(MMCU) $^ -o $@ diff --git a/firmware/e300/battery/eeprom.c b/firmware/e300/battery/eeprom.c index f8bc172d2..79b1f9052 100644 --- a/firmware/e300/battery/eeprom.c +++ b/firmware/e300/battery/eeprom.c @@ -16,6 +16,9 @@ #include "eeprom.h" #include +/* default values for eeprom */ +char eeprom[] EEMEM = {0x00, 0x00, 0x00}; + /* the avr libc wants it this way ... */ static uint8_t* EEPROM_AUTOBOOT_OFFSET = (uint8_t *) 0x00; static uint16_t *EEPROM_LAST_FULL_OFFSET = (uint16_t *) 0x04; -- cgit v1.2.3 From bbeacff2b1bc3a17254167a79a26a2a2c82e906c Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 5 Jan 2016 14:56:41 -0800 Subject: firmware: e3xx: This fixes an issue with the autoboot value. The bug is a result of wrong order of evaluation: The '|' operator takes precedence over '?'. Therefore the intended expression a = x | (y ? 1 : 0) got evaluated as a = (x | y) ? 1 : 0. Signed-off-by: Moritz Fischer --- firmware/e300/battery/fpga.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/e300/battery/fpga.c b/firmware/e300/battery/fpga.c index 20404e5a1..2dc9fb09d 100644 --- a/firmware/e300/battery/fpga.c +++ b/firmware/e300/battery/fpga.c @@ -248,7 +248,8 @@ void fpga_init(void) fpga_tx2.type = 2; /* get autoboot value from eeprom, keep TX reg on */ - fpga_tx2.settings = BIT(1) | eeprom_get_autoboot() ? 0x1 : 0x0; + fpga_tx2.settings = BIT(1); + fpga_tx2.settings |= eeprom_get_autoboot() ? BIT(0) : 0x0; memset((void *) &fpga_rx, 0, sizeof(fpga_rx)); -- cgit v1.2.3 From 69be2678f7ff97ea844136f40f3be18084357d38 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Tue, 26 Jan 2016 17:31:05 +0100 Subject: firmware: e3xx: Bump minor version to 2.2 Signed-off-by: Moritz Fischer --- firmware/e300/battery/mcu_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/e300/battery/mcu_settings.h b/firmware/e300/battery/mcu_settings.h index 1472c183a..75f31518c 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 1 +#define VERSION_MIN 2 #endif /* MCU_SETTINGS_H */ -- cgit v1.2.3