Fix crash related to ADC timeout

This commit is contained in:
Hierophect 2019-09-17 15:45:15 -04:00
parent 168823e096
commit 7c713b9e3b
2 changed files with 7 additions and 1 deletions

View File

@ -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);

View File

@ -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