summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMr.M <[email protected]>2023-07-18 02:52:56 +0000
committerMan, Jianting (Meco) <[email protected]>2023-07-21 00:28:31 -0400
commitc985f318e4ca5271911816c74f021aaca9e258e4 (patch)
treef23b32c16056dd645007e35e8236c8594290bbbd /components
parentf2063388133fbd1972a98b800ff146eb2f7579ef (diff)
overflow is invalid in oneshot mode
Diffstat (limited to 'components')
-rw-r--r--components/drivers/hwtimer/hwtimer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c
index f17a08bd8e..27ffff6025 100644
--- a/components/drivers/hwtimer/hwtimer.c
+++ b/components/drivers/hwtimer/hwtimer.c
@@ -165,6 +165,10 @@ static rt_ssize_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buf
{
cnt = (rt_uint32_t)(timer->freq * timer->period_sec) - cnt;
}
+ if (timer->mode == HWTIMER_MODE_ONESHOT)
+ {
+ overflow = 0;
+ }
t = overflow * timer->period_sec + cnt/(float)timer->freq;
tv.sec = (rt_int32_t)t;