I'm porting my system from 1.2.0 SDK to 1.4.2. The GPIO API has changed quite a bit. I have this problem that when I'm enabling some GPIO to be on interrupts, it seems to break my gpio_pin_read_raw results. When I initialize this interrupt gpios I make this call;
int WakeupInit(wakeup_handler_t wakeup_handler)
{
int err;
uint32_t wakeup_val;
wakeup_handler_cb = wakeup_handler;
gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0)));
if (!gpio_dev) {
printk("Cannot bind gpio device\n");
return -ENODEV;
}
err = configure_sources();
if (err) {
printk("Cannot configure wakeup sources\n");
return err;
}
for (size_t i = 0; i < ARRAY_SIZE(wakeup_pins); i++)
{
gpio_pin_interrupt_configure(gpio_dev,i, GPIO_INT_DISABLE );
}
k_delayed_work_init(&wakeup_scan, wakeup_scan_fn);
wakeup_val = get_wakeup_status();
atomic_set(&wakeup_state, (atomic_val_t)wakeup_val);
uint32_t pin_mask = 0;
for (size_t i = 0; i < ARRAY_SIZE(wakeup_pins); i++) {
pin_mask |= BIT(wakeup_pins[i]);
}
gpio_init_callback(&gpio_cb, wakeup_detected, pin_mask);
err = gpio_add_callback(gpio_dev, &gpio_cb);
if (err) {
printk("Cannot add callback\n");
return err;
}
for (size_t i = 0; i < ARRAY_SIZE(wakeup_pins); i++)
{
gpio_pin_interrupt_configure(gpio_dev,i, GPIO_INT_EDGE_BOTH );
}
return 0;
}
I used the dk_leds and button routines as an example of how to set it up. I've chopped out pieces of code and everything works fine unit the final loop where I enable the interrupts to both edges. But even replacing it with single edge breaks the GPIO reads. I was hoping someone might have some insight.
Thanks,