stm32/mboot: Provide led_state_all function to reduce code size.

This commit is contained in:
Damien George 2018-12-04 23:11:51 +11:00
parent 9262f54138
commit 13e92e1225
1 changed files with 11 additions and 15 deletions

View File

@ -298,6 +298,12 @@ void led_state(int led, int val) {
} }
} }
void led_state_all(unsigned int mask) {
led_state(LED0, mask & 1);
led_state(LED1, mask & 2);
led_state(LED2, mask & 4);
}
/******************************************************************************/ /******************************************************************************/
// USR BUTTON // USR BUTTON
@ -1100,9 +1106,7 @@ static int get_reset_mode(void) {
reset_mode = 1; reset_mode = 1;
} }
uint8_t l = RESET_MODE_LED_STATES >> ((reset_mode - 1) * 4); uint8_t l = RESET_MODE_LED_STATES >> ((reset_mode - 1) * 4);
led_state(LED0, l & 1); led_state_all(l);
led_state(LED1, l & 2);
led_state(LED2, l & 4);
} }
if (!usrbtn_state()) { if (!usrbtn_state()) {
break; break;
@ -1111,14 +1115,10 @@ static int get_reset_mode(void) {
} }
// Flash the selected reset mode // Flash the selected reset mode
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
led_state(LED0, 0); led_state_all(0);
led_state(LED1, 0);
led_state(LED2, 0);
mp_hal_delay_ms(50); mp_hal_delay_ms(50);
uint8_t l = RESET_MODE_LED_STATES >> ((reset_mode - 1) * 4); uint8_t l = RESET_MODE_LED_STATES >> ((reset_mode - 1) * 4);
led_state(LED0, l & 1); led_state_all(l);
led_state(LED1, l & 2);
led_state(LED2, l & 4);
mp_hal_delay_ms(50); mp_hal_delay_ms(50);
} }
mp_hal_delay_ms(300); mp_hal_delay_ms(300);
@ -1127,9 +1127,7 @@ static int get_reset_mode(void) {
} }
static void do_reset(void) { static void do_reset(void) {
led_state(LED0, 0); led_state_all(0);
led_state(LED1, 0);
led_state(LED2, 0);
mp_hal_delay_ms(50); mp_hal_delay_ms(50);
pyb_usbdd_shutdown(); pyb_usbdd_shutdown();
#if defined(MBOOT_I2C_SCL) #if defined(MBOOT_I2C_SCL)
@ -1235,9 +1233,7 @@ enter_bootloader:
i2c_init(initial_r0); i2c_init(initial_r0);
#endif #endif
led_state(LED0, 0); led_state_all(0);
led_state(LED1, 0);
led_state(LED2, 0);
#if USE_USB_POLLING #if USE_USB_POLLING
uint32_t ss = systick_ms; uint32_t ss = systick_ms;