X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fplatforms%2FeyesIFX%2FLocalTimeP.nc;h=6e00648de802127ec9f446798b9d56e6bb8bcb12;hb=4ba4b94611387e857fa1249fe49340aeabe9670e;hp=87784227ceca7a2cbf438a64efbbfaa4539175c0;hpb=e5533d4cc5eb80845d8e58456a03d2188abda869;p=tinyos-2.x.git diff --git a/tos/platforms/eyesIFX/LocalTimeP.nc b/tos/platforms/eyesIFX/LocalTimeP.nc index 87784227..6e00648d 100644 --- a/tos/platforms/eyesIFX/LocalTimeP.nc +++ b/tos/platforms/eyesIFX/LocalTimeP.nc @@ -30,6 +30,7 @@ module LocalTimeP { provides { interface LocalTime as LocalTime32kHz; + interface WideLocalTime as WideLocalTime; } uses { interface Counter as Counter32khz16; @@ -45,20 +46,42 @@ implementation { }; } ui32parts_t; - uint16_t counter2sec = 127; + typedef union + { + uint64_t op; + struct { + uint32_t lo; + uint32_t hi; + }; + } ui64parts_t; + uint16_t counter2sec = 127; + uint32_t dayCounter = 0; + async command uint32_t LocalTime32kHz.get() { ui32parts_t time; atomic { time.lo = call Counter32khz16.get(); time.hi = counter2sec; - if(call Counter32khz16.isOverflowPending()) ++time.hi; + if(call Counter32khz16.isOverflowPending()) { + time.hi++; + } } return time.op; } + async command uint64_t WideLocalTime.get() { + ui64parts_t time; + atomic { + time.lo = call LocalTime32kHz.get(); + time.hi = dayCounter; + } + return time.op; + } + async event void Counter32khz16.overflow() { ++counter2sec; + if(counter2sec == 0) ++dayCounter; } }