/****************************************************************************** * Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. * * This software is owned and published by: * Huada Semiconductor Co.,Ltd ("HDSC"). * * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. * * This software contains source code for use with HDSC * components. This software is licensed by HDSC to be adapted only * for use in systems utilizing HDSC components. HDSC shall not be * responsible for misuse or illegal use of this software for devices not * supported herein. HDSC is providing this software "AS IS" and will * not be responsible for issues arising from incorrect user implementation * of the software. * * Disclaimer: * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED * WARRANTY OF NONINFRINGEMENT. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, * SAVINGS OR PROFITS, * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED * FROM, THE SOFTWARE. * * This software may be replicated in part or whole for the licensed use, * with the restriction that this Disclaimer and Copyright notice must be * included with each copy of this software, whether used in part or whole, * at all times. */ /******************************************************************************/ /** \file adc.h ** ** Header file for AD Converter functions ** @link ADC Group Some description @endlink ** ** - 2017-06-28 Alex First Version ** ******************************************************************************/ #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, /*!