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 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.
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.
you can use still use Zephyr's gpio_pin_get() to get the state of the the output pin.
To be more precise: you read to level of the input at that pin. If the output is high, but the load pulls it too much down, you will read a low instead of the value high set to the output. Maybe in my case, the load is out of spec.
you can use still use Zephyr's gpio_pin_get() to get the state of the the output pin.
To be more precise: you read to level of the input at that pin. If the output is high, but the load pulls it too much down, you will read a low instead of the value high set to the output. Maybe in my case, the load is out of spec.