]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
test commit with parts of new stack
authorsdhsdh <sdhsdh>
Thu, 20 Aug 2009 01:37:44 +0000 (01:37 +0000)
committersdhsdh <sdhsdh>
Thu, 20 Aug 2009 01:37:44 +0000 (01:37 +0000)
tos/chips/cc2420/CC2420Ieee154MessageC.nc [new file with mode: 0644]
tos/chips/cc2420/CC2420Ieee154MessageP.nc [new file with mode: 0644]
tos/chips/cc2420/CC2420RadioC.nc [new file with mode: 0644]

diff --git a/tos/chips/cc2420/CC2420Ieee154MessageC.nc b/tos/chips/cc2420/CC2420Ieee154MessageC.nc
new file mode 100644 (file)
index 0000000..9d9965a
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * "Copyright (c) 2008 The Regents of the University  of California.
+ * All rights reserved."
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+/*                                                                     tab:4
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ * 
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * 
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * IEEE 802.15.4 layer for the cc2420.  Provides a simplistic 
+ *       link layer with dispatching on the 6lowpan "network" field
+ *
+ * @author Philip Levis
+ * @author David Moss
+ * @author Stephen Dawson-Haggerty
+ * @version $Revision$ $Date$
+ */
+
+#include "CC2420.h"
+#ifdef TFRAMES_ENABLED
+#error "The CC2420 Ieee 802.15.4 layer does not work with TFRAMES"
+#endif
+
+configuration CC2420Ieee154MessageC {
+  provides {
+    interface SplitControl;
+
+    interface Resource as SendResource[uint8_t clientId];
+    interface Ieee154Send;
+    interface Receive as Ieee154Receive;
+
+    interface Ieee154Packet;
+    interface Packet;
+
+    interface CC2420Packet;
+    interface PacketAcknowledgements;
+    interface LinkPacketMetadata;
+    interface LowPowerListening;
+    interface CC2420Config;
+    interface PacketLink;
+  }
+}
+implementation {
+
+  components CC2420RadioC as Radio;
+  components CC2420Ieee154MessageP as Msg;
+  components CC2420PacketC;
+  components CC2420ControlC;
+
+  SendResource = Radio.Resource;
+  Ieee154Receive = Radio.Receive;
+  Ieee154Send = Msg;
+  Ieee154Packet = Msg;
+  Packet = Msg;
+  CC2420Packet = CC2420PacketC;
+
+  SplitControl = Radio;
+  CC2420Packet = Radio;
+  PacketAcknowledgements = Radio;
+  LinkPacketMetadata = Radio;
+  LowPowerListening = Radio;
+  CC2420Config = CC2420ControlC;
+  PacketLink = Radio;
+
+  Msg.SubSend -> Radio.Send;
+
+  Msg.CC2420Packet -> CC2420PacketC;
+  Msg.CC2420PacketBody -> CC2420PacketC;
+  Msg.CC2420Config -> CC2420ControlC;
+
+}
diff --git a/tos/chips/cc2420/CC2420Ieee154MessageP.nc b/tos/chips/cc2420/CC2420Ieee154MessageP.nc
new file mode 100644 (file)
index 0000000..d1abc75
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * "Copyright (c) 2008 The Regents of the University  of California.
+ * All rights reserved."
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ */
+/*                                                                     tab:4
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ * 
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * 
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+
+/**
+ *
+ * @author Stephen Dawson-Haggerty
+ * @version $Revision$ $Date$
+ */
+#include "CC2420.h"
+#include "IEEE802154.h"
+
+module CC2420Ieee154MessageP {
+
+  provides {
+    interface Ieee154Send;
+    interface Ieee154Packet;
+    interface Packet;
+  }
+  
+  uses {
+    interface Send as SubSend;
+    interface CC2420Packet;
+    interface CC2420PacketBody;
+    interface CC2420Config;
+  }
+}
+implementation {
+
+  /***************** Ieee154Send Commands ****************/
+  command error_t Ieee154Send.send(ieee154_saddr_t addr,
+                                   message_t* msg,
+                                   uint8_t len) {
+    cc2420_header_t* header = call CC2420PacketBody.getHeader( msg );
+    header->dest = addr;
+    header->destpan = call CC2420Config.getPanAddr();
+    header->src = call CC2420Config.getShortAddr();
+
+    return call SubSend.send( msg, len );
+  }
+
+  command error_t Ieee154Send.cancel(message_t* msg) {
+    return call SubSend.cancel(msg);
+  }
+
+  command uint8_t Ieee154Send.maxPayloadLength() {
+    return call Packet.maxPayloadLength();
+  }
+
+  command void* Ieee154Send.getPayload(message_t* m, uint8_t len) {
+    return call Packet.getPayload(m, len);
+  }
+
+  /***************** Ieee154Packet Commands ****************/
+  command ieee154_saddr_t Ieee154Packet.address() {
+    return call CC2420Config.getShortAddr();
+  }
+  command ieee154_saddr_t Ieee154Packet.destination(message_t* msg) {
+    cc2420_header_t* header = call CC2420PacketBody.getHeader(msg);
+    return header->dest;
+  }
+  command ieee154_saddr_t Ieee154Packet.source(message_t* msg) {
+    cc2420_header_t* header = call CC2420PacketBody.getHeader(msg);
+    return header->src;
+  }
+
+  command void Ieee154Packet.setDestination(message_t* msg, ieee154_saddr_t addr) {
+    cc2420_header_t* header = call CC2420PacketBody.getHeader(msg);
+    header->dest = addr;
+  }
+
+  command void Ieee154Packet.setSource(message_t* msg, ieee154_saddr_t addr) {
+    cc2420_header_t* header = call CC2420PacketBody.getHeader(msg);
+    header->src = addr;
+  }
+
+  command bool Ieee154Packet.isForMe(message_t* msg) {
+    return (call Ieee154Packet.destination(msg) == call Ieee154Packet.address() ||
+           call Ieee154Packet.destination(msg) == IEEE154_BROADCAST_ADDR);
+  }
+
+  command ieee154_panid_t Ieee154Packet.pan(message_t* msg) {
+    return (call CC2420PacketBody.getHeader(msg))->destpan;
+  }
+
+  command void Ieee154Packet.setPan(message_t* msg, ieee154_panid_t grp) {
+    // Overridden intentionally when we send()
+    (call CC2420PacketBody.getHeader(msg))->destpan = grp;
+  }
+
+  command ieee154_panid_t Ieee154Packet.localPan() {
+    return call CC2420Config.getPanAddr();
+  }
+
+
+  /***************** Packet Commands ****************/
+  command void Packet.clear(message_t* msg) {
+    memset(call CC2420PacketBody.getHeader(msg), sizeof(cc2420_header_t) - AM_OVERHEAD, 0);
+    memset(call CC2420PacketBody.getMetadata(msg), sizeof(cc2420_metadata_t), 0);
+  }
+  
+  command uint8_t Packet.payloadLength(message_t* msg) {
+    return (call CC2420PacketBody.getHeader(msg))->length - CC2420_SIZE;
+  }
+  
+  command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
+    (call CC2420PacketBody.getHeader(msg))->length  = len + CC2420_SIZE;
+  }
+  
+  command uint8_t Packet.maxPayloadLength() {
+    return TOSH_DATA_LENGTH + AM_OVERHEAD;
+  }
+  
+  command void* Packet.getPayload(message_t* msg, uint8_t len) {
+        return call SubSend.getPayload( msg, len );
+  }
+
+  
+  /***************** SubSend Events ****************/
+  event void SubSend.sendDone(message_t* msg, error_t result) {
+    signal Ieee154Send.sendDone(msg, result);
+  }
+
+  /***************** CC2420Config Events ****************/
+  event void CC2420Config.syncDone( error_t error ) {
+  }
+
+  default event void Ieee154Send.sendDone(message_t *msg, error_t e) {
+
+  }
+}
diff --git a/tos/chips/cc2420/CC2420RadioC.nc b/tos/chips/cc2420/CC2420RadioC.nc
new file mode 100644 (file)
index 0000000..a30c281
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ * 
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * 
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * Radio wiring for the CC2420.  This layer seperates the common
+ * wiring of the lower-layer components of the CC2420 stack and makes
+ * them available to clients like the AM stack and the IEEE802.15.4
+ * stack.
+ *
+ * This component provides the highest-level internal interface to
+ * other components of the CC2420 stack.
+ *
+ * @author Philip Levis
+ * @author David Moss
+ * @author Stephen Dawson-Haggerty
+ * @version $Revision$ $Date$
+ */
+
+#include "CC2420.h"
+
+configuration CC2420RadioC {
+  provides {
+    interface SplitControl;
+
+    interface Resource[uint8_t clientId];
+    interface Send;
+    interface Receive;
+
+    interface Send as ActiveSend;
+    interface Receive as ActiveReceive;
+
+    interface CC2420Packet;
+    interface PacketAcknowledgements;
+    interface LinkPacketMetadata;
+    interface LowPowerListening;
+    interface PacketLink;
+
+  }
+}
+implementation {
+
+  components CC2420CsmaC as CsmaC;
+  components UniqueSendC;
+  components UniqueReceiveC;
+  components CC2420TinyosNetworkC;
+  components CC2420PacketC;
+  components CC2420ControlC;
+  
+#if defined(LOW_POWER_LISTENING) || defined(ACK_LOW_POWER_LISTENING)
+  components DefaultLplC as LplC;
+#else
+  components DummyLplC as LplC;
+#endif
+
+#if defined(PACKET_LINK)
+  components PacketLinkC as LinkC;
+#else
+  components PacketLinkDummyC as LinkC;
+#endif
+  
+  PacketLink = LinkC;
+  LowPowerListening = LplC;
+  CC2420Packet = CC2420PacketC;
+  PacketAcknowledgements = CC2420PacketC;
+  LinkPacketMetadata = CC2420PacketC;
+  
+  Resource = CC2420TinyosNetworkC;
+  Send = CC2420TinyosNetworkC.Send;
+  Receive = CC2420TinyosNetworkC.Receive;
+  ActiveSend = CC2420TinyosNetworkC.ActiveSend;
+  ActiveReceive = CC2420TinyosNetworkC.ActiveReceive;
+
+  // SplitControl Layers
+  SplitControl = LplC;
+  LplC.SubControl -> CsmaC;
+  
+  // Send Layers
+  CC2420TinyosNetworkC.SubSend -> UniqueSendC;
+  UniqueSendC.SubSend -> LinkC;
+  LinkC.SubSend -> LplC.Send;
+  LplC.SubSend -> CsmaC;
+  
+  // Receive Layers
+  CC2420TinyosNetworkC.SubReceive -> LplC;
+  LplC.SubReceive -> UniqueReceiveC.Receive;
+  UniqueReceiveC.SubReceive ->  CsmaC;
+  
+}