added function to retrieve elapsed time

This commit is contained in:
joxe 2010-03-15 15:53:57 +00:00
parent 573e772a32
commit 7d5e3fbfde
2 changed files with 20 additions and 2 deletions

View file

@ -42,7 +42,7 @@
*
* Author: Adam Dunkels <adam@sics.se>, Nicolas Tsiftes <nvt@sics.se>
*
* $Id: stimer.c,v 1.2 2008/11/05 19:34:36 nvt-se Exp $
* $Id: stimer.c,v 1.3 2010/03/15 15:53:57 joxe Exp $
*/
#include "contiki-conf.h"
@ -142,6 +142,23 @@ stimer_remaining(struct stimer *t)
{
return t->start + t->interval - clock_seconds();
}
/*---------------------------------------------------------------------------*/
/**
* The time elapsed since the timer started
*
* This function returns the time elapsed.
*
* \param t A pointer to the timer
*
* \return The time elapsed since the last start of the timer
*
*/
unsigned long
stimer_elapsed(struct stimer *t)
{
return clock_seconds() - t->start;
}
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -64,7 +64,7 @@
*
* Author: Adam Dunkels <adam@sics.se>, Nicolas Tsiftes <nvt@sics.se>
*
* $Id: stimer.h,v 1.3 2009/03/01 09:31:43 adamdunkels Exp $
* $Id: stimer.h,v 1.4 2010/03/15 15:53:57 joxe Exp $
*/
#ifndef __STIMER_H__
#define __STIMER_H__
@ -89,6 +89,7 @@ void stimer_reset(struct stimer *t);
void stimer_restart(struct stimer *t);
int stimer_expired(struct stimer *t);
unsigned long stimer_remaining(struct stimer *t);
unsigned long stimer_elapsed(struct stimer *t);
#endif /* __STIMER_H__ */