I am trying to read from a GPIO configured as input and the value returned from gpio_pin_get_raw() is always 0. I have verified the voltage into the pin is 3.3v. Here is the code
#include <zephyr/kernel.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <zephyr/device.h> #include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> #define GPIO0_NODE DT_NODELABEL(gpio0) #define ROGUE_IRQ_PIN 10 const struct device *gpio0_dev; void main(void) { gpio0_dev = DEVICE_DT_GET(GPIO0_NODE); gpio_pin_configure(gpio0_dev, ROGUE_IRQ_PIN, GPIO_INPUT); printk("irq=%d\n", gpio_pin_get_raw(gpio0_dev, ROGUE_IRQ_PIN)); }
I'm using ncs v2.4.2
This seems very simple. Am I missing something in my configuration? I have CONFIG_GPIO=y in my prt.conf. Do I need something in my device tree overlay?