changed to use unsigned long for seconds counter

This commit is contained in:
nifi 2008-10-10 12:36:58 +00:00
parent aff141f56e
commit 49f57b7848

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.15 2008/09/16 12:00:48 fros4943 Exp $ * @(#)$Id: clock.c,v 1.16 2008/10/10 12:36:58 nifi Exp $
*/ */
@ -47,7 +47,7 @@
#define MAX_TICKS (~((clock_time_t)0) / 2) #define MAX_TICKS (~((clock_time_t)0) / 2)
static volatile unsigned short seconds; static volatile unsigned long seconds;
static volatile clock_time_t count = 0; static volatile clock_time_t count = 0;
/* last_tar is used for calculating clock_fine, last_ccr might be better? */ /* last_tar is used for calculating clock_fine, last_ccr might be better? */
@ -189,22 +189,12 @@ clock_set_seconds(unsigned long sec)
unsigned long unsigned long
clock_seconds(void) clock_seconds(void)
{ {
static unsigned long offset; unsigned long t1, t2;
static unsigned long last_time; do {
unsigned long new_time; t1 = seconds;
t2 = seconds;
new_time = seconds + offset; } while(t1 != t2);
return t1;
/* printf("Seconds %d new_time %lu offset %lu\n", seconds, new_time, offset);*/
if(new_time < last_time) {
offset += 0x10000L;
new_time += 0x10000L;
}
last_time = new_time;
return new_time;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
rtimer_clock_t rtimer_clock_t