Skip to content

Commit a64b5c8

Browse files
committed
nrf: Fix missing LED GPIO initialization
led_init was never called, which means the GPIOs were never set to output and the LEDs didn't work.
1 parent 7c6adaa commit a64b5c8

File tree

1 file changed

+3
-7
lines changed
  • ports/nrf/modules/machine

1 file changed

+3
-7
lines changed

ports/nrf/modules/machine/led.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ STATIC const pyb_led_obj_t pyb_led_obj[] = {
6363

6464
#define NUM_LEDS MP_ARRAY_SIZE(pyb_led_obj)
6565

66-
void led_init(void) {
67-
for (uint8_t i = 0; i < NUM_LEDS; i++) {
68-
LED_OFF(pyb_led_obj[i].hw_pin);
69-
hal_gpio_cfg_pin(0, pyb_led_obj[i].hw_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
70-
}
71-
}
72-
7366
void led_state(pyb_led_obj_t * led_obj, int state) {
7467
if (state == 1) {
7568
LED_ON(led_obj->hw_pin);
@@ -108,6 +101,9 @@ STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_
108101
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LED(%d) does not exist", led_id));
109102
}
110103

104+
hal_gpio_cfg_pin(0, pyb_led_obj[led_id - 1].hw_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
105+
LED_OFF(pyb_led_obj[led_id - 1].hw_pin);
106+
111107
// return static led object
112108
return (mp_obj_t)&pyb_led_obj[led_id - 1];
113109
}

0 commit comments

Comments
 (0)