提交 3b4bb18c 编写于 作者: misonyo's avatar misonyo

[components/drivers/hwtimer]修复定时器向下计数模式时时间获取错误bug

上级 0b79f450
...@@ -153,7 +153,7 @@ static rt_size_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buff ...@@ -153,7 +153,7 @@ static rt_size_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buff
cnt = timer->ops->count_get(timer); cnt = timer->ops->count_get(timer);
if (timer->info->cntmode == HWTIMER_CNTMODE_DW) if (timer->info->cntmode == HWTIMER_CNTMODE_DW)
{ {
cnt = timer->info->maxcnt - cnt; cnt = (timer->freq * timer->period_sec) - cnt;
} }
t = timer->overflow * timer->period_sec + cnt/(float)timer->freq; t = timer->overflow * timer->period_sec + cnt/(float)timer->freq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册