Re: GPIO support on nRF52840 DK


Bolivar, Marti
 

"leonardomt via Lists.Zephyrproject.Org"
<leonardomt=gmail.com@lists.zephyrproject.org> writes:

This worked, although this pin in particular did not trigger the interrupt function but required calling gpio_pin_read(...) inside a loop to detect changes in its state.
Thanks for the fix and the walk-thru!
Sure thing!


What thought process or what resource/documentation makes one realize
that pin P1.0 belongs to port DT_ALIAS_GPIO_1_LABEL?

For example, I found that P1.0 (D1) belongs to port "gpio1" by looking at the gpio-map definition in nrf52840_pca10056.dts; as you suggested, generated_dts_board_unfixed.h lists that "GPIO_1" is assigned to DT_NORDIC_NRF_GPIO_50000300_LABEL and finally that DT_ALIAS_GPIO_1_LABEL = DT_NORDIC_NRF_GPIO_50000300_LABEL... but is this the only way to know what's where?
Port 1 is the GPIO controller; the .0 is a pin number it
controls. You want the device label for the controller -- as
you've seen, the pin number is a separate piece of data.

You can look at the DTS files to know what nodes are available:

https://github.com/zephyrproject-rtos/zephyr/blob/master/dts/arm/nordic/nrf52840.dtsi#L126

This dtsi (Device Tree Source Include) is included from the .dts
file for the board, which you can find by searching for its name
in boards/*/:

https://github.com/zephyrproject-rtos/zephyr/blob/master/boards/arm/nrf52840_pca10056/nrf52840_pca10056.dts

The nodes have the addresses of the hardware peripherals they
correspond to, so you can find the one you want by comparing your
chip memory map with the DT reg property. (But usually, they're
numbered according to the same peripheral numbering in the chip
reference manual, so P1 means you're looking for GPIO_1. And
similarly for other types of peripheral, like SPI_1, I2C_3, etc.)

Marti


Thanks

Join users@lists.zephyrproject.org to automatically receive all group messages.