#ifndef HC32L1XX_LL_ADC_H_
#define HC32L1XX_LL_ADC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hc32l1xx.h"
#include "hc32l1xx_ll_bus.h"
#include "hc32l1xx_ll_bgr.h"
///
#define LL_ADC_CHANNEL_0 ADC_CR0_CH_AIN0
#define LL_ADC_CHANNEL_1 ADC_CR0_CH_AIN1
#define LL_ADC_CHANNEL_2 ADC_CR0_CH_AIN2
#define LL_ADC_CHANNEL_3 ADC_CR0_CH_AIN3
#define LL_ADC_CHANNEL_4 ADC_CR0_CH_AIN4
#define LL_ADC_CHANNEL_5 ADC_CR0_CH_AIN5
#define LL_ADC_CHANNEL_6 ADC_CR0_CH_AIN6
#define LL_ADC_CHANNEL_7 ADC_CR0_CH_AIN7
#define LL_ADC_CHANNEL_8 ADC_CR0_CH_AIN8
#define LL_ADC_CHANNEL_9 ADC_CR0_CH_AIN9
#define LL_ADC_CHANNEL_10 ADC_CR0_CH_AIN10
#define LL_ADC_CHANNEL_11 ADC_CR0_CH_AIN11
#define LL_ADC_CHANNEL_12 ADC_CR0_CH_AIN12
#define LL_ADC_CHANNEL_13 ADC_CR0_CH_AIN13
#define LL_ADC_CHANNEL_14 ADC_CR0_CH_AIN14
#define LL_ADC_CHANNEL_15 ADC_CR0_CH_AIN15
#define LL_ADC_CHANNEL_16 ADC_CR0_CH_AIN16
#define LL_ADC_CHANNEL_17 ADC_CR0_CH_AIN17
#define LL_ADC_CHANNEL_18 ADC_CR0_CH_AIN18
#define LL_ADC_CHANNEL_19 ADC_CR0_CH_AIN19
#define LL_ADC_CHANNEL_20 ADC_CR0_CH_AIN20
#define LL_ADC_CHANNEL_21 ADC_CR0_CH_AIN21
#define LL_ADC_CHANNEL_22 ADC_CR0_CH_AIN22
#define LL_ADC_CHANNEL_23 ADC_CR0_CH_AIN23
#define LL_ADC_CHANNEL_24 ADC_CR0_CH_AIN24
#define LL_ADC_CHANNEL_25 ADC_CR0_CH_AIN25
#define LL_ADC_CHANNEL_26 ADC_CR0_CH_DAC
#define LL_ADC_CHANNEL_27 ADC_CR0_CH_AVCC_P3
#define LL_ADC_CHANNEL_28 ADC_CR0_CH_TEMP
#define LL_ADC_CHANNEL_29 ADC_CR0_CH_IN1P2
#define LL_ADC_TH_CHANNEL_0 ADC_CR1_TH_CH_AIN0
#define LL_ADC_TH_CHANNEL_1 ADC_CR1_TH_CH_AIN1
#define LL_ADC_TH_CHANNEL_2 ADC_CR1_TH_CH_AIN2
#define LL_ADC_TH_CHANNEL_3 ADC_CR1_TH_CH_AIN3
#define LL_ADC_TH_CHANNEL_4 ADC_CR1_TH_CH_AIN4
#define LL_ADC_TH_CHANNEL_5 ADC_CR1_TH_CH_AIN5
#define LL_ADC_TH_CHANNEL_6 ADC_CR1_TH_CH_AIN6
#define LL_ADC_TH_CHANNEL_7 ADC_CR1_TH_CH_AIN7
#define LL_ADC_TH_CHANNEL_8 ADC_CR1_TH_CH_AIN8
#define LL_ADC_TH_CHANNEL_9 ADC_CR1_TH_CH_AIN9
#define LL_ADC_TH_CHANNEL_10 ADC_CR1_TH_CH_AIN10
#define LL_ADC_TH_CHANNEL_11 ADC_CR1_TH_CH_AIN11
#define LL_ADC_TH_CHANNEL_12 ADC_CR1_TH_CH_AIN12
#define LL_ADC_TH_CHANNEL_13 ADC_CR1_TH_CH_AIN13
#define LL_ADC_TH_CHANNEL_14 ADC_CR1_TH_CH_AIN14
#define LL_ADC_TH_CHANNEL_15 ADC_CR1_TH_CH_AIN15
#define LL_ADC_TH_CHANNEL_16 ADC_CR1_TH_CH_AIN16
#define LL_ADC_TH_CHANNEL_17 ADC_CR1_TH_CH_AIN17
#define LL_ADC_TH_CHANNEL_18 ADC_CR1_TH_CH_AIN18
#define LL_ADC_TH_CHANNEL_19 ADC_CR1_TH_CH_AIN19
#define LL_ADC_TH_CHANNEL_20 ADC_CR1_TH_CH_AIN20
#define LL_ADC_TH_CHANNEL_21 ADC_CR1_TH_CH_AIN21
#define LL_ADC_TH_CHANNEL_22 ADC_CR1_TH_CH_AIN22
#define LL_ADC_TH_CHANNEL_23 ADC_CR1_TH_CH_AIN23
#define LL_ADC_TH_CHANNEL_24 ADC_CR1_TH_CH_AIN24
#define LL_ADC_TH_CHANNEL_25 ADC_CR1_TH_CH_AIN25
#define LL_ADC_TH_CHANNEL_26 ADC_CR1_TH_CH_AIN26
#define LL_ADC_TH_CHANNEL_27 ADC_CR1_TH_CH_AIN27
#define LL_ADC_TH_CHANNEL_28 ADC_CR1_TH_CH_AIN28
#define LL_ADC_TH_CHANNEL_29 ADC_CR1_TH_CH_AIN29
#define LL_ADC_SQR_SCAN_DISABLE (0x00UL<
#define LL_ADC_SQR_SCAN_ENABLE_1RANKS (0x00UL<
#define LL_ADC_SQR_SCAN_ENABLE_2RANKS (0x01UL<
#define LL_ADC_SQR_SCAN_ENABLE_3RANKS (0x02UL<
#define LL_ADC_SQR_SCAN_ENABLE_4RANKS (0x03UL<
#define LL_ADC_SQR_SCAN_ENABLE_5RANKS (0x04UL<
#define LL_ADC_SQR_SCAN_ENABLE_6RANKS (0x05UL<
#define LL_ADC_SQR_SCAN_ENABLE_7RANKS (0x06UL<
#define LL_ADC_SQR_SCAN_ENABLE_8RANKS (0x07UL<
#define LL_ADC_SQR_SCAN_ENABLE_9RANKS (0x08UL<
#define LL_ADC_SQR_SCAN_ENABLE_10RANKS (0x08UL<
#define LL_ADC_SQR_SCAN_ENABLE_11RANKS (0x0AUL<
#define LL_ADC_SQR_SCAN_ENABLE_12RANKS (0x0BUL<
#define LL_ADC_SQR_SCAN_ENABLE_13RANKS (0x0CUL<
#define LL_ADC_SQR_SCAN_ENABLE_14RANKS (0x0DUL<
#define LL_ADC_SQR_SCAN_ENABLE_15RANKS (0x0EUL<
#define LL_ADC_SQR_SCAN_ENABLE_16RANKS (0x0FUL<
#define LL_ADC_SQR_RANK_0 0UL
#define LL_ADC_SQR_RANK_1 1UL
#define LL_ADC_SQR_RANK_2 2UL
#define LL_ADC_SQR_RANK_3 3UL
#define LL_ADC_SQR_RANK_4 4UL
#define LL_ADC_SQR_RANK_5 5UL
#define LL_ADC_SQR_RANK_6 6UL
#define LL_ADC_SQR_RANK_7 7UL
#define LL_ADC_SQR_RANK_8 8UL
#define LL_ADC_SQR_RANK_9 9UL
#define LL_ADC_SQR_RANK_10 10UL
#define LL_ADC_SQR_RANK_11 11UL
#define LL_ADC_SQR_RANK_12 12UL
#define LL_ADC_SQR_RANK_13 13UL
#define LL_ADC_SQR_RANK_14 14UL
#define LL_ADC_SQR_RANK_15 15UL
#define LL_ADC_JQR_SCAN_DISABLE (0x00UL<
#define LL_ADC_JQR_SCAN_ENABLE_1RANKS (0x00UL<
#define LL_ADC_JQR_SCAN_ENABLE_2RANKS (0x01UL<
#define LL_ADC_JQR_SCAN_ENABLE_3RANKS (0x02UL<
#define LL_ADC_JQR_SCAN_ENABLE_4RANKS (0x03UL<
#define LL_ADC_JQR_RANK_0 0
#define LL_ADC_JQR_RANK_1 1
#define LL_ADC_JQR_RANK_2 2
#define LL_ADC_JQR_RANK_3 3
#define LL_ADC_DATA_ALIGN_RIGHT 0x00000000UL
#define LL_ADC_DATA_ALIGN_LEFT ADC_CR1_ALIGN
#define LL_ADC_SAMPLINGTIME_4CYCLE ADC_CR0_SAM_CYCLE_4
#define LL_ADC_SAMPLINGTIME_6CYCLES ADC_CR0_SAM_CYCLE_6
#define LL_ADC_SAMPLINGTIME_8CYCLES ADC_CR0_SAM_CYCLE_8
#define LL_ADC_SAMPLINGTIME_12CYCLES ADC_CR0_SAM_CYCLE_12
#define LL_ADC_CLK_DIV_1 ADC_CR0_CLK_DIV1
#define LL_ADC_CLK_DIV_2 ADC_CR0_CLK_DIV2
#define LL_ADC_CLK_DIV_4 ADC_CR0_CLK_DIV4
#define LL_ADC_CLK_DIV_8 ADC_CR0_CLK_DIV8
#define LL_ADC_CONV_SINGLE 0x00000000UL
#define LL_ADC_CONV_CONTINUOUS (ADC_CR1_MODE)
#define LL_ADC_SQR_DMA_DISABLE 0x00000000UL
#define LL_ADC_SQR_DMA_ENABLE (ADC_CR1_DMA_SQR)
#define LL_ADC_JQR_DMA_DISABLE 0x00000000UL
#define LL_ADC_JQR_DMA_ENABLE (ADC_CR1_DMA_JQR)
#define LL_ADC_REF_SELECTED_IN1P5 ADC_CR0_REF_IN1P5
#define LL_ADC_REF_SELECTED_IN2P5 ADC_CR0_REF_IN2P5
#define LL_ADC_REF_SELECTED_EXREF ADC_CR0_REF_EXREF
#define LL_ADC_REF_SELECTED_AVCC ADC_CR0_REF_AVCC
#define LL_ADC_INREF_ENABLE ADC_CR0_INREF
#define LL_ADC_INREF_DISABLE 0x00000000UL
///
//函 数:
//功 能: 数据对齐
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
{
MODIFY_REG(ADCx->CR1, ADC_CR1_ALIGN, DataAlignment);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_ALIGN));
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable(ADC_TypeDef *ADCx)
{
//---检查BGR是否开启
if (LL_BGR_IsEnable(BGR) == 0)
{
if (LL_PER0_GRP1_IsEnabled_Clock(LL_PER0_GRP1_PERIPH_BGR) == 0)
{
LL_PER0_GRP1_Enable_Clock(LL_PER0_GRP1_PERIPH_BGR);
}
LL_BGR_Enable(BGR);
}
SET_BIT(ADCx->CR0, ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_EN) == ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_EnableIT(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_IE);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_DisableIT(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_IE);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabledIT(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_IE) == ADC_CR0_IE);
}
///
//函 数:
//功 能: 使能能不参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable_InRef(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_INREF);
}
///
//函 数:
//功 能: 不能使能内部参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable_InRef(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_INREF);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabled_InRef(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_INREF) == ADC_CR0_INREF);
}
///
//函 数:
//功 能: 使能能不参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetInRefEN(ADC_TypeDef *ADCx,uint32_t en)
{
MODIFY_REG(ADCx->CR0, ADC_CR0_INREF,en);
}
///
//函 数:
//功 能: 采样时间
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetSamplingTime(ADC_TypeDef *ADCx, uint32_t SamplingTime)
{
MODIFY_REG(ADCx->CR0, ADC_CR0_SAM, SamplingTime);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_GetSamplingTime(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_SAM));
}
///
//函 数:
//功 能: 使能跟谁器
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable_Buffer(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_BUFFER);
}
///
//函 数:
//功 能: 不使能跟谁器
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable_Buffer(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_BUFFER);
}
#ifndef HC32L1XX_LL_ADC_H_
#define HC32L1XX_LL_ADC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "hc32l1xx.h"
#include "hc32l1xx_ll_bus.h"
#include "hc32l1xx_ll_bgr.h"
///
#define LL_ADC_CHANNEL_0 ADC_CR0_CH_AIN0
#define LL_ADC_CHANNEL_1 ADC_CR0_CH_AIN1
#define LL_ADC_CHANNEL_2 ADC_CR0_CH_AIN2
#define LL_ADC_CHANNEL_3 ADC_CR0_CH_AIN3
#define LL_ADC_CHANNEL_4 ADC_CR0_CH_AIN4
#define LL_ADC_CHANNEL_5 ADC_CR0_CH_AIN5
#define LL_ADC_CHANNEL_6 ADC_CR0_CH_AIN6
#define LL_ADC_CHANNEL_7 ADC_CR0_CH_AIN7
#define LL_ADC_CHANNEL_8 ADC_CR0_CH_AIN8
#define LL_ADC_CHANNEL_9 ADC_CR0_CH_AIN9
#define LL_ADC_CHANNEL_10 ADC_CR0_CH_AIN10
#define LL_ADC_CHANNEL_11 ADC_CR0_CH_AIN11
#define LL_ADC_CHANNEL_12 ADC_CR0_CH_AIN12
#define LL_ADC_CHANNEL_13 ADC_CR0_CH_AIN13
#define LL_ADC_CHANNEL_14 ADC_CR0_CH_AIN14
#define LL_ADC_CHANNEL_15 ADC_CR0_CH_AIN15
#define LL_ADC_CHANNEL_16 ADC_CR0_CH_AIN16
#define LL_ADC_CHANNEL_17 ADC_CR0_CH_AIN17
#define LL_ADC_CHANNEL_18 ADC_CR0_CH_AIN18
#define LL_ADC_CHANNEL_19 ADC_CR0_CH_AIN19
#define LL_ADC_CHANNEL_20 ADC_CR0_CH_AIN20
#define LL_ADC_CHANNEL_21 ADC_CR0_CH_AIN21
#define LL_ADC_CHANNEL_22 ADC_CR0_CH_AIN22
#define LL_ADC_CHANNEL_23 ADC_CR0_CH_AIN23
#define LL_ADC_CHANNEL_24 ADC_CR0_CH_AIN24
#define LL_ADC_CHANNEL_25 ADC_CR0_CH_AIN25
#define LL_ADC_CHANNEL_26 ADC_CR0_CH_DAC
#define LL_ADC_CHANNEL_27 ADC_CR0_CH_AVCC_P3
#define LL_ADC_CHANNEL_28 ADC_CR0_CH_TEMP
#define LL_ADC_CHANNEL_29 ADC_CR0_CH_IN1P2
#define LL_ADC_TH_CHANNEL_0 ADC_CR1_TH_CH_AIN0
#define LL_ADC_TH_CHANNEL_1 ADC_CR1_TH_CH_AIN1
#define LL_ADC_TH_CHANNEL_2 ADC_CR1_TH_CH_AIN2
#define LL_ADC_TH_CHANNEL_3 ADC_CR1_TH_CH_AIN3
#define LL_ADC_TH_CHANNEL_4 ADC_CR1_TH_CH_AIN4
#define LL_ADC_TH_CHANNEL_5 ADC_CR1_TH_CH_AIN5
#define LL_ADC_TH_CHANNEL_6 ADC_CR1_TH_CH_AIN6
#define LL_ADC_TH_CHANNEL_7 ADC_CR1_TH_CH_AIN7
#define LL_ADC_TH_CHANNEL_8 ADC_CR1_TH_CH_AIN8
#define LL_ADC_TH_CHANNEL_9 ADC_CR1_TH_CH_AIN9
#define LL_ADC_TH_CHANNEL_10 ADC_CR1_TH_CH_AIN10
#define LL_ADC_TH_CHANNEL_11 ADC_CR1_TH_CH_AIN11
#define LL_ADC_TH_CHANNEL_12 ADC_CR1_TH_CH_AIN12
#define LL_ADC_TH_CHANNEL_13 ADC_CR1_TH_CH_AIN13
#define LL_ADC_TH_CHANNEL_14 ADC_CR1_TH_CH_AIN14
#define LL_ADC_TH_CHANNEL_15 ADC_CR1_TH_CH_AIN15
#define LL_ADC_TH_CHANNEL_16 ADC_CR1_TH_CH_AIN16
#define LL_ADC_TH_CHANNEL_17 ADC_CR1_TH_CH_AIN17
#define LL_ADC_TH_CHANNEL_18 ADC_CR1_TH_CH_AIN18
#define LL_ADC_TH_CHANNEL_19 ADC_CR1_TH_CH_AIN19
#define LL_ADC_TH_CHANNEL_20 ADC_CR1_TH_CH_AIN20
#define LL_ADC_TH_CHANNEL_21 ADC_CR1_TH_CH_AIN21
#define LL_ADC_TH_CHANNEL_22 ADC_CR1_TH_CH_AIN22
#define LL_ADC_TH_CHANNEL_23 ADC_CR1_TH_CH_AIN23
#define LL_ADC_TH_CHANNEL_24 ADC_CR1_TH_CH_AIN24
#define LL_ADC_TH_CHANNEL_25 ADC_CR1_TH_CH_AIN25
#define LL_ADC_TH_CHANNEL_26 ADC_CR1_TH_CH_AIN26
#define LL_ADC_TH_CHANNEL_27 ADC_CR1_TH_CH_AIN27
#define LL_ADC_TH_CHANNEL_28 ADC_CR1_TH_CH_AIN28
#define LL_ADC_TH_CHANNEL_29 ADC_CR1_TH_CH_AIN29
#define LL_ADC_SQR_SCAN_DISABLE (0x00UL<
#define LL_ADC_SQR_SCAN_ENABLE_1RANKS (0x00UL<
#define LL_ADC_SQR_SCAN_ENABLE_2RANKS (0x01UL<
#define LL_ADC_SQR_SCAN_ENABLE_3RANKS (0x02UL<
#define LL_ADC_SQR_SCAN_ENABLE_4RANKS (0x03UL<
#define LL_ADC_SQR_SCAN_ENABLE_5RANKS (0x04UL<
#define LL_ADC_SQR_SCAN_ENABLE_6RANKS (0x05UL<
#define LL_ADC_SQR_SCAN_ENABLE_7RANKS (0x06UL<
#define LL_ADC_SQR_SCAN_ENABLE_8RANKS (0x07UL<
#define LL_ADC_SQR_SCAN_ENABLE_9RANKS (0x08UL<
#define LL_ADC_SQR_SCAN_ENABLE_10RANKS (0x08UL<
#define LL_ADC_SQR_SCAN_ENABLE_11RANKS (0x0AUL<
#define LL_ADC_SQR_SCAN_ENABLE_12RANKS (0x0BUL<
#define LL_ADC_SQR_SCAN_ENABLE_13RANKS (0x0CUL<
#define LL_ADC_SQR_SCAN_ENABLE_14RANKS (0x0DUL<
#define LL_ADC_SQR_SCAN_ENABLE_15RANKS (0x0EUL<
#define LL_ADC_SQR_SCAN_ENABLE_16RANKS (0x0FUL<
#define LL_ADC_SQR_RANK_0 0UL
#define LL_ADC_SQR_RANK_1 1UL
#define LL_ADC_SQR_RANK_2 2UL
#define LL_ADC_SQR_RANK_3 3UL
#define LL_ADC_SQR_RANK_4 4UL
#define LL_ADC_SQR_RANK_5 5UL
#define LL_ADC_SQR_RANK_6 6UL
#define LL_ADC_SQR_RANK_7 7UL
#define LL_ADC_SQR_RANK_8 8UL
#define LL_ADC_SQR_RANK_9 9UL
#define LL_ADC_SQR_RANK_10 10UL
#define LL_ADC_SQR_RANK_11 11UL
#define LL_ADC_SQR_RANK_12 12UL
#define LL_ADC_SQR_RANK_13 13UL
#define LL_ADC_SQR_RANK_14 14UL
#define LL_ADC_SQR_RANK_15 15UL
#define LL_ADC_JQR_SCAN_DISABLE (0x00UL<
#define LL_ADC_JQR_SCAN_ENABLE_1RANKS (0x00UL<
#define LL_ADC_JQR_SCAN_ENABLE_2RANKS (0x01UL<
#define LL_ADC_JQR_SCAN_ENABLE_3RANKS (0x02UL<
#define LL_ADC_JQR_SCAN_ENABLE_4RANKS (0x03UL<
#define LL_ADC_JQR_RANK_0 0
#define LL_ADC_JQR_RANK_1 1
#define LL_ADC_JQR_RANK_2 2
#define LL_ADC_JQR_RANK_3 3
#define LL_ADC_DATA_ALIGN_RIGHT 0x00000000UL
#define LL_ADC_DATA_ALIGN_LEFT ADC_CR1_ALIGN
#define LL_ADC_SAMPLINGTIME_4CYCLE ADC_CR0_SAM_CYCLE_4
#define LL_ADC_SAMPLINGTIME_6CYCLES ADC_CR0_SAM_CYCLE_6
#define LL_ADC_SAMPLINGTIME_8CYCLES ADC_CR0_SAM_CYCLE_8
#define LL_ADC_SAMPLINGTIME_12CYCLES ADC_CR0_SAM_CYCLE_12
#define LL_ADC_CLK_DIV_1 ADC_CR0_CLK_DIV1
#define LL_ADC_CLK_DIV_2 ADC_CR0_CLK_DIV2
#define LL_ADC_CLK_DIV_4 ADC_CR0_CLK_DIV4
#define LL_ADC_CLK_DIV_8 ADC_CR0_CLK_DIV8
#define LL_ADC_CONV_SINGLE 0x00000000UL
#define LL_ADC_CONV_CONTINUOUS (ADC_CR1_MODE)
#define LL_ADC_SQR_DMA_DISABLE 0x00000000UL
#define LL_ADC_SQR_DMA_ENABLE (ADC_CR1_DMA_SQR)
#define LL_ADC_JQR_DMA_DISABLE 0x00000000UL
#define LL_ADC_JQR_DMA_ENABLE (ADC_CR1_DMA_JQR)
#define LL_ADC_REF_SELECTED_IN1P5 ADC_CR0_REF_IN1P5
#define LL_ADC_REF_SELECTED_IN2P5 ADC_CR0_REF_IN2P5
#define LL_ADC_REF_SELECTED_EXREF ADC_CR0_REF_EXREF
#define LL_ADC_REF_SELECTED_AVCC ADC_CR0_REF_AVCC
#define LL_ADC_INREF_ENABLE ADC_CR0_INREF
#define LL_ADC_INREF_DISABLE 0x00000000UL
///
//函 数:
//功 能: 数据对齐
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
{
MODIFY_REG(ADCx->CR1, ADC_CR1_ALIGN, DataAlignment);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_ALIGN));
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable(ADC_TypeDef *ADCx)
{
//---检查BGR是否开启
if (LL_BGR_IsEnable(BGR) == 0)
{
if (LL_PER0_GRP1_IsEnabled_Clock(LL_PER0_GRP1_PERIPH_BGR) == 0)
{
LL_PER0_GRP1_Enable_Clock(LL_PER0_GRP1_PERIPH_BGR);
}
LL_BGR_Enable(BGR);
}
SET_BIT(ADCx->CR0, ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_EN) == ADC_CR0_EN);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_EnableIT(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_IE);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_DisableIT(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_IE);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabledIT(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_IE) == ADC_CR0_IE);
}
///
//函 数:
//功 能: 使能能不参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable_InRef(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_INREF);
}
///
//函 数:
//功 能: 不能使能内部参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable_InRef(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_INREF);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_IsEnabled_InRef(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_INREF) == ADC_CR0_INREF);
}
///
//函 数:
//功 能: 使能能不参考电压
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetInRefEN(ADC_TypeDef *ADCx,uint32_t en)
{
MODIFY_REG(ADCx->CR0, ADC_CR0_INREF,en);
}
///
//函 数:
//功 能: 采样时间
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_SetSamplingTime(ADC_TypeDef *ADCx, uint32_t SamplingTime)
{
MODIFY_REG(ADCx->CR0, ADC_CR0_SAM, SamplingTime);
}
///
//函 数:
//功 能:
//输入参 数:
//输出参 数:
//说 明:
//
static inline uint32_t LL_ADC_GetSamplingTime(ADC_TypeDef *ADCx)
{
return (uint32_t)(READ_BIT(ADCx->CR0, ADC_CR0_SAM));
}
///
//函 数:
//功 能: 使能跟谁器
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Enable_Buffer(ADC_TypeDef *ADCx)
{
SET_BIT(ADCx->CR0, ADC_CR0_BUFFER);
}
///
//函 数:
//功 能: 不使能跟谁器
//输入参 数:
//输出参 数:
//说 明:
//
static inline void LL_ADC_Disable_Buffer(ADC_TypeDef *ADCx)
{
CLEAR_BIT(ADCx->CR0, ADC_CR0_BUFFER);
}
举报