[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/cc1000 CC1000ActiveMessageC.nc, 1.8, 1.9 CC1000CsmaRadioC.nc, 1.8, 1.9 CC1000Msg.h, 1.6, 1.7 CC1000SendReceiveP.nc, 1.13, 1.14

Marco Langerwisch devdj at users.sourceforge.net
Mon Sep 1 10:47:35 PDT 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/cc1000
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16808/tos/chips/cc1000

Modified Files:
	CC1000ActiveMessageC.nc CC1000CsmaRadioC.nc CC1000Msg.h 
	CC1000SendReceiveP.nc 
Log Message:
Recommited changes after bugfixing in tos/platforms/mica/Counter32khz32C.nc


Index: CC1000ActiveMessageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/cc1000/CC1000ActiveMessageC.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** CC1000ActiveMessageC.nc	1 Sep 2008 08:28:14 -0000	1.8
--- CC1000ActiveMessageC.nc	1 Sep 2008 17:47:33 -0000	1.9
***************
*** 1,4 ****
- // $Id$
- 
  /*
   * "Copyright (c) 2004-2005 The Regents of the University  of California.  
--- 1,2 ----
***************
*** 39,43 ****
   * 
   * @author Philip Levis
!  * @date June 19 2005
   */
  
--- 37,41 ----
   * 
   * @author Philip Levis
!  * @author Marco Langerwisch (Packet timestamping)
   */
  
***************
*** 52,55 ****
--- 50,57 ----
      interface PacketAcknowledgements;
      interface LinkPacketMetadata;
+ 
+     interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+     interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+     interface PacketTimeSyncOffset;
    }
  }
***************
*** 74,76 ****
--- 76,81 ----
    AM.Packet     -> Radio;
    
+   PacketTimeStamp32khz = Radio;
+   PacketTimeStampMilli = Radio;
+   PacketTimeSyncOffset = Radio;
  }

Index: CC1000CsmaRadioC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/cc1000/CC1000CsmaRadioC.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** CC1000CsmaRadioC.nc	1 Sep 2008 08:28:59 -0000	1.8
--- CC1000CsmaRadioC.nc	1 Sep 2008 17:47:33 -0000	1.9
***************
*** 1,3 ****
! /* $Id$
   * "Copyright (c) 2000-2005 The Regents of the University  of California.  
   * All rights reserved.
--- 1,3 ----
! /*
   * "Copyright (c) 2000-2005 The Regents of the University  of California.  
   * All rights reserved.
***************
*** 45,48 ****
--- 45,49 ----
   * @author Joe Polastre
   * @author David Gay
+  * @author Marco Langerwisch (Packet timestamping)
   */
  
***************
*** 56,67 ****
      interface Receive;
  
!     interface Packet;    
      interface CsmaControl;
      interface CsmaBackoff;
-     interface RadioTimeStamping;
      interface PacketAcknowledgements;
      interface LinkPacketMetadata;
!     
      interface LowPowerListening;
    }
  }
--- 57,71 ----
      interface Receive;
  
!     interface Packet;
      interface CsmaControl;
      interface CsmaBackoff;
      interface PacketAcknowledgements;
      interface LinkPacketMetadata;
! 
      interface LowPowerListening;
+ 
+     interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+     interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+     interface PacketTimeSyncOffset;
    }
  }
***************
*** 87,94 ****
    CsmaBackoff = Csma;
    LowPowerListening = Csma;
-   RadioTimeStamping = SendReceive;
    PacketAcknowledgements = SendReceive;
    LinkPacketMetadata = SendReceive;
!   
    Csma.CC1000Control -> Control;
    Csma.Random -> RandomC;
--- 91,97 ----
    CsmaBackoff = Csma;
    LowPowerListening = Csma;
    PacketAcknowledgements = SendReceive;
    LinkPacketMetadata = SendReceive;
! 
    Csma.CC1000Control -> Control;
    Csma.Random -> RandomC;
***************
*** 104,108 ****
    SendReceive.RssiRx -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
    SendReceive.CC1000Squelch -> Squelch;
!   
    Csma.RssiNoiseFloor -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
    Csma.RssiCheckChannel -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
--- 107,111 ----
    SendReceive.RssiRx -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
    SendReceive.CC1000Squelch -> Squelch;
! 
    Csma.RssiNoiseFloor -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
    Csma.RssiCheckChannel -> Rssi.Rssi[unique(UQ_CC1000_RSSI)];
***************
*** 115,117 ****
--- 118,132 ----
    Control.CC -> Hpl;
    Control.BusyWait -> BusyWaitMicroC;
