This is almost certainly a noob (to nRF52840) programming question.
I have modified the peripheral/gpiote example to invoke an ISR on the falling edge of a pin signal. In the ISR I toggle another pin.
On a scope I see about 22 microseconds between the signal fall and the toggle.
My approach is similar to nrf52-gpiote-interrupt-latency, but there the latency reported is 1.6 us, which would make me happy.
#define GPIO_INPUT_INTR_PIN_NUMBER NRF_GPIO_PIN_MAP(1,12)
#define GPIO_OUTPUT_IRQ_RESPONSE_PIN_NUMBER NRF_GPIO_PIN_MAP(1,13)
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
nrf_drv_gpiote_out_toggle(GPIO_OUTPUT_IRQ_RESPONSE_PIN_NUMBER);
}
/**
* @brief Function for application main entry.
*/
int main(void)
{
ret_code_t err_code;
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
// set up the pin that is toggled by the IRQ
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(true);
err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_IRQ_RESPONSE_PIN_NUMBER, &out_config);
APP_ERROR_CHECK(err_code);
// set up the pin that detects the signal change
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
in_config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(GPIO_INPUT_INTR_PIN_NUMBER, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);
// enable the interrupt detection
nrf_drv_gpiote_in_event_enable(GPIO_INPUT_INTR_PIN_NUMBER, true);
bsp_board_init(BSP_INIT_LEDS);
while (true)
{
bsp_board_led_invert(0);
nrf_delay_ms(100);
}
}