Skip to content

Commit 03b03fe

Browse files
committed
TARGET_STM32F1: don't set ADC common register when ADC doesn't support it
STM32F103ZE: ADC3 doesn't support common settings. __LL_ADC_COMMON_INSTANCE(ADC3) returns 0
1 parent 0f4a986 commit 03b03fe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

targets/TARGET_STM/TARGET_STM32F1/analogin_device.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ uint16_t adc_read(analogin_t *obj)
177177
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
178178
adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
179179
}
180-
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE((&obj->handle)->Instance), LL_ADC_PATH_INTERNAL_NONE);
180+
181+
if (__LL_ADC_COMMON_INSTANCE(__LL_ADC_COMMON_INSTANCE((&obj->handle)->Instance)) != 0U) {
182+
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE((&obj->handle)->Instance), LL_ADC_PATH_INTERNAL_NONE);
183+
}
181184
return adcValue;
182185
}
183186

0 commit comments

Comments
 (0)