From 8472cf8bbe4d57d18bce7522070aa1cf9be7fabd Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 13 Oct 2018 10:17:30 +0200 Subject: [PATCH] stimer_reset: do not do anything if the timer has not expired --- os/sys/stimer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/os/sys/stimer.c b/os/sys/stimer.c index 1301dc41e..007587e83 100644 --- a/os/sys/stimer.c +++ b/os/sys/stimer.c @@ -77,7 +77,8 @@ stimer_set(struct stimer *t, unsigned long interval) * given to the stimer_set() function. The start point of the interval * is the exact time that the timer last expired. Therefore, this * function will cause the timer to be stable over time, unlike the - * stimer_restart() function. + * stimer_restart() function. If this is executed before the + * timer expired, this function has no effect. * * \param t A pointer to the timer. * @@ -86,7 +87,9 @@ stimer_set(struct stimer *t, unsigned long interval) void stimer_reset(struct stimer *t) { - t->start += t->interval; + if(stimer_expired(t)) { + t->start += t->interval; + } } /*---------------------------------------------------------------------------*/ /**