stm32/mboot: Add macros for use in led_state_all().
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
b2deea6762
commit
cb0372b5bf
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user