X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fcc2420%2Fpacket%2FCC2420PacketP.nc;h=f0c2e3849ba639be9d653fe5b8894f7b85ce5013;hb=f8120ec47efebf578a6edf99882d009ea6dedcd1;hp=0a730484f83c8dcf06837f507b5d3b0cd05d6fd6;hpb=41083396da355614f097802a60ddbd28a58d8413;p=tinyos-2.x.git diff --git a/tos/chips/cc2420/packet/CC2420PacketP.nc b/tos/chips/cc2420/packet/CC2420PacketP.nc index 0a730484..f0c2e384 100644 --- a/tos/chips/cc2420/packet/CC2420PacketP.nc +++ b/tos/chips/cc2420/packet/CC2420PacketP.nc @@ -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)