123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #ifndef __BSP_ADC_H__
- #define __BSP_ADC_H__
- /*********************************************************************
- * INCLUDES
- */
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include "sdk_common.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- #include "nrf_gpio.h"
- #include "nrf_pwr_mgmt.h"
- #include "nrf_drv_saadc.h"
- /*********************************************************************
- * DEFINITIONS
- */
- //ERROR CODE
- #define ADC_OP_SUCCESS 0x00 //adc操作成功
- #define ADC_ERR_INIT_PIN 0x01 //该引脚已初始化
- #define ADC_ERR_INIT_CHANNEL 0x02 //该通道已初始化
- #define ADC_ERR_INIT_CONGESTION 0x03 //有效通道已全部初始化
- #define ADC_ERR_REMOVE_PIN_CHANNEL 0x04 //移除通道和引脚失败
- #define ADC_ERR_READ_NO_CHANNEL 0x05 //无配置通道,读取失败
- #define ADC_ERR_READ_TIMEOUT 0x06 //读取adc超时
- #define ADC_ERR_READ_FAIL 0x07 //读取adc失败
- /*********************************************************************
- * API
- */
-
- //初始化ADC引脚和通道
- uint32_t ADC_SetPinChannel(uint32_t pin, uint32_t channel,nrf_gpio_pin_pull_t pin_pull);
- //移除已初始化ADC引脚和通道
- uint32_t ADC_RemovePinChannel(uint32_t pin, uint32_t channel);
- //ADC初始化
- void ADC_Initialize(void);
- //ADC读取
- uint32_t ADC_Read(uint32_t channel, int16_t *p_adc_value);
- //开启ADC,与初始化没有区别,为了与Disable成对出现
- void ADC_Enable(void);
- //禁用ADC
- void ADC_Disable(void);
- #endif
|