STM32WB: ADC INTERNAL CHANNEL reset after read

Internal channels use is enabling ADC "internal path" which needs
to be disabled after measurement.

Same applied here for WB family as was done for others in #10143.
pull/9814/head
Laurent Meunier 2019-03-29 14:26:09 +01:00
parent c6277988c6
commit b0f4815261
1 changed files with 4 additions and 11 deletions

View File

@ -190,19 +190,12 @@ uint16_t adc_read(analogin_t *obj)
}
// Wait end of conversion and get value
uint16_t adcValue = 0;
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
/* Ref Manual: To prevent any unwanted consumption on the battery,
it is recommended to enable the bridge divider only when needed for ADC conversion */
if (sConfig.Channel == ADC_CHANNEL_VBAT) {
CLEAR_BIT(__LL_ADC_COMMON_INSTANCE(obj->handle.Instance)->CCR, LL_ADC_PATH_INTERNAL_VBAT);
}
return (uint16_t)HAL_ADC_GetValue(&obj->handle);
} else {
debug("ADC conversion failed. Returned 0.\r\n");
return 0;
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
}
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE((&obj->handle)->Instance), LL_ADC_PATH_INTERNAL_NONE);
return adcValue;
}
const PinMap *analogin_pinmap()