Hi all ,
I had my code working on nRF connect 1.6.0 and now had to upgrade it to work with nRF connect 2.1.2.
I read the migration guide for nRF connect 1.x.x to 2.x.x but still can't fully understand how to port my working code on nRF connect 1.6.0 that controlled the LEDs to nRF connect 2.1.2
Here is the nRF connect 1.6.0:
void init_leds(void)
{
/* GPIOs: p0.02 == RED */
red_gpio = DT_GPIO_PIN(DT_ALIAS(LED_RED_LABEL), gpios);
/* GPIOs: p0.03 == BLUE */
blue_gpio= DT_GPIO_PIN(DT_ALIAS(LED_BLUE_LABEL), gpios);
dev_red = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(LED_RED_LABEL), gpios));
NULL_ERROR_CHECK_RETURN_VOID(dev_red);
dev_blue = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(LED_BLUE_LABEL), gpios));
NULL_ERROR_CHECK_RETURN_VOID(dev_blue);
gpio_pin_configure(dev_red, red_gpio, GPIO_OUTPUT_ACTIVE | DT_GPIO_FLAGS(DT_ALIAS(LED_RED_LABEL), gpios));
gpio_pin_configure(dev_blue, blue_gpio, GPIO_OUTPUT_ACTIVE | DT_GPIO_FLAGS(DT_ALIAS(LED_BLUE_LABEL), gpios));
}
void led_control(int led, int cmd)
{
switch (led)
{
case LED_RED:
gpio_pin_set(dev_red, red_gpio, cmd);
break;
case LED_BLUE:
gpio_pin_set(dev_blue, blue_gpio, cmd);
break;
default:
LOG_WRN("GPIO %d is not connected to any LED",led);
break;
}
}