mirror of https://github.com/ARMmbed/mbed-os.git
Reset internal vref buffer after an ADC conversion using the config channel function
parent
a4ed473afc
commit
4378689944
|
@ -175,11 +175,13 @@ uint16_t adc_read(analogin_t *obj)
|
|||
HAL_ADC_Start(&obj->handle); // Start conversion
|
||||
|
||||
// Wait end of conversion and get value
|
||||
uint16_t adcValue = 0;
|
||||
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
|
||||
return (uint16_t)HAL_ADC_GetValue(&obj->handle);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
|
||||
}
|
||||
sConfig.Rank = ADC_RANK_NONE;
|
||||
HAL_ADC_ConfigChannel(&obj->handle, &sConfig);
|
||||
return adcValue;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue