]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/cc2420/CC2420.h
Upstream commits to tos/chips/cc2420, Aug 7 2008 thru Jul 16 2009, except one.
[tinyos-2.x.git] / tos / chips / cc2420 / CC2420.h
index 788b700cf56abc583e54570dd28fc39d213e77bc..798107f0ebcb0367ee9e7822cfc8d1b5d0ca095c 100644 (file)
  * OF THE POSSIBILITY OF SUCH DAMAGE
  *
  * @author Jonathan Hui <jhui@archrock.com>
+ * @author David Moss
  * @version $Revision$ $Date$
  */
 
 #ifndef __CC2420_H__
 #define __CC2420_H__
 
-//#include "message.h"
-
 typedef uint8_t cc2420_status_t;
 
+#ifndef TFRAMES_ENABLED
+#define CC2420_IFRAME_TYPE
+#endif
+
+/**
+ * CC2420 header definition.
+ * 
+ * An I-frame (interoperability frame) header has an extra network 
+ * byte specified by 6LowPAN
+ * 
+ * Length = length of the header + payload of the packet, minus the size
+ *   of the length byte itself (1).  This is what allows for variable 
+ *   length packets.
+ * 
+ * FCF = Frame Control Field, defined in the 802.15.4 specs and the
+ *   CC2420 datasheet.
+ *
+ * DSN = Data Sequence Number, a number incremented for each packet sent
+ *   by a particular node.  This is used in acknowledging that packet, 
+ *   and also filtering out duplicate packets.
+ *
+ * DestPan = The destination PAN (personal area network) ID, so your 
+ *   network can sit side by side with another TinyOS network and not
+ *   interfere.
+ * 
+ * Dest = The destination address of this packet. 0xFFFF is the broadcast
+ *   address.
+ *
+ * Src = The local node ID that generated the message.
+ * 
+ * Network = The TinyOS network ID, for interoperability with other types
+ *   of 802.15.4 networks. 
+ * 
+ * Type = TinyOS AM type.  When you create a new AMSenderC(AM_MYMSG), 
+ *   the AM_MYMSG definition is the type of packet.
+ * 
+ * TOSH_DATA_LENGTH defaults to 28, it represents the maximum size of 
+ * the payload portion of the packet, and is specified in the 
+ * tos/types/message.h file.
+ *
+ * All of these fields will be filled in automatically by the radio stack 
+ * when you attempt to send a message.
+ */
 typedef nx_struct cc2420_header_t {
   nxle_uint8_t length;
   nxle_uint16_t fcf;
@@ -46,26 +88,56 @@ typedef nx_struct cc2420_header_t {
   nxle_uint16_t destpan;
   nxle_uint16_t dest;
   nxle_uint16_t src;
+  
+  /** I-Frame 6LowPAN interoperability byte */
+#ifdef CC2420_IFRAME_TYPE
+  nxle_uint8_t network;
+#endif
+
+#ifndef TINYOS_IP
   nxle_uint8_t type;
-} cc2420_header_t;
+#endif
 
+} cc2420_header_t;
+  
+/**
+ * CC2420 Packet Footer
+ */
 typedef nx_struct cc2420_footer_t {
 } cc2420_footer_t;
 
+/**
+ * CC2420 Packet metadata. Contains extra information about the message
+ * that will not be transmitted.
+ *
+ * Note that the first two bytes automatically take in the values of the
+ * FCS when the payload is full. Do not modify the first two bytes of metadata.
+ */
 typedef nx_struct cc2420_metadata_t {
-  nx_uint8_t tx_power;
   nx_uint8_t rssi;
   nx_uint8_t lqi;
+  nx_uint8_t tx_power;
   nx_bool crc;
   nx_bool ack;
-  nx_uint16_t time;
+  nx_bool timesync;
+  nx_uint32_t timestamp;
+  nx_uint16_t rxInterval;
+
+  /** Packet Link Metadata */
+#ifdef PACKET_LINK
+  nx_uint16_t maxRetries;
+  nx_uint16_t retryDelay;
+#endif
+
 } cc2420_metadata_t;
 
+
 typedef nx_struct cc2420_packet_t {
   cc2420_header_t packet;
   nx_uint8_t data[];
 } cc2420_packet_t;
 
+
 #ifndef TOSH_DATA_LENGTH
 #define TOSH_DATA_LENGTH 28
 #endif
@@ -78,6 +150,22 @@ typedef nx_struct cc2420_packet_t {
 #define CC2420_DEF_RFPOWER 31
 #endif
 
+/**
+ * Ideally, your receive history size should be equal to the number of
+ * RF neighbors your node will have
+ */
+#ifndef RECEIVE_HISTORY_SIZE
+#define RECEIVE_HISTORY_SIZE 4
+#endif
+
+/** 
+ * The 6LowPAN NALP ID for a TinyOS network is 63 (TEP 125).
+ */
+#ifndef TINYOS_6LOWPAN_NETWORK_ID
+#define TINYOS_6LOWPAN_NETWORK_ID 0x3f
+#endif
+
+
 enum {
   // size of the header not including the length byte
   MAC_HEADER_SIZE = sizeof( cc2420_header_t ) - 1,
@@ -85,6 +173,8 @@ enum {
   MAC_FOOTER_SIZE = sizeof( uint16_t ),
   // MDU
   MAC_PACKET_SIZE = MAC_HEADER_SIZE + TOSH_DATA_LENGTH + MAC_FOOTER_SIZE,
+
+  CC2420_SIZE = MAC_HEADER_SIZE + MAC_FOOTER_SIZE,
 };
 
 enum cc2420_enums {
@@ -92,7 +182,8 @@ enum cc2420_enums {
   CC2420_TIME_VREN = 20,          // jiffies
   CC2420_TIME_SYMBOL = 2,         // 2 symbols / jiffy
   CC2420_BACKOFF_PERIOD = ( 20 / CC2420_TIME_SYMBOL ), // symbols
-  CC2420_ACK_WAIT_DELAY = 128,    // jiffies
+  CC2420_MIN_BACKOFF = ( 20 / CC2420_TIME_SYMBOL ),  // platform specific?
+  CC2420_ACK_WAIT_DELAY = 256,    // jiffies
 };
 
 enum cc2420_status_enums {
@@ -118,7 +209,7 @@ enum cc2420_config_reg_enums {
   CC2420_SACK = 0x0a,
   CC2420_SACKPEND = 0x0b,
   CC2420_SRXDEC = 0x0c,
-  CC2420_SRXENC = 0x0d,
+  CC2420_STXENC = 0x0d,
   CC2420_SAES = 0x0e,
   CC2420_MAIN = 0x10,
   CC2420_MDMCTRL0 = 0x11,
@@ -316,4 +407,9 @@ enum cc2420_sfdmux_enums {
   CC2420_SFDMUX_XOSC16M_STABLE = 24,
 };
 
+enum
+{
+  CC2420_INVALID_TIMESTAMP  = 0x80000000L,
+};
+
 #endif