Merge pull request #9560 from RobVlaar/analogin-fix-stm32l0xx

Reset internal vref buffer after an ADC conversion
pull/9581/head
Martin Kojtal 2019-02-01 08:25:10 +01:00 committed by GitHub
commit 363f35f842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 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