1.在sdk_config.h中加入宏
// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver
//==========================================================
#ifndef GPIOTE_ENABLED
#define GPIOTE_ENABLED 1
#endif
// GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins
#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4
#endif
// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority
// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// 0 (highest)
// 1
// 2
// 3
// 4
// 5
// 6
// 7
#ifndef GPIOTE_CONFIG_IRQ_PRIORITY
#define GPIOTE_CONFIG_IRQ_PRIORITY 7
#endif
2.导入nrfx_gpiote.c到工程中
3.GPIOTE INPUT事件函数
void pin_event_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action){
printf("timer_dummy_handler\n");
}
4.初时化GPIOTE
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true); // HIGH TO LOW
config.pull = GPIO_PIN_CNF_PULL_Pullup; //pull up
err_code = nrf_drv_gpiote_in_init(16, &config, pin_event_handler);
nrf_drv_gpiote_in_event_enable(16, true); //true则使能执行pin_event_handler函数
