We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4ed473 commit 4378689Copy full SHA for 4378689
targets/TARGET_STM/TARGET_STM32L0/analogin_device.c
@@ -175,11 +175,13 @@ uint16_t adc_read(analogin_t *obj)
175
HAL_ADC_Start(&obj->handle); // Start conversion
176
177
// Wait end of conversion and get value
178
+ uint16_t adcValue = 0;
179
if (HAL_ADC_PollForConversion(&obj->handle, 10) == HAL_OK) {
- return (uint16_t)HAL_ADC_GetValue(&obj->handle);
180
- } else {
181
- return 0;
182
- }
+ adcValue = (uint16_t)HAL_ADC_GetValue(&obj->handle);
+ }
+ sConfig.Rank = ADC_RANK_NONE;
183
+ HAL_ADC_ConfigChannel(&obj->handle, &sConfig);
184
+ return adcValue;
185
}
186
187
#endif
0 commit comments