1.在sdk_config.h中加入宏
// <e> GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver
//==========================================================
#ifndef GPIOTE_ENABLED
#define GPIOTE_ENABLED 1
#endif
// <o> 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
// <o> GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority
// <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// <0=> 0 (highest)
// <1=> 1
// <2=> 2
// <3=> 3
// <4=> 4
// <5=> 5
// <6=> 6
// <7=> 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函数