Reset internal vref buffer after an ADC conversion using the config channel function

pull/9560/head
Rob Vlaar 2019-01-30 14:43:05 +01:00
parent a4ed473afc
commit 4378689944
1 changed files with 6 additions and 4 deletions

View File

@ -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