Skip to content

Commit 575ede5

Browse files
committed
Fix
1 parent 065c9b3 commit 575ede5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

libraries/SrcWrapper/src/stm32/analog.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,17 +929,21 @@ uint16_t adc_read_value(PinName pin, uint32_t resolution)
929929

930930
if (!LL_ADC_IsEnabled(AdcHandle.Instance)) {
931931
AdcHandle.State = HAL_ADC_STATE_RESET;
932-
AdcHandle.DMA_Handle = NULL;
933-
AdcHandle.Lock = HAL_UNLOCKED;
934-
/* Some other ADC_HandleTypeDef fields exists but not required */
932+
} else {
933+
AdcHandle.State = HAL_ADC_STATE_READY;
934+
}
935+
936+
AdcHandle.DMA_Handle = NULL;
937+
AdcHandle.Lock = HAL_UNLOCKED;
938+
/* Some other ADC_HandleTypeDef fields exists but not required */
935939

936-
g_current_pin = pin; /* Needed for HAL_ADC_MspInit*/
940+
g_current_pin = pin; /* Needed for HAL_ADC_MspInit*/
937941

938-
if (HAL_ADC_Init(&AdcHandle) != HAL_OK) {
939-
return 0;
940-
}
942+
if (HAL_ADC_Init(&AdcHandle) != HAL_OK) {
943+
return 0;
941944
}
942945

946+
943947
AdcChannelConf.Channel = channel; /* Specifies the channel to configure into ADC */
944948

945949
#if defined(STM32G4xx) || defined(STM32H5xx) || defined(STM32L4xx) || \

0 commit comments

Comments
 (0)