智能车制作
标题:
void ADC_Init(ADC_InitTypeDef* ADC_InitStruct)怎么引用
[打印本页]
作者:
綿婲/ka餹
时间:
2014-4-7 15:23
标题:
void ADC_Init(ADC_InitTypeDef* ADC_InitStruct)怎么引用
void ADC_Init(ADC_InitTypeDef* ADC_InitStruct)
{
uint8_t i;
ADC_Type *ADCx = ADC0;
PeripheralMapTypeDef *pADC_Map = (PeripheralMapTypeDef*)&(ADC_InitStruct->ADCxMap);
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK; //′ò¿aê±ÖóÃÅ
ADCx->CFG1 &= ~(ADC_CFG1_MODE_MASK); //éèÖÃAD¾«¶è
ADCx->CFG1 |= ADC_CFG1_MODE(ADC_InitStruct->ADC_Precision);
ADCx->CFG1 &= ~ADC_CFG1_ADICLK_MASK; //×üÏßê±ÖóÎaadê±ÖóÔ′
ADCx->CFG1 |= ADC_CFG1_ADICLK(0);
ADCx->CFG1 &= ~ADC_CFG1_ADLSMP_MASK; //3éÑùê±¼ä
ADCx->CFG1 &= ~ADC_CFG1_ADIV_MASK; //3éÑùê±Öó·ÖÆμ
ADCx->CFG1 |= ADC_CFG1_ADIV(3);
if(pADC_Map->m_PinCntIndex > 1) // μ¥í¨μà¡¢2î·Öí¨μà
{
ADCx->SC1[pADC_Map->m_SpecDefine1] |= ADC_SC1_DIFF_MASK;
}
else
{
ADCx->SC1[pADC_Map->m_SpecDefine1] &= ~ADC_SC1_DIFF_MASK;
}
//Calieration
i = ADC_Cal(ADCx);
//′¥·¢Ô′
(ADC_TRIGGER_HW == ADC_InitStruct->ADC_TriggerSelect)?(ADCx->SC2 |= ADC_SC2_ADTRG_MASK)
ADCx->SC2 &= ~ADC_SC2_ADTRG_MASK);
for(i=0;i<pADC_Map->m_PinCntIndex;i++)
{
PinMuxConfig(pADC_Map->m_PortIndex,pADC_Map->m_PinBaseIndex+i,pADC_Map->m_MuxIndex);
}
}
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2