Is there a simple software code example how to configure an interrupt handler for a single GPIO-pin? I am using nRF51822 chip with softdevice S110 and the interrupt source is connected to pin P0.24.
Is there a simple software code example how to configure an interrupt handler for a single GPIO-pin? I am using nRF51822 chip with softdevice S110 and the interrupt source is connected to pin P0.24.
Thanks, I checked the code. For me, it looks like it is using a timer to poll the pin. The code is as below (clipped). There is no hint about using interrupt, except the timer, or do I misunderstand?
// Configure pin.
nrf_gpio_cfg_input(p_btn->pin_no, p_btn->pull_cfg);
// Build GPIOTE user registration masks.
m_active_high_states_mask |= ((p_btn->active_high ? 1 : 0) << p_btn->pin_no);
m_active_low_states_mask |= ((p_btn->active_high ? 0 : 1) << p_btn->pin_no);
}
// Register button module as a GPIOTE user.
err_code = app_gpiote_user_register(&m_gpiote_user_id,
m_active_high_states_mask,
m_active_low_states_mask,
gpiote_event_handler);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Create polling timer.
return app_timer_create(&m_detection_delay_timer_id,
APP_TIMER_MODE_SINGLE_SHOT,
detection_delay_timeout_handler);
Thanks, I checked the code. For me, it looks like it is using a timer to poll the pin. The code is as below (clipped). There is no hint about using interrupt, except the timer, or do I misunderstand?
// Configure pin.
nrf_gpio_cfg_input(p_btn->pin_no, p_btn->pull_cfg);
// Build GPIOTE user registration masks.
m_active_high_states_mask |= ((p_btn->active_high ? 1 : 0) << p_btn->pin_no);
m_active_low_states_mask |= ((p_btn->active_high ? 0 : 1) << p_btn->pin_no);
}
// Register button module as a GPIOTE user.
err_code = app_gpiote_user_register(&m_gpiote_user_id,
m_active_high_states_mask,
m_active_low_states_mask,
gpiote_event_handler);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Create polling timer.
return app_timer_create(&m_detection_delay_timer_id,
APP_TIMER_MODE_SINGLE_SHOT,
detection_delay_timeout_handler);