stm32/mboot: Support boards with only two LEDs.
Mboot currently requires at least three LEDs to display each of the four states. However, since there are only four possible states, the states can be displayed via binary counting on only 2 LEDs (if only 2 are available). The existing patterns are still used for 3 or 4 LEDs.
This commit is contained in:
parent
ea060a42e9
commit
a605b53702
|
@ -408,7 +408,9 @@ void mp_hal_pin_config_speed(uint32_t port_pin, uint32_t speed) {
|
|||
|
||||
#define LED0 MICROPY_HW_LED1
|
||||
#define LED1 MICROPY_HW_LED2
|
||||
#ifdef MICROPY_HW_LED3
|
||||
#define LED2 MICROPY_HW_LED3
|
||||
#endif
|
||||
#ifdef MICROPY_HW_LED4
|
||||
#define LED3 MICROPY_HW_LED4
|
||||
#endif
|
||||
|
@ -416,7 +418,9 @@ void mp_hal_pin_config_speed(uint32_t port_pin, uint32_t speed) {
|
|||
void led_init(void) {
|
||||
mp_hal_pin_output(LED0);
|
||||
mp_hal_pin_output(LED1);
|
||||
#ifdef LED2
|
||||
mp_hal_pin_output(LED2);
|
||||
#endif
|
||||
#ifdef LED3
|
||||
mp_hal_pin_output(LED3);
|
||||
#endif
|
||||
|
@ -436,7 +440,9 @@ void led_state(int led, int val) {
|
|||
void led_state_all(unsigned int mask) {
|
||||
led_state(LED0, mask & 1);
|
||||
led_state(LED1, mask & 2);
|
||||
#ifdef LED2
|
||||
led_state(LED2, mask & 4);
|
||||
#endif
|
||||
#ifdef LED3
|
||||
led_state(LED3, mask & 8);
|
||||
#endif
|
||||
|
@ -1345,11 +1351,15 @@ static int pyb_usbdd_shutdown(void) {
|
|||
|
||||
#define RESET_MODE_NUM_STATES (4)
|
||||
#define RESET_MODE_TIMEOUT_CYCLES (8)
|
||||
#ifdef LED2
|
||||
#ifdef LED3
|
||||
#define RESET_MODE_LED_STATES 0x8421
|
||||
#else
|
||||
#define RESET_MODE_LED_STATES 0x7421
|
||||
#endif
|
||||
#else
|
||||
#define RESET_MODE_LED_STATES 0x3210
|
||||
#endif
|
||||
|
||||
static int get_reset_mode(void) {
|
||||
usrbtn_init();
|
||||
|
|
Loading…
Reference in New Issue