From f5ea8314452b73bdc9ebab08c90a248a183b82f8 Mon Sep 17 00:00:00 2001 From: nifi Date: Mon, 13 Sep 2010 20:51:09 +0000 Subject: [PATCH] Added function rtimer_arch_now that makes sure that the timer value does not change between readouts to avoid reading while the timer is being updated. --- cpu/msp430/rtimer-arch.c | 13 ++++++++++++- cpu/msp430/rtimer-arch.h | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cpu/msp430/rtimer-arch.c b/cpu/msp430/rtimer-arch.c index 8a620b347..ff3a8742b 100644 --- a/cpu/msp430/rtimer-arch.c +++ b/cpu/msp430/rtimer-arch.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rtimer-arch.c,v 1.14 2010/02/18 22:15:54 adamdunkels Exp $ + * $Id: rtimer-arch.c,v 1.15 2010/09/13 20:51:09 nifi Exp $ */ /** @@ -77,6 +77,17 @@ rtimer_arch_init(void) eint(); } /*---------------------------------------------------------------------------*/ +rtimer_clock_t +rtimer_arch_now(void) +{ + rtimer_clock_t t1, t2; + do { + t1 = TAR; + t2 = TAR; + } while(t1 != t2); + return t1; +} +/*---------------------------------------------------------------------------*/ void rtimer_arch_schedule(rtimer_clock_t t) { diff --git a/cpu/msp430/rtimer-arch.h b/cpu/msp430/rtimer-arch.h index ac21cc414..4c4947761 100644 --- a/cpu/msp430/rtimer-arch.h +++ b/cpu/msp430/rtimer-arch.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rtimer-arch.h,v 1.7 2010/03/19 13:25:52 adamdunkels Exp $ + * $Id: rtimer-arch.h,v 1.8 2010/09/13 20:51:10 nifi Exp $ */ /** @@ -46,6 +46,6 @@ #define RTIMER_ARCH_SECOND (4096U*4) -#define rtimer_arch_now() (TAR) +rtimer_clock_t rtimer_arch_now(void); #endif /* __RTIMER_ARCH_H__ */