您当前的位置: 首页 >  仙剑情缘

NRF52832 GPIOTE INPUT

仙剑情缘 发布时间:2018-10-31 17:04:37 ,浏览量:5

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函数

关注
打赏
查看更多评论

仙剑情缘

暂无认证

  • 5浏览

    0关注

    138博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录