This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr, nrf5340 and pin number

Hi,

I am using the nrfx GPIOTE driver to manage the output, input and interrupt on a nRF5340 on top of Zephyr Framework.

I know I can use the GPIO Api from Zephyr, but this is not my case.

I would like to retrieve the absolute pin numbers starting from the device tree definition and provide them to the functions of GPIOTE driver.

In order to do that i need to retrieve also the port number.

As far i can see the port number is contained in the data structure gpio_nrfx_cfg pointed by member void* config of the structure  gpio_dt_spec.port.

The data type gpio_nrfx_cfg  is defined in gpio_nrfx.c, so not publicly exposed.

Is there a more elegant way to retrieve the absolute pin number (port number * 32 + pin number) starting from the device tree definition ?

Thanks in advance!

Kind regards

Riccardo

Parents Reply
  • Hi Jørgen,

    i just tried to run quickly an example project where the led0 is configured in the device tree in this way:

    leds {
            compatible = "gpio-leds";
            led0: led_0 {
                gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
                label = "Green LED 0";
            };
     
    So the absolute pin number is 32 + 7 = 39
    The macro
    #define INPUT_PIN  DT_GPIO_PIN(DT_ALIAS(led0), gpios)
    has a value of 7 instead. So the port number is not considered.
Children
No Data
Related