nRF52840 read GPIO state right after its wakeup from deep sleep

I am trying to read the GPIO state on an nRF52840 right after it wakes up from deep sleep (System OFF mode). I have configured 4 pins as wake-up sources from deep sleep System OFF mode. I tried using the latch register, but it does not work at all. Now I am trying to see if I can read the GPIO state as soon as the nRF52840 wakes up from deep sleep, but the pin states are always active low or 0 when I try to get the state of these pins, even if I press one of these buttons. However, if I press longer, like 2 seconds, then it works fine. Can anyone please help me fix this?

LOG_INF("button0 state: %d", gpio_pin_get_dt(&sw0));
LOG_INF("button1 state: %d", gpio_pin_get_dt(&sw1));
LOG_INF("button2 state: %d", gpio_pin_get_dt(&sw2));
LOG_INF("button3 state: %d", gpio_pin_get_dt(&sw3));
Related