+ 
+   PacketTimeStamp32khz = SendReceive;
+   PacketTimeStampMilli = SendReceive;
+   PacketTimeSyncOffset = SendReceive;
+ 
+   components Counter32khz32C, new CounterToLocalTimeC(T32khz);
+   CounterToLocalTimeC.Counter -> Counter32khz32C;
+   SendReceive.LocalTime32khz -> CounterToLocalTimeC;
+ 
+   //DummyTimer is introduced to compile apps that use no timers
+   components HilTimerMilliC, new TimerMilliC() as DummyTimer;
+   SendReceive.LocalTimeMilli -> HilTimerMilliC;
  }

Index: CC1000Msg.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/cc1000/CC1000Msg.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** CC1000Msg.h	1 Sep 2008 08:26:45 -0000	1.6
--- CC1000Msg.h	1 Sep 2008 17:47:33 -0000	1.7
***************
*** 30,37 ****
    nx_int16_t strength_or_preamble; /* negative when used for preamble length */
    nx_uint8_t metadataBits;
!   nx_uint16_t time;
    nx_uint8_t sendSecurityMode;
    nx_uint8_t receiveSecurityMode;  
  } cc1000_metadata_t;
  
  #endif
--- 30,43 ----
    nx_int16_t strength_or_preamble; /* negative when used for preamble length */
    nx_uint8_t metadataBits;
!   nx_bool timesync;
!   nx_uint32_t timestamp;
    nx_uint8_t sendSecurityMode;
    nx_uint8_t receiveSecurityMode;  
  } cc1000_metadata_t;
  
+ enum
+ {
+   CC1000_INVALID_TIMESTAMP  = 0x80000000L,
+ };
+ 
  #endif

Index: CC1000SendReceiveP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/cc1000/CC1000SendReceiveP.nc,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** CC1000SendReceiveP.nc	1 Sep 2008 08:28:38 -0000	1.13
--- CC1000SendReceiveP.nc	1 Sep 2008 17:47:33 -0000	1.14
***************
*** 1,4 ****
- // $Id$
- 
  /*
   * "Copyright (c) 2000-2005 The Regents of the University  of California.  
--- 1,2 ----
***************
*** 33,36 ****
--- 31,35 ----
  #include "CC1000Const.h"
  #include "Timer.h"
+ #include "CC1000TimeSyncMessage.h"
  
  /**
***************
*** 51,54 ****
--- 50,54 ----
   * @author Joe Polastre
   * @author David Gay
+  * @author Marco Langerwisch (Packet timestamping)
   */
    
***************
*** 59,67 ****
      interface Send;
      interface Receive;
-     interface RadioTimeStamping;
      interface Packet;
      interface ByteRadio;
      interface PacketAcknowledgements;
      interface LinkPacketMetadata;
    }
    uses {
--- 59,70 ----
      interface Send;
      interface Receive;
      interface Packet;
      interface ByteRadio;
      interface PacketAcknowledgements;
      interface LinkPacketMetadata;
+ 
+     interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+     interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+     interface PacketTimeSyncOffset;
    }
    uses {
***************
*** 72,79 ****
--- 75,93 ----
      interface ReadNow<uint16_t> as RssiRx;
      async command am_addr_t amAddress();
+ 
+     interface LocalTime<T32khz> as LocalTime32khz;
+     interface LocalTime<TMilli> as LocalTimeMilli;
    }
  }
  implementation 
  {
+ #ifdef PLATFORM_MICA2
+   // estimated calibration, 19.2 Kbps data, Manchester Encoding, time in jiffies (32768 Hz)
+   static const int8_t BIT_CORRECTION[8] = { 27, 28, 30, 32, 34, 36, 38, 40 };
+ #else
+   // other platforms not calibrated yet
+   static const uint8_t BIT_CORRECTION[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ #endif
+ 
    enum {
      OFF_STATE,
***************
*** 258,265 ****
--- 272,283 ----
  	else {
  	  cc1000_header_t *header = getHeader(msg);
+           cc1000_metadata_t *metadata = getMetadata(msg);
  
  	  f.txBusy = TRUE;
  	  header->length = len;
  	  txBufPtr = msg;
+ 
+           metadata->timesync = FALSE;
+           metadata->timestamp = CC1000_INVALID_TIMESTAMP;
  	}
        }
***************
*** 300,304 ****
      nextTxByte = SYNC_BYTE2;
      enterTxDataState();
-     signal RadioTimeStamping.transmittedSFD(0, txBufPtr); 
    }
  
--- 318,321 ----
***************
*** 306,309 ****
--- 323,338 ----
      cc1000_header_t *txHeader = getHeader(txBufPtr);
      sendNextByte();
+ 
+     if (nextTxByte == SYNC_BYTE2) {
+       // SYNC_WORD has just been sent
+       uint32_t time32khz = call LocalTime32khz.get();
+       call PacketTimeStamp32khz.set(txBufPtr, time32khz);
+ 
+       if (call PacketTimeSyncOffset.isSet(txBufPtr)) {
+         timesync_radio_t *timesync = (timesync_radio_t*)((void*)txBufPtr + call PacketTimeSyncOffset.get(txBufPtr));
+         // set timesync event time as the offset between the event time and the SFD interrupt time (TEP 133)
+         *timesync  -= time32khz;
+       }
+     }
      
      if (count < txHeader->length + sizeof(message_header_t))
***************
*** 446,452 ****
--- 475,484 ----
        {
  	// TODO: Modify to be tolerant of bad bits in the preamble...
+         uint32_t time;
  	uint16_t tmp;
  	uint8_t i;
  
+         time = call LocalTime32khz.get();
+ 
  	// bit shift the data in with previous sample to find sync
  	tmp = rxShiftBuf;
***************
*** 465,469 ****
  		signal ByteRadio.rx();
  		f.rxBitOffset = 7 - i;
! 		signal RadioTimeStamping.receivedSFD(0);
  		call RssiRx.read();
  	      }
--- 497,504 ----
  		signal ByteRadio.rx();
  		f.rxBitOffset = 7 - i;
!                 // correct receive time according to bit offset and set timestamp
!                 time -= BIT_CORRECTION[f.rxBitOffset];
!                 call PacketTimeStamp32khz.set(rxBufPtr, time);
! 
  		call RssiRx.read();
  	      }
