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

nrf52832 comp for sdk 15.2.0

仙剑情缘 发布时间:2018-10-31 15:41:18 ,浏览量:8

1.在sdk_config.h中加入宏

// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver
//==========================================================
#ifndef COMP_ENABLED
#define COMP_ENABLED 1
#endif
// COMP_CONFIG_REF  - Reference voltage
 
// Internal 1.2V 
// Internal 1.8V 
// Internal 2.4V 
// VDD 
// ARef 

#ifndef COMP_CONFIG_REF
#define COMP_CONFIG_REF 1
#endif

// COMP_CONFIG_MAIN_MODE  - Main mode
 
// Single ended 
// Differential 

#ifndef COMP_CONFIG_MAIN_MODE
#define COMP_CONFIG_MAIN_MODE 0
#endif

// COMP_CONFIG_SPEED_MODE  - Speed mode
 
// Low power 
// Normal 
// High speed 

#ifndef COMP_CONFIG_SPEED_MODE
#define COMP_CONFIG_SPEED_MODE 2
#endif

// COMP_CONFIG_HYST  - Hystheresis
 
// No 
// 50mV 

#ifndef COMP_CONFIG_HYST
#define COMP_CONFIG_HYST 0
#endif

// COMP_CONFIG_ISOURCE  - Current Source
 
// Off 
// 2.5 uA 
// 5 uA 
// 10 uA 

#ifndef COMP_CONFIG_ISOURCE
#define COMP_CONFIG_ISOURCE 0
#endif

// COMP_CONFIG_INPUT  - Analog input
 
// 0 
// 1 
// 2 
// 3 
// 4 
// 5 
// 6 
// 7 

#ifndef COMP_CONFIG_INPUT
#define COMP_CONFIG_INPUT 7
#endif

// COMP_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 COMP_CONFIG_IRQ_PRIORITY
#define COMP_CONFIG_IRQ_PRIORITY 7
#endif

2.导入nrfx_comp.c到工程

3.comp事件处理函数

#include "nrf_drv_comp.h"

void comp_event_handler(nrf_comp_event_t evt)
{
     printf("\r\ncomp_event_handler\r\n");
}

4.comp初时化使用
     uint32_t err_code;
      nrf_drv_comp_config_t comp_config = NRF_DRV_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_7);
       comp_config.isource = NRF_COMP_ISOURCE_Ien5uA;
      err_code = nrf_drv_comp_init(&comp_config, comp_event_handler);
      nrf_drv_comp_start(NRF_DRV_COMP_EVT_EN_CROSS_MASK ,NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT);
      
      

关注
打赏
查看更多评论

仙剑情缘

暂无认证

  • 8浏览

    0关注

    138博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

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

微信扫码登录