Skip to content

Commit

Permalink
[bsp][stm32] 修复 encoder驱动 编码器数值的计算问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ChnTamap authored and mysterywolf committed Nov 26, 2023
1 parent 17092dd commit 3ea3f34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ rt_int32_t pulse_encoder_get_count(struct rt_pulse_encoder_device *pulse_encoder
{
struct stm32_pulse_encoder_device *stm32_device;
stm32_device = (struct stm32_pulse_encoder_device*)pulse_encoder;
return (rt_int32_t)((rt_int16_t)__HAL_TIM_GET_COUNTER(&stm32_device->tim_handler) + stm32_device->over_under_flowcount * AUTO_RELOAD_VALUE);
return (rt_int32_t)((rt_int16_t)__HAL_TIM_GET_COUNTER(&stm32_device->tim_handler) + stm32_device->over_under_flowcount * (AUTO_RELOAD_VALUE + 1));
}

rt_err_t pulse_encoder_control(struct rt_pulse_encoder_device *pulse_encoder, rt_uint32_t cmd, void *args)
Expand Down

0 comments on commit 3ea3f34

Please sign in to comment.