***************
*** 678,685 ****
      return getMetadata(msg)->metadataBits & CC1000_WHITE_BIT;
    }
!   
!   // Default events for radio send/receive coordinators do nothing.
!   // Be very careful using these, or you'll break the stack.
!   default async event void RadioTimeStamping.transmittedSFD(uint16_t time, message_t *msgBuff) { }
!   default async event void RadioTimeStamping.receivedSFD(uint16_t time) { }
  }
--- 713,782 ----
      return getMetadata(msg)->metadataBits & CC1000_WHITE_BIT;
    }
! 
!   /***************** PacketTimeStamp32khz Commands ****************/
!   async command bool PacketTimeStamp32khz.isValid(message_t* msg)
!   {
!     return (getMetadata(msg)->timestamp != CC1000_INVALID_TIMESTAMP);
!   }
! 
!   async command uint32_t PacketTimeStamp32khz.timestamp(message_t* msg)
!   {
!     return getMetadata(msg)->timestamp;
!   }
! 
!   async command void PacketTimeStamp32khz.clear(message_t* msg)
!   {
!     getMetadata(msg)->timesync = FALSE;
!     getMetadata(msg)->timestamp = CC1000_INVALID_TIMESTAMP;
!   }
! 
!   async command void PacketTimeStamp32khz.set(message_t* msg, uint32_t value)
!   {
!     getMetadata(msg)->timestamp = value;
!   }
! 
!   /***************** PacketTimeStampMilli Commands ****************/
!   // over the air value is always T32khz
!   async command bool PacketTimeStampMilli.isValid(message_t* msg)
!   {
!     return call PacketTimeStamp32khz.isValid(msg);
!   }
! 
!   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();
!   }
! 
!   async command void PacketTimeStampMilli.clear(message_t* msg)
!   {
!     call PacketTimeStamp32khz.clear(msg);
!   }
! 
!   async command void PacketTimeStampMilli.set(message_t* msg, uint32_t value)
!   {
!     int32_t offset = (value - call LocalTimeMilli.get()) << 5;
!     call PacketTimeStamp32khz.set(msg, offset + call LocalTime32khz.get());
!   }
! 
!   /*----------------- PacketTimeSyncOffset -----------------*/
!   async command bool PacketTimeSyncOffset.isSet(message_t* msg)
!   {
!     return getMetadata(msg)->timesync;
!   }
! 
!   async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
!   {
!     return sizeof(cc1000_header_t) + getHeader(msg)->length - sizeof(timesync_radio_t);
!   }
! 
!   async command void PacketTimeSyncOffset.set(message_t* msg)
!   {
!     getMetadata(msg)->timesync = TRUE;
!   }
! 
!   async command void PacketTimeSyncOffset.cancel(message_t* msg)
!   {
!     getMetadata(msg)->timesync = FALSE;
!   }
  }



More information about the Tinyos-2-commits mailing list