Skip to content

Commit

Permalink
Added shutdown command, increased short circuit fault timing.
Browse files Browse the repository at this point in the history
  • Loading branch information
o7-machinehum committed Oct 16, 2023
1 parent b4bc7f9 commit d79242b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stm32-app/bq76920.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void bq76920_init()
bq76920_write_reg(SYS_CTRL1, SYS_CTRL1_ADC_EN); // ADC_EN = 1

bq76920_write_reg(CELLBAL1, 0x00);
bq76920_write_reg(PROTECT1, PROTECT1_SCD_T0);
bq76920_write_reg(PROTECT1, PROTECT1_SCD_T1);
// PROTECT2 Left at default settings (8A Over Current)
}

Expand Down
1 change: 1 addition & 0 deletions stm32-app/bq76920.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#define PROTECT1 0x06
#define PROTECT1_SCD_T0 (1 << 0)
#define PROTECT1_SCD_T1 (1 << 1)

#define OV_TRIP 0x09
#define UV_TRIP 0x0A
Expand Down
9 changes: 9 additions & 0 deletions stm32-app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ static void gpio_setup(void)
gpio_mode_setup(PORT_LED, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
PIN_LED1 | PIN_LED2);

// Shutdown buttons
gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO13);

// allert
gpio_mode_setup(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO8);
}

Expand Down Expand Up @@ -184,6 +188,11 @@ int main(void)
uart_out(buf);
}

if(!gpio_get(GPIOA, GPIO13)) {
sprintf(buf, "Shutting down\n\r");
uart_out(buf);
bq76920_shutdown();
}
gpio_toggle(PORT_LED, PIN_LED2);
delay(5e6);
}
Expand Down
2 changes: 1 addition & 1 deletion stm32-app/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ ifeq ($(OOCD_FILE),)
(echo "halt; program $(realpath $(*).elf) verify reset" | nc -4 localhost 4444 2>/dev/null) || \
$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
-f target/$(OOCD_TARGET).cfg \
-c "program $(*).elf verify reset exit"
-c "reset_config srst_only connect_assert_srst; program $(*).elf verify reset exit"
else
%.flash: %.elf
@printf " FLASH $<\n"
Expand Down

0 comments on commit d79242b

Please sign in to comment.