diff --git a/core/sys/stimer.c b/core/sys/stimer.c index b300afb3d..4307b8022 100644 --- a/core/sys/stimer.c +++ b/core/sys/stimer.c @@ -42,7 +42,7 @@ * * Author: Adam Dunkels , Nicolas Tsiftes * - * $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; +} + /*---------------------------------------------------------------------------*/ /** @} */ diff --git a/core/sys/stimer.h b/core/sys/stimer.h index 11bd1dee6..84279f711 100644 --- a/core/sys/stimer.h +++ b/core/sys/stimer.h @@ -64,7 +64,7 @@ * * Author: Adam Dunkels , Nicolas Tsiftes * - * $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__ */