Commit 3b98ffad authored by 陈家乐's avatar 陈家乐

🐞 fix:禅道问题:45370、45353、45351,中微厂家更改

parent 324d2a83
...@@ -166,27 +166,34 @@ uint16_t ADC_Converse(ADC_Channel_t ch, uint32_t times, uint16_t *buf) ...@@ -166,27 +166,34 @@ uint16_t ADC_Converse(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
volatile uint8_t flag; volatile uint8_t flag;
uint32_t total = 0; uint32_t total = 0;
INTC_DisableIRQ(ADC_IRQn); // disable INTAD interrupt if(times == 0)
{
return 0;
}
else
{
INTC_DisableIRQ(ADC_IRQn); // disable INTAD interrupt
ADC->ADM0 &= ~ADC_Enable; ADC->ADM0 &= ~ADC_Enable;
ADC->ADM1 |= ADC_Conv_Oneshot; //enable one-shot convertion ADC->ADM1 |= ADC_Conv_Oneshot; //enable one-shot convertion
ADC->ADTRG = ADC_ExternalTrig_Software; ADC->ADTRG = ADC_ExternalTrig_Software;
ADC->ADM0 |= ADC_Enable; ADC->ADM0 |= ADC_Enable;
ADC->ADS = ch; ADC->ADS = ch;
for(i=0; i<times;i++) for(i=0; i<times;i++)
{ {
ADC->ADM0 |= ADC_Start_Cmp; //adc start ADC->ADM0 |= ADC_Start_Cmp; //adc start
while(INTC_GetPendingIRQ(ADC_IRQn) == 0); while(INTC_GetPendingIRQ(ADC_IRQn) == 0);
INTC_ClearPendingIRQ(ADC_IRQn); // clear INTAD interrupt flag INTC_ClearPendingIRQ(ADC_IRQn); // clear INTAD interrupt flag
*buf++ = ADC->ADCR; *buf++ = ADC->ADCR;
total += ADC->ADCR; total += ADC->ADCR;
}
return (total / times); // return average value
} }
return (total / times); // return average value
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment