Merge pull request #541 from simonduq/fix/timer-reset

timer_reset: do not do anything if the timer has not expired
This commit is contained in:
Simon Duquennoy 2018-10-13 12:21:29 +02:00 committed by GitHub
commit 5cb325f3a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 8 deletions

View File

@ -76,7 +76,8 @@ struct ctimer {
* is the exact time that the callback timer last
* expired. Therefore, this function will cause the timer
* to be stable over time, unlike the ctimer_restart()
* function.
* function. If this is executed before the timer expired,
* this function has no effect.
*
* \sa ctimer_restart()
*/

View File

@ -107,7 +107,8 @@ void etimer_set(struct etimer *et, clock_time_t interval);
* is the exact time that the event timer last
* expired. Therefore, this function will cause the timer
* to be stable over time, unlike the etimer_restart()
* function.
* function. If this is executed before the timer expired,
* this function has no effect.
*
* \sa etimer_restart()
*/

View File

@ -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;
}
}
/*---------------------------------------------------------------------------*/
/**

View File

@ -74,9 +74,8 @@ timer_set(struct timer *t, clock_time_t interval)
* given to the timer_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
* timer_restart() function.
*
* \note Must not be executed before timer expired
* timer_restart() function. If this is executed before the
* timer expired, this function has no effect.
*
* \param t A pointer to the timer.
* \sa timer_restart()
@ -84,7 +83,9 @@ timer_set(struct timer *t, clock_time_t interval)
void
timer_reset(struct timer *t)
{
t->start += t->interval;
if(timer_expired(t)) {
t->start += t->interval;
}
}
/*---------------------------------------------------------------------------*/
/**