GPIO pin value are read incorrectly from the .overlay file

I generated an overlay file with the following info:

// To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.

// You can also use the buttons in the sidebar to perform actions on nodes.
// Actions currently available include:

// * Enabling / disabling the node
// * Adding the bus to a bus
// * Removing the node
// * Connecting ADC channels

// For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html
// You can also visit the nRF DeviceTree extension documentation at https://docs.nordicsemi.com/bundle/nrf-connect-vscode/page/guides/ncs_configure_app.html#devicetree-support-in-the-extension

&gpio0 {
	status = "okay";
};

&gpiote {
	status = "okay";
};

/ {
	leds {
		compatible = "gpio-leds";
		yellow_led: led {
			label = "led";
			gpios = <&gpio0 6 0>;
		};
	};
};

and there is my main.c file:

// have some useful utility functions provided by zeyphr kernal.
#include <zephyr/kernel.h>

// include the GPIO driver
#include <zephyr/drivers/gpio.h>

// get the gpio pin properties from the .overlay file
static struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_NODELABEL(yellow_led), gpios);

int main(void)
{
        // check if the pin is ready to use (the function returns 0 if everything is ok)
        if(!gpio_is_ready_dt(&led))
        {
                // end the program
                return 0;
        }

        // check if the pin is configured successfully (the function returns 0 if everything is ok)
        if(gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE) < 0)
        {
                // end the program
                return 0;
        }

        // loop infinitely
        while(1)
        {
                // toggle the led and check if it was toggled successfully 
                if(gpio_pin_toggle_dt(&led) < 0)
                {
                        return 0;
                }

                // sleep for 1 second 
                k_msleep(1000);
        }

        return 0;
}

However, when I tried to debug my code to understand what was wrong, I got the following value of the led variable at the start of the main:

$1 = {port = 0x395f <notify_monitors+40>, pin = 0 '\000', dt_flags = 0}

which is incorrect because the pin value should be 6 not 0.

Parents Reply Children
No Data
Related