From bd5152c928a4a0809eaa340e0f8ae788a949daea Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 9 Jun 2022 12:20:42 +1000 Subject: [PATCH] stm32/mboot: Add board-configurable SysTick hook. Signed-off-by: Damien George --- ports/stm32/mboot/main.c | 4 ++-- ports/stm32/mboot/mboot.h | 6 +++++- ports/stm32/mboot/ui.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c index 8bd5e86fe7..734c6a3b7d 100644 --- a/ports/stm32/mboot/main.c +++ b/ports/stm32/mboot/main.c @@ -1518,9 +1518,9 @@ void SysTick_Handler(void) { // work properly. SysTick->CTRL; - // Update the LED0 state from here to ensure it's consistent regardless of + // Run any board-specific code that needs to be done regardless of // other processing going on in interrupts or main. - led0_update(); + MBOOT_BOARD_SYSTICK(); } #if defined(MBOOT_I2C_SCL) diff --git a/ports/stm32/mboot/mboot.h b/ports/stm32/mboot/mboot.h index 9f47811537..208a80d57d 100644 --- a/ports/stm32/mboot/mboot.h +++ b/ports/stm32/mboot/mboot.h @@ -54,6 +54,10 @@ #define MBOOT_BOARD_STATE_CHANGE(state, arg) mboot_state_change_default((state), (arg)) #endif +#ifndef MBOOT_BOARD_SYSTICK +#define MBOOT_BOARD_SYSTICK() mboot_ui_systick() +#endif + #ifndef MBOOT_ADDRESS_SPACE_64BIT #define MBOOT_ADDRESS_SPACE_64BIT (0) #endif @@ -148,7 +152,7 @@ extern uint8_t _estack[ELEM_DATA_SIZE]; void systick_init(void); void led_init(void); -void led0_update(void); +void mboot_ui_systick(void); void SystemClock_Config(void); uint32_t get_le32(const uint8_t *b); diff --git a/ports/stm32/mboot/ui.c b/ports/stm32/mboot/ui.c index db1bcc8b78..9924ecd0ba 100644 --- a/ports/stm32/mboot/ui.c +++ b/ports/stm32/mboot/ui.c @@ -122,7 +122,7 @@ void led0_state(led0_state_t state) { } } -void led0_update(void) { +void mboot_ui_systick(void) { if (led0_cur_state != LED0_STATE_OFF && systick_ms - led0_ms_interval > 50) { uint8_t rate = (led0_cur_state >> 2) & 0x1f; led0_ms_interval += 50;