From 2bbb27c29c1693fe48b250bf1cc7231e1e793e3b Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Tue, 6 Mar 2018 10:38:35 +0800 Subject: [PATCH] =?UTF-8?q?[drivers]=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=99=A8=E9=A9=B1=E5=8A=A8=E6=A1=86=E6=9E=B6=E5=8D=95=E6=AC=A1?= =?UTF-8?q?=E9=95=BF=E6=97=B6=E9=97=B4=E5=AE=9A=E6=97=B6=E4=B8=8D=E5=87=86?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/hwtimer/hwtimer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c index bbe50aa2f..066c5f6f6 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; - 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->cycles <= 1) && (timer->mode == HWTIMER_MODE_ONESHOT)) + { + opm = HWTIMER_MODE_ONESHOT; + } + if (timer->ops->start(timer, t, opm) != RT_EOK) size = 0;