Fix crash related to ADC timeout
This commit is contained in:
parent
168823e096
commit
7c713b9e3b
|
@ -118,7 +118,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||||
HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
|
HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
|
||||||
|
|
||||||
HAL_ADC_Start(&AdcHandle);
|
HAL_ADC_Start(&AdcHandle);
|
||||||
HAL_ADC_PollForConversion(&AdcHandle,1); //timeout in ms
|
HAL_ADC_PollForConversion(&AdcHandle,1); //doesn't work as HAL_GetTick always returns 0
|
||||||
|
//uint32_t tickstart = ticks_ms;
|
||||||
uint16_t uhADCxConvertedData = (uint16_t)HAL_ADC_GetValue(&AdcHandle);
|
uint16_t uhADCxConvertedData = (uint16_t)HAL_ADC_GetValue(&AdcHandle);
|
||||||
HAL_ADC_Stop(&AdcHandle);
|
HAL_ADC_Stop(&AdcHandle);
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,11 @@ void SysTick_Handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t HAL_GetTick(void) //override ST HAL
|
||||||
|
{
|
||||||
|
return (uint32_t)ticks_ms;
|
||||||
|
}
|
||||||
|
|
||||||
void tick_init() {
|
void tick_init() {
|
||||||
uint32_t ticks_per_ms = SystemCoreClock/ 1000;
|
uint32_t ticks_per_ms = SystemCoreClock/ 1000;
|
||||||
SysTick_Config(ticks_per_ms); // interrupt is enabled
|
SysTick_Config(ticks_per_ms); // interrupt is enabled
|
||||||
|
|
Loading…
Reference in New Issue