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:
commit
5cb325f3a4
|
@ -76,7 +76,8 @@ struct ctimer {
|
||||||
* is the exact time that the callback timer last
|
* is the exact time that the callback timer last
|
||||||
* expired. Therefore, this function will cause the timer
|
* expired. Therefore, this function will cause the timer
|
||||||
* to be stable over time, unlike the ctimer_restart()
|
* 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()
|
* \sa ctimer_restart()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -107,7 +107,8 @@ void etimer_set(struct etimer *et, clock_time_t interval);
|
||||||
* is the exact time that the event timer last
|
* is the exact time that the event timer last
|
||||||
* expired. Therefore, this function will cause the timer
|
* expired. Therefore, this function will cause the timer
|
||||||
* to be stable over time, unlike the etimer_restart()
|
* 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()
|
* \sa etimer_restart()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -77,7 +77,8 @@ stimer_set(struct stimer *t, unsigned long interval)
|
||||||
* given to the stimer_set() function. The start point of the interval
|
* given to the stimer_set() function. The start point of the interval
|
||||||
* is the exact time that the timer last expired. Therefore, this
|
* is the exact time that the timer last expired. Therefore, this
|
||||||
* function will cause the timer to be stable over time, unlike the
|
* 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.
|
* \param t A pointer to the timer.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +87,9 @@ stimer_set(struct stimer *t, unsigned long interval)
|
||||||
void
|
void
|
||||||
stimer_reset(struct stimer *t)
|
stimer_reset(struct stimer *t)
|
||||||
{
|
{
|
||||||
t->start += t->interval;
|
if(stimer_expired(t)) {
|
||||||
|
t->start += t->interval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
* given to the timer_set() function. The start point of the interval
|
||||||
* is the exact time that the timer last expired. Therefore, this
|
* is the exact time that the timer last expired. Therefore, this
|
||||||
* function will cause the timer to be stable over time, unlike the
|
* function will cause the timer to be stable over time, unlike the
|
||||||
* timer_restart() function.
|
* timer_restart() function. If this is executed before the
|
||||||
*
|
* timer expired, this function has no effect.
|
||||||
* \note Must not be executed before timer expired
|
|
||||||
*
|
*
|
||||||
* \param t A pointer to the timer.
|
* \param t A pointer to the timer.
|
||||||
* \sa timer_restart()
|
* \sa timer_restart()
|
||||||
|
@ -84,7 +83,9 @@ timer_set(struct timer *t, clock_time_t interval)
|
||||||
void
|
void
|
||||||
timer_reset(struct timer *t)
|
timer_reset(struct timer *t)
|
||||||
{
|
{
|
||||||
t->start += t->interval;
|
if(timer_expired(t)) {
|
||||||
|
t->start += t->interval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue