From cb0372b5bfe72fee99f5b3ffb94dcd1735353f4b Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 24 Mar 2022 10:18:34 +1100 Subject: [PATCH] stm32/mboot: Add macros for use in led_state_all(). Signed-off-by: Damien George --- ports/stm32/mboot/mboot.h | 6 ++++++ ports/stm32/mboot/ui.c | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ports/stm32/mboot/mboot.h b/ports/stm32/mboot/mboot.h index 0984fd9ac5..db90e07a0e 100644 --- a/ports/stm32/mboot/mboot.h +++ b/ports/stm32/mboot/mboot.h @@ -46,6 +46,12 @@ #define MBOOT_ADDRESS_SPACE_64BIT (0) #endif +// These are for led_state_all() and can be or'd together. +#define MBOOT_LED_STATE_LED0 (0x01) +#define MBOOT_LED_STATE_LED1 (0x02) +#define MBOOT_LED_STATE_LED2 (0x04) +#define MBOOT_LED_STATE_LED3 (0x08) + // These enum values are passed as the first argument to mboot_state_change() to // notify of a change in state of the bootloader activity. This function has a // default implementation in ui.c but can be overridden by a board. Some states diff --git a/ports/stm32/mboot/ui.c b/ports/stm32/mboot/ui.c index 36cba1cf50..840803829e 100644 --- a/ports/stm32/mboot/ui.c +++ b/ports/stm32/mboot/ui.c @@ -103,15 +103,15 @@ MP_WEAK void led_state(uint32_t led, int val) { } void led_state_all(unsigned int mask) { - led_state(LED0, mask & 1); + led_state(LED0, mask & MBOOT_LED_STATE_LED0); #ifdef LED1 - led_state(LED1, mask & 2); + led_state(LED1, mask & MBOOT_LED_STATE_LED1); #endif #ifdef LED2 - led_state(LED2, mask & 4); + led_state(LED2, mask & MBOOT_LED_STATE_LED2); #endif #ifdef LED3 - led_state(LED3, mask & 8); + led_state(LED3, mask & MBOOT_LED_STATE_LED3); #endif } @@ -218,9 +218,9 @@ void mboot_state_change(mboot_state_t state, uint32_t arg) { // Flash LEDs based on success/failure of update for (int i = 0; i < 4; ++i) { if (arg == 0) { - led_state_all(7); + led_state_all(MBOOT_LED_STATE_LED0 | MBOOT_LED_STATE_LED1 | MBOOT_LED_STATE_LED2); } else { - led_state_all(1); + led_state_all(MBOOT_LED_STATE_LED0); } mp_hal_delay_ms(100); led_state_all(0);