diff --git a/targets/TARGET_STM/TARGET_STM32WB/analogin_device.c b/targets/TARGET_STM/TARGET_STM32WB/analogin_device.c index ac63be50125..4e1769889de 100644 --- a/targets/TARGET_STM/TARGET_STM32WB/analogin_device.c +++ b/targets/TARGET_STM/TARGET_STM32WB/analogin_device.c @@ -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()