302 lines
8.6 KiB
C
302 lines
8.6 KiB
C
|
/***************************************************************
|
|||
|
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
|
|||
|
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lib_timer.c
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD>ߣ<EFBFBD> Liut
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> V1.00
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD>ڣ<EFBFBD> 2017/07/14
|
|||
|
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ADCģ<EFBFBD><EFBFBD><EFBFBD>⺯<EFBFBD><EFBFBD>
|
|||
|
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508xоƬ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
#include "lib_adc.h"
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_Init
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ADCģ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ýṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
void ADC_Init(ADC_InitStruType * ADC_InitStruct)
|
|||
|
{
|
|||
|
ADC->VREFCON.VREF_EN = ENABLE; //<2F>ڲ<EFBFBD>VREFPʹ<50><CAB9>
|
|||
|
ADC->VREFCON.IREF_EN = ENABLE; //IREFʹ<46><CAB9>λ
|
|||
|
ADC->CON1.VCMBUF_EN = ENABLE; //ADC<44><43>ģ<EFBFBD><C4A3>ѹVCM BUFʹ<46><CAB9>
|
|||
|
ADC ->CON1.VCMBUF_HS = ENABLE; //ADC<44><43>ģ<EFBFBD><C4A3>ѹVCM BUF<55><46><EFBFBD><EFBFBD>ģʽʹ<CABD><CAB9>
|
|||
|
ADC->CON1.HSEN = ENABLE; //ADCת<43><D7AA><EFBFBD>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ADC->CHS.VDD5_FLAG_EN = DISABLE; //<2F><><EFBFBD><EFBFBD>VDD<44><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
ADC->CON1.CLKS = ADC_InitStruct->ADC_ClkS; //ADCCON1:bit3 ADCʱ<43><CAB1>Դѡ<D4B4><D1A1>
|
|||
|
ADC->CON1.CLKDIV = ADC_InitStruct->ADC_ClkDiv; //ADCCON1:bit2-0 ADCʱ<43><CAB1>ԴԤ<D4B4><D4A4>Ƶ
|
|||
|
ADC->CON1.VREFP = ADC_InitStruct->ADC_VrefP; //ADCCON1:bit9-8 ADC<44><43><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>ѹѡ<D1B9><D1A1>
|
|||
|
ADC->CON1.SMPS = ADC_InitStruct->ADC_SampS; //ADCCON1:bit12 ADC<44><43><EFBFBD><EFBFBD>ģʽѡ<CABD><D1A1>
|
|||
|
ADC->CHS.CHS = ADC_InitStruct->ADC_ChS; //ADCCHS:bit0-3 ADCģ<43><C4A3>ͨ<EFBFBD><CDA8>ѡ<EFBFBD><D1A1>
|
|||
|
ADC->CON1.ST = ADC_InitStruct->ST; //ADCCON1:bit20-16 ADC<44><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1> ST*2+1<><31>Tadclk
|
|||
|
//ADC->VREFCON.VREF_SEL=ADC_InitStruct->VREF_SEL;//<2F>ڲ<EFBFBD><DAB2>ο<EFBFBD><CEBF><EFBFBD>ѹѡ<D1B9><D1A1>
|
|||
|
|
|||
|
ADC->CON1.VREFN = ADC_InitStruct->ADC_VREFN; //<2F><><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>ѹʹ<D1B9><CAB9>λ
|
|||
|
ADC->CON1.VRBUF_EN = ADC_InitStruct->ADC_VRBUF_EN; //VREF BUFʹ<46><CAB9>λ
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_Set_CH
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ADCģ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
void ADC_Set_CH(ADC_TYPE_CHS AdcCH)
|
|||
|
{
|
|||
|
ADC->CHS.CHS = AdcCH;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetConvValue
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡADCת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>ֵ
|
|||
|
***************************************************************/
|
|||
|
uint16_t ADC_GetConvValue(void)
|
|||
|
{
|
|||
|
return ((uint16_t)ADC->DR.DR);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetConvStatus
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡADCת<EFBFBD><EFBFBD>״̬
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)/SET(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>)
|
|||
|
***************************************************************/
|
|||
|
FlagStatus ADC_GetConvStatus(void)
|
|||
|
{
|
|||
|
FlagStatus bitstatus = RESET;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>״̬<D7B4>Ĵ<EFBFBD><C4B4><EFBFBD> */
|
|||
|
if ((ADC->CON0.TRIG != (uint32_t)RESET))
|
|||
|
bitstatus = SET; //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
|
|||
|
else
|
|||
|
bitstatus = RESET; //ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
return bitstatus;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_ACPConfig
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD>Զ<EFBFBD><EFBFBD>ȽϹ<EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ADC_ACP_InitStruct <EFBFBD>Զ<EFBFBD><EFBFBD>ȽϹ<EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SUCCESS <EFBFBD>ɹ<EFBFBD>
|
|||
|
ERROR ʧ<EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
ErrorStatus ADC_ACPConfig(ADC_ACP_TypeDef *ADC_ACP_InitStruct)
|
|||
|
{
|
|||
|
if(ADC_ACP_InitStruct->ACPC_OVER_TIME > ADC_ACPC_OVFL_TIME_MAX
|
|||
|
||ADC_ACP_InitStruct->ACPC_TIMES > ADC_ACPC_TIMES_MAX
|
|||
|
||ADC_ACP_InitStruct->ACPC_MIN_TARGET > ADC_ACP_MIN_MAX
|
|||
|
||ADC_ACP_InitStruct->ACPC_MAX_TARGET > ADC_ACP_MAX_MAX)
|
|||
|
{
|
|||
|
return ERROR;
|
|||
|
}
|
|||
|
|
|||
|
if(ADC_ACP_InitStruct->ACP_EN == ENABLE)
|
|||
|
{
|
|||
|
if(ADC->CON1.CLKS == ADC_ClkS_PCLK)
|
|||
|
{
|
|||
|
ADC->ACPC.CLKS = ADC_ACPC_CLKS_PCLK;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ADC->ACPC.CLKS = ADC_ACPC_CLKS_LRC;
|
|||
|
}
|
|||
|
|
|||
|
ADC->ACPC.OVFL_TIME = ADC_ACP_InitStruct ->ACPC_OVER_TIME;
|
|||
|
ADC->ACPC.TIMES = ADC_ACP_InitStruct->ACPC_TIMES;
|
|||
|
ADC->IE.ACPOVIE = ENABLE;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>߷<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ó<EFBFBD>0(<28><>Сֵ)<29><><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>رոù<D5B8><C3B9><EFBFBD> */
|
|||
|
if(ADC_ACP_InitStruct ->ACPC_MAX_TARGET ==0x0)
|
|||
|
{
|
|||
|
ADC->IE.ACPMAXIE = DISABLE;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ADC->ACPCMP.CMP_MAX =ADC_ACP_InitStruct ->ACPC_MAX_TARGET;
|
|||
|
ADC->IE.ACPMAXIE = ENABLE;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ͷ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ó<EFBFBD>0xfff(<28><><EFBFBD><EFBFBD>ֵ)<29><><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>رոù<D5B8><C3B9><EFBFBD> */
|
|||
|
if(ADC_ACP_InitStruct ->ACPC_MIN_TARGET == 0xfff)
|
|||
|
{
|
|||
|
ADC->IE.ACPMINIE = DISABLE;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ADC->ACPCMP.CMP_MIN =ADC_ACP_InitStruct ->ACPC_MIN_TARGET;
|
|||
|
ADC->IE.ACPMINIE = ENABLE;
|
|||
|
}
|
|||
|
|
|||
|
ADC->CON0.ACP_EN = ENABLE;
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ADC->CON0.ACP_EN = DISABLE;
|
|||
|
}
|
|||
|
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_SampStart
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SUCCESS <EFBFBD>ɹ<EFBFBD>
|
|||
|
ERROR ʧ<EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
ErrorStatus ADC_SoftStart(void)
|
|||
|
{
|
|||
|
if(ADC->CON1.SMPS == ADC_SMPS_HARD)
|
|||
|
return ERROR;
|
|||
|
|
|||
|
ADC ->CON1.SMPON = SET;
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_SampStop
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SUCCESS <EFBFBD>ɹ<EFBFBD>
|
|||
|
ERROR ʧ<EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
ErrorStatus ADC_SoftStop(void)
|
|||
|
{
|
|||
|
if(ADC->CON1.SMPS == ADC_SMPS_HARD)
|
|||
|
return ERROR;
|
|||
|
|
|||
|
ADC->CON1.SMPON = RESET;
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetACPMeanValue
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>Ƚ<EFBFBD>ƽ<EFBFBD><EFBFBD>ֵ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
uint16_t ADC_GetACPMeanValue(void)
|
|||
|
{
|
|||
|
return ((uint16_t)ADC->ACPMEAN.MEAN_DATA);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetACPMINValue
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>Ƚ<EFBFBD>ƽ<EFBFBD><EFBFBD>ֵ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
uint16_t ADC_GetACPMinValue(void)
|
|||
|
{
|
|||
|
return ((uint16_t)ADC->ACPCMP.CMP_MIN);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetACPMAXValue
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>Ƚ<EFBFBD>ƽ<EFBFBD><EFBFBD>ֵ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
uint16_t ADC_GetACPMaxValue(void)
|
|||
|
{
|
|||
|
return ((uint16_t)ADC->ACPCMP.CMP_MAX);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetFlagStatus
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡADC<EFBFBD><EFBFBD>־λ״̬
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>IFName<EFBFBD><EFBFBD>ADC<EFBFBD>жϱ<EFBFBD>־
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET/RESET
|
|||
|
***************************************************************/
|
|||
|
FlagStatus ADC_GetFlagStatus(ADC_TYPE_IF IFName)
|
|||
|
{
|
|||
|
FlagStatus bitstatus = RESET;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ */
|
|||
|
if (((ADC->IF.Word & IFName) != (uint32_t)RESET))
|
|||
|
bitstatus = SET; //ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
else
|
|||
|
bitstatus = RESET; //<2F><><EFBFBD>ж<EFBFBD>
|
|||
|
|
|||
|
return bitstatus;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_GetITStatus
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡADC<EFBFBD>ж<EFBFBD>״̬<EFBFBD><EFBFBD>δʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>᷵<EFBFBD><EFBFBD>SET
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SET<EFBFBD><EFBFBD><EFBFBD>жϣ<EFBFBD>/RESET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
ITStatus ADC_GetITStatus(ADC_TYPE_IE IEName)
|
|||
|
{
|
|||
|
ITStatus bitstatus = RESET;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ */
|
|||
|
if (((ADC->IE.Word & IEName) != (uint32_t)RESET))
|
|||
|
bitstatus = SET; //ת<><D7AA><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
else
|
|||
|
bitstatus = RESET; //<2F><><EFBFBD>ж<EFBFBD>
|
|||
|
|
|||
|
return bitstatus;
|
|||
|
}
|
|||
|
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_ClearIFStatus
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>IFName <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|||
|
ADC_IF ADC<EFBFBD>ж<EFBFBD>
|
|||
|
ADC_IF_ACPMIN <EFBFBD>Զ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
ADC_IF_ACPMAX <EFBFBD>Զ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
ADC_IF_ACPOVER <EFBFBD>Զ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>SUCCESS <EFBFBD>ɹ<EFBFBD>
|
|||
|
ERROR ʧ<EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
ErrorStatus ADC_ClearIFStatus(ADC_TYPE_IF IFName)
|
|||
|
{
|
|||
|
ADC->IF.Word = (uint32_t)IFName;
|
|||
|
|
|||
|
return SUCCESS;
|
|||
|
}
|
|||
|
/***************************************************************
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC_Reset
|
|||
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADC<EFBFBD><EFBFBD>λ
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
***************************************************************/
|
|||
|
void ADC_Reset(void)
|
|||
|
{
|
|||
|
ADC->CON0.Word = 0x00000030;
|
|||
|
ADC->CON1.Word = 0x00041000;
|
|||
|
ADC->CHS.Word = 0x00000100;
|
|||
|
ADC->IE.Word = 0x00000000;
|
|||
|
ADC->IF.Word = 0x00000000;
|
|||
|
ADC->ACPC.Word = 0x00000000;
|
|||
|
ADC->ACPCMP.Word = 0x0FFF0000;
|
|||
|
ADC->VREFCON.Word = 0x00000000;
|
|||
|
}
|
|||
|
|
|||
|
/*************************END OF FILE**********************/
|
|||
|
|
|||
|
|