I was under the impression that when the voltage was 0 in a GPIO pin, reading from that pin would return 0, and if there was any voltage going through the pin it would read 1. I thought the readings would be instant.
However, when reading from the pin there is somewhat peculiar behavior. With no input, the reading is 1 whether I try using gpio_input_raw, or gpio_input_read.
If I put a single wire into the GPIO pin in question, and I touch that wire the GPIO reading goes to 0 for about 16 seconds and then returns to 1.
When the GPIO pin is reading 1, and I connect the GPIO pin to a battery circuit then the reading goes back to 1. If I disconnect the battery circuit, the GPIO reading stays at 1 indefinitely.
Here are some code snippets. I am reading from pin 22
gpio_pin_configure(gpio_dev, 22, GPIO_INPUT);
while (true) {
int pin_val = gpio_pin_get_raw(gpio_dev, 22);
k_sleep(K_SECONDS(.1));
}