/****************************************************************************** * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved. * * This software component is licensed by XHSC under BSD 3-Clause license * (the "License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************/ /****************************************************************************** * @file adc.h * * @brief Header file for ADC functions * * @author MADS Team * ******************************************************************************/ #ifndef __ADC_H__ #define __ADC_H__ /******************************************************************************/ /* Include files */ /******************************************************************************/ #include "ddl.h" /* C binding of definitions if building with C++ compiler */ #ifdef __cplusplus extern "C" { #endif /** ****************************************************************************** ** \defgroup AdcGroup AD Converter (ADC) ** ******************************************************************************/ //@{ /****************************************************************************** * Global definitions ******************************************************************************/ #define ADC_SCAN_CH0_EN (0x1u) /*!< SCAN模式使用ADC CH0 */ #define ADC_SCAN_CH1_EN (0x1u<<1) /*!< SCAN模式使用ADC CH1 */ #define ADC_SCAN_CH2_EN (0x1u<<2) /*!< SCAN模式使用ADC CH2 */ #define ADC_SCAN_CH3_EN (0x1u<<3) /*!< SCAN模式使用ADC CH3 */ #define ADC_SCAN_CH4_EN (0x1u<<4) /*!< SCAN模式使用ADC CH4 */ #define ADC_SCAN_CH5_EN (0x1u<<5) /*!< SCAN模式使用ADC CH5 */ #define ADC_SCAN_CH6_EN (0x1u<<6) /*!< SCAN模式使用ADC CH6 */ #define ADC_SCAN_CH7_EN (0x1u<<7) /*!< SCAN模式使用ADC CH7 */ /****************************************************************************** ** Global type definitions *****************************************************************************/ /** ****************************************************************************** ** \brief ADC转换模式 *****************************************************************************/ typedef enum en_adc_mode { AdcSglMode = 0u, /*!< 单输入通道单次转换模式 */ AdcScanMode = 1u, /*!< 多输入通道顺序/插队扫描转换模式*/ }en_adc_mode_t; /** ****************************************************************************** ** \brief ADC时钟分频选择 *****************************************************************************/ typedef enum en_adc_clk_sel { AdcMskClkDiv1 = 0u<<2, /*!< PCLK */ AdcMskClkDiv2 = 1u<<2, /*!< 1/2 PCLK */ AdcMskClkDiv4 = 2u<<2, /*!< 1/4 PCLK */ AdcMskClkDiv8 = 3u<<2, /*!< 1/8 PCLK */ } en_adc_clk_div_t; /** ****************************************************************************** ** \brief ADC参考电压 *****************************************************************************/ typedef enum en_adc_ref_vol_sel { AdcMskRefVolSelInBgr1p5 = 0u<<9, /*!<内部参考电压1.5V(SPS<=200kHz)*/ AdcMskRefVolSelInBgr2p5 = 1u<<9, /*!<内部参考电压2.5V(avdd>3V,SPS<=200kHz)*/ AdcMskRefVolSelExtern1 = 2u<<9, /*!<外部输入(max avdd) PB01*/ AdcMskRefVolSelAVDD = 3u<<9, /*!