1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #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超时
- /*********************************************************************
- * API
- */
-
- //初始化ADC引脚和通道
- uint32_t ADC_SetPinChannel(uint32_t pin, uint32_t channel);
- //移除已初始化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
|