Add function etimer_reset_set.

This new function is similar to reset, but allows to also set a new
timeout. Thus long-term accuracy with changing timeouts is now possible.
This commit is contained in:
Moritz 'Morty' Strübe 2012-11-02 16:56:11 +01:00
parent ea5216a9cb
commit 9b77aac542
2 changed files with 21 additions and 0 deletions

View File

@ -181,6 +181,14 @@ etimer_set(struct etimer *et, clock_time_t interval)
}
/*---------------------------------------------------------------------------*/
void
etimer_reset_with_new_interval(struct etimer *et, clock_time_t interval)
{
timer_reset(&et->timer);
et->timer.interval = interval;
add_timer(et);
}
/*---------------------------------------------------------------------------*/
void
etimer_reset(struct etimer *et)
{
timer_reset(&et->timer);

View File

@ -114,6 +114,19 @@ CCIF void etimer_set(struct etimer *et, clock_time_t interval);
*/
CCIF void etimer_reset(struct etimer *et);
/**
* \brief Reset an event timer with a new interval.
* \param et A pointer to the event timer.
* \param interval The interval before the timer expires.
*
* This function very similar to etimer_reset. Opposed to
* etimer_reset it is possible to change the timout.
* This allows accurate, non-periodic timers without drift.
*
* \sa etimer_reset()
*/
void etimer_reset_with_new_interval(struct etimer *et, clock_time_t interval);
/**
* \brief Restart an event timer from the current point in time
* \param et A pointer to the event timer.