Added support for 32-bit clock ticks: when reading the 32-bit value, make sure that it does not change between readouts to avoid reading right in the middle of it being updated

This commit is contained in:
adamdunkels 2010-02-23 18:41:20 +00:00
parent 50e1452564
commit 465125c5e7
1 changed files with 9 additions and 2 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: clock.c,v 1.21 2010/01/30 14:03:35 adamdunkels Exp $ * @(#)$Id: clock.c,v 1.22 2010/02/23 18:41:20 adamdunkels Exp $
*/ */
@ -63,7 +63,9 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
/* Make sure interrupt time is future */ /* Make sure interrupt time is future */
do { do {
/* TACTL &= ~MC1;*/
TACCR1 += INTERVAL; TACCR1 += INTERVAL;
/* TACTL |= MC1;*/
++count; ++count;
/* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure
@ -98,7 +100,12 @@ interrupt(TIMERA1_VECTOR) timera1 (void) {
clock_time_t clock_time_t
clock_time(void) clock_time(void)
{ {
return count; clock_time_t t1, t2;
do {
t1 = count;
t2 = count;
} while(t1 != t2);
return t1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void