FIX: [bsp][stm32] pulse_encoder driver did not handle TIM overflow

This commit is contained in:
bzrobotics 2022-10-05 13:07:26 +08:00 committed by Man, Jianting (Meco)
parent c17d5d509f
commit 560a21207e
1 changed files with 2 additions and 0 deletions

View File

@ -157,10 +157,12 @@ rt_err_t pulse_encoder_control(struct rt_pulse_encoder_device *pulse_encoder, rt
switch (cmd)
{
case PULSE_ENCODER_CMD_ENABLE:
__HAL_TIM_ENABLE_IT(&stm32_device->tim_handler, TIM_IT_UPDATE);
HAL_TIM_Encoder_Start(&stm32_device->tim_handler, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Start_IT(&stm32_device->tim_handler, TIM_CHANNEL_ALL);
break;
case PULSE_ENCODER_CMD_DISABLE:
__HAL_TIM_DISABLE_IT(&stm32_device->tim_handler, TIM_IT_UPDATE);
HAL_TIM_Encoder_Stop(&stm32_device->tim_handler, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Stop_IT(&stm32_device->tim_handler, TIM_CHANNEL_ALL);
break;