]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/cc2420/packet/CC2420PacketP.nc
Fixing T32khz to TMilli conversion - coeficient 32 needs to be changed to 28.1.
[tinyos-2.x.git] / tos / chips / cc2420 / packet / CC2420PacketP.nc
index 0a730484f83c8dcf06837f507b5d3b0cd05d6fd6..f0c2e3849ba639be9d653fe5b8894f7b85ce5013 100644 (file)
@@ -138,10 +138,13 @@ implementation {
     return call PacketTimeStamp32khz.isValid(msg);
   }
 
+  //timestmap is always represented in 32khz
+  //28.1 is coefficient difference between T32khz and TMilli on MicaZ
   async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg)
   {
-    int32_t offset = call PacketTimeStamp32khz.timestamp(msg) - call LocalTime32khz.get();
-    return (offset >> 5) + call LocalTimeMilli.get();
+    int32_t offset = (call LocalTime32khz.get()-call PacketTimeStamp32khz.timestamp(msg));
+    offset/=28.1;
+    return call LocalTimeMilli.get() - offset;
   }
 
   async command void PacketTimeStampMilli.clear(message_t* msg)