Skip to content

Commit

Permalink
mimxrt/led: Fix LED init call from main, and simplify led_init.
Browse files Browse the repository at this point in the history
led_init() was not called, and therefore the machine.LED class seemed not
to work.  led_init() now uses mp_hal_pin_output() to configure the pin.

Signed-off-by: robert-hh <[email protected]>
  • Loading branch information
robert-hh authored and dpgeorge committed Oct 9, 2023
1 parent 3fb1bb1 commit a06f4c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
14 changes: 1 addition & 13 deletions ports/mimxrt/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,7 @@ void led_init(void) {
// Turn off LEDs and initialize
for (mp_int_t led = 0; led < NUM_LEDS; led++) {
const machine_pin_obj_t *led_pin = machine_led_obj[led].led_pin;

gpio_pin_config_t pin_config = {
.outputLogic = 1U,
.direction = kGPIO_DigitalOutput,
.interruptMode = kGPIO_NoIntmode,
};

GPIO_PinInit(led_pin->gpio, led_pin->pin, &pin_config);

// ALT mode for GPIO is always 5
IOMUXC_SetPinMux(led_pin->muxRegister, 5U, 0, 0, led_pin->configRegister,
1U); // Software Input On Field: Input Path is determined by functionality
IOMUXC_SetPinConfig(led_pin->muxRegister, 5U, 0, 0, led_pin->configRegister, 0x10B0U);
mp_hal_pin_output(led_pin);
MICROPY_HW_LED_OFF(led_pin);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ports/mimxrt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(void) {
#endif

for (;;) {
#if defined(MICROPY_HW_LED1)
#if defined(MICROPY_HW_LED1_PIN)
led_init();
#endif

Expand Down

0 comments on commit a06f4c8

Please sign in to comment.