summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarturo182 <arturo182@tlen.pl>2018-02-03 13:45:18 +0100
committerarturo182 <arturo182@tlen.pl>2018-02-03 13:51:11 +0100
commita64b5c84de9782624dc1f91324b0fa7bcef3c3d7 (patch)
treea925792a30a5191b0359e05dcb3825d748b4e36d
parent7c6adaa661aa066aca27457b966f5168189186c5 (diff)
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.
-rw-r--r--ports/nrf/modules/machine/led.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ports/nrf/modules/machine/led.c b/ports/nrf/modules/machine/led.c
index 3eec949e9..423c70bb8 100644
--- a/ports/nrf/modules/machine/led.c
+++ b/ports/nrf/modules/machine/led.c
@@ -63,13 +63,6 @@ STATIC const pyb_led_obj_t pyb_led_obj[] = {
#define NUM_LEDS MP_ARRAY_SIZE(pyb_led_obj)
-void led_init(void) {
- for (uint8_t i = 0; i < NUM_LEDS; i++) {
- LED_OFF(pyb_led_obj[i].hw_pin);
- hal_gpio_cfg_pin(0, pyb_led_obj[i].hw_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
- }
-}
-
void led_state(pyb_led_obj_t * led_obj, int state) {
if (state == 1) {
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_
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "LED(%d) does not exist", led_id));
}
+ hal_gpio_cfg_pin(0, pyb_led_obj[led_id - 1].hw_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
+ LED_OFF(pyb_led_obj[led_id - 1].hw_pin);
+
// return static led object
return (mp_obj_t)&pyb_led_obj[led_id - 1];
}