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.
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.
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.
Pedro,
Actually, you can use still use Zephyr's gpio_pin_get() to get the state of the the output pin.
The trick is to configure the pin as both an output and input in Zephyr, like this:
gpio_pin_configure_dt(&led1, GPIO_OUTPUT_INACTIVE | GPIO_INPUT);
and now gpio_pin_get() will work.
Thank you Joe! This also works.
Anyway, I'm curious about knowing how to know the include path for any .h file, which does not corresponds with the system folder structure. Somebody knows?
Regards,
Pedro.