summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-03-24 10:18:34 +1100
committerDamien George <damien@micropython.org>2022-04-11 15:52:41 +1000
commitcb0372b5bfe72fee99f5b3ffb94dcd1735353f4b (patch)
treeef294c8d4616251a1660d01f770eb0e37d2af588
parentb2deea67628b7069ed4e5d0cde84005738463514 (diff)
stm32/mboot: Add macros for use in led_state_all().
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/stm32/mboot/mboot.h6
-rw-r--r--ports/stm32/mboot/ui.c12
2 files changed, 12 insertions, 6 deletions
diff --git a/ports/stm32/mboot/mboot.h b/ports/stm32/mboot/mboot.h
index 0984fd9ac..db90e07a0 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 36cba1cf5..840803829 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);