diff options
| author | Bernard Xiong <[email protected]> | 2018-03-06 16:35:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-03-06 16:35:28 +0800 |
| commit | 2cfb670fa35775bcf00889cdc5c281e33afef478 (patch) | |
| tree | 5c36a491c222d015b33470b67931db38c25cb85e | |
| parent | 8f2588d609b01a59ee4ea8fba6e01a07f49182e5 (diff) | |
| parent | 2bbb27c29c1693fe48b250bf1cc7231e1e793e3b (diff) | |
Merge pull request #1259 from enkiller/development
[drivers]修复硬件定时器驱动框架单次长时间定时不准确的问题
| -rw-r--r-- | components/drivers/hwtimer/hwtimer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c index bbe50aa2f7..066c5f6f6c 100644 --- a/components/drivers/hwtimer/hwtimer.c +++ b/components/drivers/hwtimer/hwtimer.c @@ -192,14 +192,15 @@ static rt_size_t rt_hwtimer_write(struct rt_device *dev, rt_off_t pos, const voi if (size != sizeof(rt_hwtimerval_t)) return 0; + timer->ops->stop(timer); + timer->overflow = 0; + + t = timeout_calc(timer, (rt_hwtimerval_t*)buffer); if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT)) { opm = HWTIMER_MODE_ONESHOT; } - timer->ops->stop(timer); - timer->overflow = 0; - t = timeout_calc(timer, (rt_hwtimerval_t*)buffer); if (timer->ops->start(timer, t, opm) != RT_EOK) size = 0; |
