I am trying to set up a button interrupt by adding the following functions:
void button_interrupt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
nrf_gpio_pin_toggle(LED_4);
}
void button4_config()
{
nrf_drv_gpiote_in_config_t config;
memset(&config, 0, sizeof(nrf_drv_gpiote_in_config_t));
config.sense = NRF_GPIOTE_POLARITY_HITOLO;
config.pull = NRF_GPIO_PIN_NOPULL;
config.hi_accuracy = false;
config.is_watcher = false;
nrf_drv_gpiote_in_init(BUTTON_4, &config, button_interrupt_handler);
nrf_drv_gpiote_in_event_enable(BUTTON_4, true);
}
int main(void)
{
// ...
button4_config();
// ...
}
When I tried to press the button, my interrupt is never called. Not even once.
Thinking that maybe the problem is because I was using BUTTON_4
, I have also tried to replace it with pin 29
and use an external button. That doesn't work either.
What could I be missing?