summaryrefslogtreecommitdiff
path: root/bsp/stm32
diff options
context:
space:
mode:
authorTamapChn <[email protected]>2023-11-26 16:58:29 +0800
committerMeco Man <[email protected]>2023-11-26 18:00:01 +0800
commit3ea3f3447e2a6f6233d64ed84ef7e5abc9cc655a (patch)
tree8c866ab25b6fe284a27b3b214ca96a200960f419 /bsp/stm32
parent17092dd7001fb88a1939dd2a0eac1a0185cf3763 (diff)
[bsp][stm32] 修复 encoder驱动 编码器数值的计算问题
Diffstat (limited to 'bsp/stm32')
-rw-r--r--bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c b/bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
index 51e3c64c7b..8482b598ad 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_pulse_encoder.c
@@ -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)