From 7d5e3fbfde7ca0bf82a2f10724f108d2f7e5d7a8 Mon Sep 17 00:00:00 2001 From: joxe Date: Mon, 15 Mar 2010 15:53:57 +0000 Subject: [PATCH] added function to retrieve elapsed time --- core/sys/stimer.c | 19 ++++++++++++++++++- core/sys/stimer.h | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) 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__ */