Hi!
Any way in Zephyr to read the current value of a GPIO pin that is configured as OUTPUT?
Thanks!
Pedro.
Hi!
Any way in Zephyr to read the current value of a GPIO pin that is configured as OUTPUT?
Thanks!
Pedro.
Hi,
You can use nrf_gpio_pin_out_read() to read the state of an output pin in the OUT register.
Hi Einar,
I'm using NCS v2.0.2, with Zephyr, so I use gpio_pin_get()
. The problem is when GPIO is configured as output, I can not use this function to read its current value.
How can I do this?
Thanks and kind regards,
Pedro.
Hi Pedro,
You are right, gpio_pin_get()
can only be used to read an input pin. That is why I suggested that you use nrf_gpio_pin_out_read()
, which is for reading the state of an output pin
Hi Pedro,
You are right, gpio_pin_get()
can only be used to read an input pin. That is why I suggested that you use nrf_gpio_pin_out_read()
, which is for reading the state of an output pin
But, how can I use nrf_gpio_pin_out_read()
with NCS v2.0.2, with Zephyr? Isn't it a function of the old Nordic SDK?
It is a low-level function from nrfx that is available regardless of which SDK you are using. It exist in NCS v2.0.2, and also in the latest v2.4.2.
Ah, I see.
I've found this function in C:\ncs\v2.0.2\modules\hal\nordic\nrfx\hal\nrf_gpio.h
But, how can I include it in my project?
If I try #include <modules/hal/nordic/nrfx/hal/nrf_gpio.h>
it does not find the file.
I do not understand the include paths when using NCS. They do not correspond exactly with file system folder structure.
Thanks again!
Pedro.
Hi Pedro,
You should include it like this:
#include <hal/nrf_gpio.h>
Thanks Einar!
How can I find in the future the include path for other .h files? They do not correspond with the system folder structure.