[drivers]修复定时器驱动框架单次长时间定时不准确的问题

This commit is contained in:
tangyuxin 2018-03-06 10:38:35 +08:00
parent 8f2588d609
commit 2bbb27c29c
1 changed files with 5 additions and 4 deletions

View File

@ -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)) if (size != sizeof(rt_hwtimerval_t))
return 0; return 0;
if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT))
{
opm = HWTIMER_MODE_ONESHOT;
}
timer->ops->stop(timer); timer->ops->stop(timer);
timer->overflow = 0; timer->overflow = 0;
t = timeout_calc(timer, (rt_hwtimerval_t*)buffer); t = timeout_calc(timer, (rt_hwtimerval_t*)buffer);
if ((timer->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT))
{
opm = HWTIMER_MODE_ONESHOT;
}
if (timer->ops->start(timer, t, opm) != RT_EOK) if (timer->ops->start(timer, t, opm) != RT_EOK)
size = 0; size = 0;