소스 검색

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

misonyo 6 년 전
부모
커밋
3b4bb18c06
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      components/drivers/hwtimer/hwtimer.c

+ 1 - 1
components/drivers/hwtimer/hwtimer.c

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