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.

This commit is contained in:
nifi 2010-09-13 20:51:09 +00:00
parent 095f700b63
commit f5ea831445
2 changed files with 14 additions and 3 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * 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(); eint();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
rtimer_clock_t
rtimer_arch_now(void)
{
rtimer_clock_t t1, t2;
do {
t1 = TAR;
t2 = TAR;
} while(t1 != t2);
return t1;
}
/*---------------------------------------------------------------------------*/
void void
rtimer_arch_schedule(rtimer_clock_t t) rtimer_arch_schedule(rtimer_clock_t t)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * 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_SECOND (4096U*4)
#define rtimer_arch_now() (TAR) rtimer_clock_t rtimer_arch_now(void);
#endif /* __RTIMER_ARCH_H__ */ #endif /* __RTIMER_ARCH_H__ */