diff options
| author | Matt van de Werken <matt.vandewerken@csiro.au> | 2020-07-02 17:36:27 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-11-17 14:46:58 +1100 |
| commit | a4c0f52714ed176587cb43f98ea7f3b2264c600e (patch) | |
| tree | 87993314a3bc5ab3c38feb7e43711af5474893a6 | |
| parent | 8f3510799d9ad5c2c19189a7a1dd1051d0d46c30 (diff) | |
stm32/led: Support an extra 2 LEDs in board configuration.
Although the pyboard has only 4 LEDs, there are some boards that (may) have
more. This commit adds 2 more LEDs to the led.c file that if defined in
the board-specific config file will be compiled in.
| -rw-r--r-- | ports/stm32/led.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ports/stm32/led.c b/ports/stm32/led.c index adcb240cc..078327462 100644 --- a/ports/stm32/led.c +++ b/ports/stm32/led.c @@ -58,6 +58,12 @@ STATIC const pyb_led_obj_t pyb_led_obj[] = { {{&pyb_led_type}, 3, MICROPY_HW_LED3}, #if defined(MICROPY_HW_LED4) {{&pyb_led_type}, 4, MICROPY_HW_LED4}, + #if defined(MICROPY_HW_LED5) + {{&pyb_led_type}, 5, MICROPY_HW_LED5}, + #if defined(MICROPY_HW_LED6) + {{&pyb_led_type}, 6, MICROPY_HW_LED6}, + #endif + #endif #endif #endif #endif @@ -77,7 +83,9 @@ void led_init(void) { #if defined(MICROPY_HW_LED1_PWM) \ || defined(MICROPY_HW_LED2_PWM) \ || defined(MICROPY_HW_LED3_PWM) \ - || defined(MICROPY_HW_LED4_PWM) + || defined(MICROPY_HW_LED4_PWM) \ + || defined(MICROPY_HW_LED5_PWM) \ + || defined(MICROPY_HW_LED6_PWM) // The following is semi-generic code to control LEDs using PWM. // It currently supports TIM1, TIM2 and TIM3, channels 1-4. @@ -98,6 +106,12 @@ void led_init(void) { #ifndef MICROPY_HW_LED4_PWM #define MICROPY_HW_LED4_PWM { NULL, 0, 0, 0 } #endif +#ifndef MICROPY_HW_LED5_PWM +#define MICROPY_HW_LED5_PWM { NULL, 0, 0, 0 } +#endif +#ifndef MICROPY_HW_LED6_PWM +#define MICROPY_HW_LED6_PWM { NULL, 0, 0, 0 } +#endif #define LED_PWM_TIM_PERIOD (10000) // TIM runs at 1MHz and fires every 10ms @@ -116,6 +130,8 @@ STATIC const led_pwm_config_t led_pwm_config[] = { MICROPY_HW_LED2_PWM, MICROPY_HW_LED3_PWM, MICROPY_HW_LED4_PWM, + MICROPY_HW_LED5_PWM, + MICROPY_HW_LED6_PWM, }; STATIC uint8_t led_pwm_state = 0; |
