]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
adding support for timesync/timestamping interfaces (teps 132,133)
authorkusy <kusy>
Tue, 17 Jun 2008 07:28:24 +0000 (07:28 +0000)
committerkusy <kusy>
Tue, 17 Jun 2008 07:28:24 +0000 (07:28 +0000)
21 files changed:
tos/chips/cc2420/CC2420.h
tos/chips/cc2420/CC2420TimeSyncMessage.h [new file with mode: 0644]
tos/chips/cc2420/CC2420TimeSyncMessageC.nc [new file with mode: 0644]
tos/chips/cc2420/CC2420TimeSyncMessageP.nc [new file with mode: 0644]
tos/chips/cc2420/csma/CC2420CsmaP.nc
tos/chips/cc2420/interfaces/CC2420Receive.nc
tos/chips/cc2420/interfaces/PacketTimeSyncOffset.nc [new file with mode: 0644]
tos/chips/cc2420/packet/CC2420PacketC.nc
tos/chips/cc2420/packet/CC2420PacketP.nc [new file with mode: 0644]
tos/chips/cc2420/receive/CC2420ReceiveC.nc
tos/chips/cc2420/receive/CC2420ReceiveP.nc
tos/chips/cc2420/transmit/CC2420TransmitC.nc
tos/chips/cc2420/transmit/CC2420TransmitP.nc
tos/platforms/intelmote2/ActiveMessageC.nc
tos/platforms/intelmote2/TimeSyncMessageC.nc [new file with mode: 0644]
tos/platforms/micaz/ActiveMessageC.nc
tos/platforms/micaz/TimeSyncMessageC.nc [new file with mode: 0644]
tos/platforms/shimmer/ActiveMessageC.nc
tos/platforms/shimmer/TimeSyncMessageC.nc [new file with mode: 0644]
tos/platforms/telosa/ActiveMessageC.nc
tos/platforms/telosa/TimeSyncMessageC.nc [new file with mode: 0644]

index a3413ec2d061721657aa2ac0ee963e2ab0e734a3..2418c3f17de303cf115661e23520071975a6ace8 100644 (file)
@@ -84,7 +84,8 @@ typedef nx_struct cc2420_metadata_t {
   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 */
@@ -369,4 +370,9 @@ enum cc2420_sfdmux_enums {
   CC2420_SFDMUX_XOSC16M_STABLE = 24,
 };
 
+enum
+{
+  CC2420_INVALID_TIMESTAMP  = 0x80000000L,
+};
+
 #endif
diff --git a/tos/chips/cc2420/CC2420TimeSyncMessage.h b/tos/chips/cc2420/CC2420TimeSyncMessage.h
new file mode 100644 (file)
index 0000000..a744fd3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+#ifndef __TIMESYNCMESSAGE_H__
+#define __TIMESYNCMESSAGE_H__
+
+// this value is sent in the air
+typedef nx_uint32_t timesync_radio_t;
+
+#endif//__TIMESYNCMESSAGE_H__
diff --git a/tos/chips/cc2420/CC2420TimeSyncMessageC.nc b/tos/chips/cc2420/CC2420TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..745bd08
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+/**
+ * The Active Message layer for the CC2420 radio with timesync support. This
+ * configuration is just layer above CC2420ActiveMessageC that supports
+ * TimeSyncPacket and TimeSyncAMSend interfaces (TEP 133)
+ *
+ * @author: Miklos Maroti
+ * @author: Brano Kusy (CC2420 port)
+ */
+
+#include <Timer.h>
+#include <AM.h>
+
+configuration CC2420TimeSyncMessageC
+{
+    provides
+    {
+        interface SplitControl;
+        interface Receive[am_id_t id];
+        interface Receive as Snoop[am_id_t id];
+        interface Packet;
+        interface AMPacket;
+
+        interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[am_id_t id];
+        interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+
+        interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+        interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+    }
+}
+
+implementation
+{
+        components CC2420TimeSyncMessageP, CC2420ActiveMessageC, CC2420PacketC, LedsC;
+
+        TimeSyncAMSend32khz = CC2420TimeSyncMessageP;
+        TimeSyncPacket32khz = CC2420TimeSyncMessageP;
+
+        TimeSyncAMSendMilli = CC2420TimeSyncMessageP;
+        TimeSyncPacketMilli = CC2420TimeSyncMessageP;
+
+        Packet = CC2420TimeSyncMessageP;
+        CC2420TimeSyncMessageP.SubSend -> CC2420ActiveMessageC.AMSend;
+        CC2420TimeSyncMessageP.SubPacket -> CC2420ActiveMessageC.Packet;
+
+        CC2420TimeSyncMessageP.PacketTimeStamp32khz -> CC2420PacketC;
+        CC2420TimeSyncMessageP.PacketTimeStampMilli -> CC2420PacketC;
+        CC2420TimeSyncMessageP.PacketTimeSyncOffset -> CC2420PacketC;
+        components Counter32khz32C, new CounterToLocalTimeC(T32khz) as LocalTime32khzC, LocalTimeMilliC;
+        LocalTime32khzC.Counter -> Counter32khz32C;
+        CC2420TimeSyncMessageP.LocalTime32khz -> LocalTime32khzC;
+        CC2420TimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC;
+        CC2420TimeSyncMessageP.Leds -> LedsC;
+
+        SplitControl = CC2420ActiveMessageC;
+        Receive = CC2420ActiveMessageC.Receive;
+        Snoop = CC2420ActiveMessageC.Snoop;
+        AMPacket = CC2420ActiveMessageC;
+}
diff --git a/tos/chips/cc2420/CC2420TimeSyncMessageP.nc b/tos/chips/cc2420/CC2420TimeSyncMessageP.nc
new file mode 100644 (file)
index 0000000..a4e1157
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * @author: Miklos Maroti
+ * @author: Brano Kusy (CC2420 port)
+ */
+#include "CC2420TimeSyncMessage.h"
+
+module CC2420TimeSyncMessageP
+{
+    provides
+    {
+        interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[uint8_t id];
+        interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[uint8_t id];
+        interface Packet;
+
+        interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+        interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+    }
+
+    uses
+    {
+        interface AMSend as SubSend[uint8_t id];
+        interface Packet as SubPacket;
+
+        interface PacketTimeStamp<T32khz,uint32_t> as PacketTimeStamp32khz;
+        interface PacketTimeStamp<TMilli,uint32_t> as PacketTimeStampMilli;
+        interface PacketTimeSyncOffset;
+
+        interface LocalTime<T32khz> as LocalTime32khz;
+        interface LocalTime<TMilli> as LocalTimeMilli;
+        interface Leds;
+    }
+}
+
+implementation
+{
+    // TODO: change the Packet.payloadLength and Packet.maxPayloadLength commands to async
+    inline void* getFooter(message_t* msg)
+    {
+        // we use the payload length that we export (the smaller one)
+        return msg->data + call Packet.payloadLength(msg);
+    }
+
+/*----------------- Packet -----------------*/
+    command void Packet.clear(message_t* msg)
+    {
+        call PacketTimeSyncOffset.cancel(msg);
+        call SubPacket.clear(msg);
+    }
+
+    command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+    {
+        call SubPacket.setPayloadLength(msg, len + sizeof(timesync_radio_t));
+    }
+
+    command uint8_t Packet.payloadLength(message_t* msg)
+    {
+        return call SubPacket.payloadLength(msg) - sizeof(timesync_radio_t);
+    }
+
+    command uint8_t Packet.maxPayloadLength()
+    {
+        return call SubPacket.maxPayloadLength() - sizeof(timesync_radio_t);
+    }
+
+    command void* Packet.getPayload(message_t* msg, uint8_t len)
+    {
+        return call SubPacket.getPayload(msg, len + sizeof(timesync_radio_t));
+    }
+
+/*----------------- TimeSyncAMSend32khz -----------------*/
+    command error_t TimeSyncAMSend32khz.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
+    {
+        error_t err;
+        void * timesync = msg->data + len;
+        *(timesync_radio_t*)timesync = event_time;
+
+        err = call SubSend.send[id](addr, msg, len + sizeof(timesync_radio_t));
+        call PacketTimeSyncOffset.set(msg);
+        return err;
+    }
+
+    command error_t TimeSyncAMSend32khz.cancel[am_id_t id](message_t* msg)
+    {
+        call PacketTimeSyncOffset.cancel(msg);
+        return call SubSend.cancel[id](msg);
+    }
+
+    default event void TimeSyncAMSend32khz.sendDone[am_id_t id](message_t* msg, error_t error) {}
+
+    command uint8_t TimeSyncAMSend32khz.maxPayloadLength[am_id_t id]()
+    {
+        return call SubSend.maxPayloadLength[id]() - sizeof(timesync_radio_t);
+    }
+
+    command void* TimeSyncAMSend32khz.getPayload[am_id_t id](message_t* msg, uint8_t len)
+    {
+        return call SubSend.getPayload[id](msg, len + sizeof(timesync_radio_t));
+    }
+
+/*----------------- TimeSyncAMSendMilli -----------------*/
+    command error_t TimeSyncAMSendMilli.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
+    {
+        // compute elapsed time in millisecond
+        event_time = ((event_time - call LocalTimeMilli.get()) << 5) + call LocalTime32khz.get();
+        return call TimeSyncAMSend32khz.send[id](addr, msg, len, event_time);
+    }
+
+    command error_t TimeSyncAMSendMilli.cancel[am_id_t id](message_t* msg)
+    {
+        return call TimeSyncAMSend32khz.cancel[id](msg);
+    }
+
+    default event void TimeSyncAMSendMilli.sendDone[am_id_t id](message_t* msg, error_t error){}
+
+    command uint8_t TimeSyncAMSendMilli.maxPayloadLength[am_id_t id]()
+    {
+        return call TimeSyncAMSend32khz.maxPayloadLength[id]();
+    }
+
+    command void* TimeSyncAMSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len)
+    {
+        return call TimeSyncAMSend32khz.getPayload[id](msg, len);
+    }
+
+/*----------------- SubSend.sendDone -------------------*/
+    event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error)
+    {
+        signal TimeSyncAMSend32khz.sendDone[id](msg, error);
+        signal TimeSyncAMSendMilli.sendDone[id](msg, error);
+    }
+
+/*----------------- TimeSyncPacket32khz -----------------*/
+    command bool TimeSyncPacket32khz.isValid(message_t* msg)
+    {
+        timesync_radio_t* timesync = getFooter(msg);
+        return call PacketTimeStamp32khz.isValid(msg) && *timesync != CC2420_INVALID_TIMESTAMP;
+    }
+
+    command uint32_t TimeSyncPacket32khz.eventTime(message_t* msg)
+    {
+        timesync_radio_t* timesync = getFooter(msg);
+
+        return (uint32_t)(*timesync) + call PacketTimeStamp32khz.timestamp(msg);
+    }
+
+/*----------------- TimeSyncPacketMilli -----------------*/
+    command bool TimeSyncPacketMilli.isValid(message_t* msg)
+    {
+        timesync_radio_t* timesync = getFooter(msg);
+        return call PacketTimeStampMilli.isValid(msg) && *timesync != CC2420_INVALID_TIMESTAMP;
+    }
+
+    command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg)
+    {
+        timesync_radio_t* timesync = getFooter(msg);
+        return ((int32_t)(*timesync) >> 5) + call PacketTimeStampMilli.timestamp(msg);
+    }
+}
index 284313ee0d09806642174f5a7e6ad64238f33be1..df6ffb25cec5260ef3d602d8ff3ff1d984085440 100644 (file)
@@ -144,8 +144,9 @@ implementation {
     metadata->ack = FALSE;
     metadata->rssi = 0;
     metadata->lqi = 0;
-    metadata->time = 0;
-    
+    metadata->timesync = FALSE;
+    metadata->timestamp = CC2420_INVALID_TIMESTAMP;
+
     ccaOn = TRUE;
     signal RadioBackoff.requestCca(m_msg);
 
index 257f942ade524ab4ae4f8f5a407b551cb6099aac..77da841960f64b1c88b76185a29deb24135c45aa 100644 (file)
@@ -46,7 +46,7 @@ interface CC2420Receive {
    *
    * @param time at which the capture happened.
    */
-  async command void sfd( uint16_t time );
+  async command void sfd( uint32_t time );
 
   /**
    * Notification that the packet has been dropped by the radio
diff --git a/tos/chips/cc2420/interfaces/PacketTimeSyncOffset.nc b/tos/chips/cc2420/interfaces/PacketTimeSyncOffset.nc
new file mode 100644 (file)
index 0000000..0295069
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+interface PacketTimeSyncOffset
+{
+    /**
+     * Returns TRUE if the value is set for this message.
+     */
+    async command bool isSet(message_t* msg);
+
+    /**
+     * Returns the stored value of this field in the message. If the
+     * value is not set, then the returned value is undefined.
+     */
+    async command uint8_t get(message_t* msg);
+
+    /**
+     * Sets the isSet false to TRUE and the time stamp value to the
+     * specified value.
+     */
+    async command void set(message_t* msg);
+
+    /**
+     * Cancels any pending requests.
+     */
+    async command void cancel(message_t* msg);
+}
index 8eeb8a629aba06dce923c7b886395d6bce8399a3..51bc23c94e5ea17e3f04ea519019c433f8f848f2 100644 (file)
  * @author Chad Metcalf
  */
 
-#include "IEEE802154.h"
-#include "message.h"
-
-module CC2420PacketC {
+configuration CC2420PacketC {
 
   provides {
     interface CC2420Packet;
     interface PacketAcknowledgements as Acks;
     interface CC2420PacketBody;
     interface LinkPacketMetadata;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+    interface PacketTimeSyncOffset;
   }
 
 }
 
 implementation {
-
-
-  /***************** PacketAcknowledgement Commands ****************/
-  async command error_t Acks.requestAck( message_t* p_msg ) {
-    (call CC2420PacketBody.getHeader( p_msg ))->fcf |= 1 << IEEE154_FCF_ACK_REQ;
-    return SUCCESS;
-  }
-
-  async command error_t Acks.noAck( message_t* p_msg ) {
-    (call CC2420PacketBody.getHeader( p_msg ))->fcf &= ~(1 << IEEE154_FCF_ACK_REQ);
-    return SUCCESS;
-  }
-
-  async command bool Acks.wasAcked( message_t* p_msg ) {
-    return (call CC2420PacketBody.getMetadata( p_msg ))->ack;
-  }
-
-  /***************** CC2420Packet Commands ****************/
-  async command void CC2420Packet.setPower( message_t* p_msg, uint8_t power ) {
-    if ( power > 31 )
-      power = 31;
-    (call CC2420PacketBody.getMetadata( p_msg ))->tx_power = power;
-  }
-
-  async command uint8_t CC2420Packet.getPower( message_t* p_msg ) {
-    return (call CC2420PacketBody.getMetadata( p_msg ))->tx_power;
-  }
-   
-  async command int8_t CC2420Packet.getRssi( message_t* p_msg ) {
-    return (call CC2420PacketBody.getMetadata( p_msg ))->rssi;
-  }
-
-  async command uint8_t CC2420Packet.getLqi( message_t* p_msg ) {
-    return (call CC2420PacketBody.getMetadata( p_msg ))->lqi;
-  }
-
-  /***************** CC2420PacketBody Commands ****************/
-  async command cc2420_header_t * ONE CC2420PacketBody.getHeader( message_t* ONE msg ) {
-    return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t, data) - sizeof( cc2420_header_t ));
-  }
-
-  async command cc2420_metadata_t *CC2420PacketBody.getMetadata( message_t* msg ) {
-    return (cc2420_metadata_t*)msg->metadata;
-  }
-
-  async command bool LinkPacketMetadata.highChannelQuality(message_t* msg) {
-    return call CC2420Packet.getLqi(msg) > 105;
-  }
+  components CC2420PacketP;
+  CC2420Packet         = CC2420PacketP;
+  Acks                 = CC2420PacketP;
+  CC2420PacketBody     = CC2420PacketP;
+  LinkPacketMetadata   = CC2420PacketP;
+  PacketTimeStamp32khz = CC2420PacketP;
+  PacketTimeStampMilli = CC2420PacketP;
+  PacketTimeSyncOffset = CC2420PacketP;
+
+  components CC2420ActiveMessageC;
+  CC2420PacketP.Packet -> CC2420ActiveMessageC;
+
+  components Counter32khz32C, new CounterToLocalTimeC(T32khz), HilTimerMilliC;
+  CounterToLocalTimeC.Counter -> Counter32khz32C;
+  CC2420PacketP.LocalTime32khz -> CounterToLocalTimeC;
+  CC2420PacketP.LocalTimeMilli -> HilTimerMilliC;
 }
diff --git a/tos/chips/cc2420/packet/CC2420PacketP.nc b/tos/chips/cc2420/packet/CC2420PacketP.nc
new file mode 100644 (file)
index 0000000..41002d5
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2005-2006 Arch Rock Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the
+ *   distribution.
+ * - Neither the name of the Arch Rock Corporation nor the names of
+ *   its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+/**
+ * @author Jonathan Hui <jhui@archrock.com>
+ * @author David Moss
+ * @author Chad Metcalf
+ */
+
+#include "IEEE802154.h"
+#include "message.h"
+#include "CC2420.h"
+
+module CC2420PacketP {
+
+  provides {
+    interface CC2420Packet;
+    interface PacketAcknowledgements as Acks;
+    interface CC2420PacketBody;
+    interface LinkPacketMetadata;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+    interface PacketTimeSyncOffset;
+  }
+
+  uses interface Packet;
+  uses interface LocalTime<T32khz> as LocalTime32khz;
+  uses interface LocalTime<TMilli> as LocalTimeMilli;
+}
+
+implementation {
+
+
+  /***************** PacketAcknowledgement Commands ****************/
+  async command error_t Acks.requestAck( message_t* p_msg ) {
+    (call CC2420PacketBody.getHeader( p_msg ))->fcf |= 1 << IEEE154_FCF_ACK_REQ;
+    return SUCCESS;
+  }
+
+  async command error_t Acks.noAck( message_t* p_msg ) {
+    (call CC2420PacketBody.getHeader( p_msg ))->fcf &= ~(1 << IEEE154_FCF_ACK_REQ);
+    return SUCCESS;
+  }
+
+  async command bool Acks.wasAcked( message_t* p_msg ) {
+    return (call CC2420PacketBody.getMetadata( p_msg ))->ack;
+  }
+
+  /***************** CC2420Packet Commands ****************/
+  async command void CC2420Packet.setPower( message_t* p_msg, uint8_t power ) {
+    if ( power > 31 )
+      power = 31;
+    (call CC2420PacketBody.getMetadata( p_msg ))->tx_power = power;
+  }
+
+  async command uint8_t CC2420Packet.getPower( message_t* p_msg ) {
+    return (call CC2420PacketBody.getMetadata( p_msg ))->tx_power;
+  }
+   
+  async command int8_t CC2420Packet.getRssi( message_t* p_msg ) {
+    return (call CC2420PacketBody.getMetadata( p_msg ))->rssi;
+  }
+
+  async command uint8_t CC2420Packet.getLqi( message_t* p_msg ) {
+    return (call CC2420PacketBody.getMetadata( p_msg ))->lqi;
+  }
+
+  /***************** CC2420PacketBody Commands ****************/
+  async command cc2420_header_t * ONE CC2420PacketBody.getHeader( message_t* ONE msg ) {
+    return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t, data) - sizeof( cc2420_header_t ));
+  }
+
+  async command cc2420_metadata_t *CC2420PacketBody.getMetadata( message_t* msg ) {
+    return (cc2420_metadata_t*)msg->metadata;
+  }
+
+  async command bool LinkPacketMetadata.highChannelQuality(message_t* msg) {
+    return call CC2420Packet.getLqi(msg) > 105;
+  }
+
+  /***************** PacketTimeStamp32khz Commands ****************/
+  async command bool PacketTimeStamp32khz.isValid(message_t* msg)
+  {
+    return ((call CC2420PacketBody.getMetadata( msg ))->timestamp != CC2420_INVALID_TIMESTAMP);
+  }
+
+  async command uint32_t PacketTimeStamp32khz.timestamp(message_t* msg)
+  {
+    return (call CC2420PacketBody.getMetadata( msg ))->timestamp;
+  }
+
+  async command void PacketTimeStamp32khz.clear(message_t* msg)
+  {
+    (call CC2420PacketBody.getMetadata( msg ))->timesync = FALSE;
+    (call CC2420PacketBody.getMetadata( msg ))->timestamp = CC2420_INVALID_TIMESTAMP;
+  }
+
+  async command void PacketTimeStamp32khz.set(message_t* msg, uint32_t value)
+  {
+    (call CC2420PacketBody.getMetadata( msg ))->timestamp = value;
+  }
+
+  /***************** PacketTimeStampMilli Commands ****************/
+  // over the air value is always T32khz, which is used to capture SFD interrupt
+  // (Timer1 on micaZ, B1 on telos)
+  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 ((call CC2420PacketBody.getMetadata( msg ))->timesync);
+  }
+
+  async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
+  {
+    // minus 1 because one less byte is transmitted
+    return (call CC2420PacketBody.getHeader(msg))->length - 1 - sizeof(uint32_t);
+  }
+
+  async command void PacketTimeSyncOffset.set(message_t* msg)
+  {
+    (call CC2420PacketBody.getMetadata( msg ))->timesync = TRUE;
+  }
+
+  async command void PacketTimeSyncOffset.cancel(message_t* msg)
+  {
+    (call CC2420PacketBody.getMetadata( msg ))->timesync = FALSE;
+  }
+}
index 1c1bb728bba253aa7fedcd973d82944b044a472f..14c723f6e68f31f9e1c5a6407f7dbdfeadff40f5 100644 (file)
@@ -75,6 +75,7 @@ implementation {
   CC2420ReceiveP.SACK -> Spi.SACK;
   CC2420ReceiveP.CC2420Packet -> CC2420PacketC;
   CC2420ReceiveP.CC2420PacketBody -> CC2420PacketC;
+  CC2420ReceiveP.PacketTimeStamp -> CC2420PacketC;
   CC2420ReceiveP.CC2420Config -> CC2420ControlC;
 
 }
index c5b672fd0f2cbf5211e906e06b6d45fcded842e3..fd757be55e6e584f1a59d2d2fc2f7ba7b31bf002 100644 (file)
@@ -60,7 +60,8 @@ module CC2420ReceiveP {
   uses interface CC2420Packet;
   uses interface CC2420PacketBody;
   uses interface CC2420Config;
-  
+  uses interface PacketTimeStamp<T32khz,uint32_t>;
+
   uses interface Leds;
 }
 
@@ -80,8 +81,8 @@ implementation {
     SACK_HEADER_LENGTH = 7,
   };
 
-  uint16_t m_timestamp_queue[ TIMESTAMP_QUEUE_SIZE ];
-  
+  uint32_t m_timestamp_queue[ TIMESTAMP_QUEUE_SIZE ];
+
   uint8_t m_timestamp_head;
   
   uint8_t m_timestamp_size;
@@ -145,7 +146,7 @@ implementation {
    * Start frame delimiter signifies the beginning/end of a packet
    * See the CC2420 datasheet for details.
    */
-  async command void CC2420Receive.sfd( uint16_t time ) {
+  async command void CC2420Receive.sfd( uint32_t time ) {
     if ( m_timestamp_size < TIMESTAMP_QUEUE_SIZE ) {
       uint8_t tail =  ( ( m_timestamp_head + m_timestamp_size ) % 
                         TIMESTAMP_QUEUE_SIZE );
@@ -194,7 +195,6 @@ implementation {
   async event void RXFIFO.readDone( uint8_t* rx_buf, uint8_t rx_len,
                                     error_t error ) {
     cc2420_header_t* header = call CC2420PacketBody.getHeader( m_p_rx_buf );
-    cc2420_metadata_t* metadata = call CC2420PacketBody.getMetadata( m_p_rx_buf );
     uint8_t tmpLen __DEPUTY_UNUSED__ = sizeof(message_t) - (offsetof(message_t, data) - sizeof(cc2420_header_t));
     uint8_t* COUNT(tmpLen) buf = TCAST(uint8_t* COUNT(tmpLen), header);
     rxFrameLength = buf[ 0 ];
@@ -283,12 +283,12 @@ implementation {
       
       if ( m_timestamp_size ) {
         if ( rxFrameLength > 10 ) {
-          metadata->time = m_timestamp_queue[ m_timestamp_head ];
+          call PacketTimeStamp.set(m_p_rx_buf, m_timestamp_queue[ m_timestamp_head ]);
           m_timestamp_head = ( m_timestamp_head + 1 ) % TIMESTAMP_QUEUE_SIZE;
           m_timestamp_size--;
         }
       } else {
-        metadata->time = 0xffff;
+        call PacketTimeStamp.clear(m_p_rx_buf);
       }
       
       // We may have received an ack that should be processed by Transmit
index fb7bcc34e62057816ae806d742a3ce5b2993d080..8624d981ed92dd30e1fb102bac78daaea25f123b 100644 (file)
@@ -44,7 +44,6 @@ configuration CC2420TransmitC {
     interface StdControl;
     interface CC2420Transmit;
     interface RadioBackoff;
-    interface RadioTimeStamping;
     interface ReceiveIndicator as EnergyIndicator;
     interface ReceiveIndicator as ByteIndicator;
   }
@@ -56,7 +55,6 @@ implementation {
   StdControl = CC2420TransmitP;
   CC2420Transmit = CC2420TransmitP;
   RadioBackoff = CC2420TransmitP;
-  RadioTimeStamping = CC2420TransmitP;
   EnergyIndicator = CC2420TransmitP.EnergyIndicator;
   ByteIndicator = CC2420TransmitP.ByteIndicator;
 
@@ -93,7 +91,9 @@ implementation {
   components CC2420PacketC;
   CC2420TransmitP.CC2420Packet -> CC2420PacketC;
   CC2420TransmitP.CC2420PacketBody -> CC2420PacketC;
-  
+  CC2420TransmitP.PacketTimeStamp -> CC2420PacketC;
+  CC2420TransmitP.PacketTimeSyncOffset -> CC2420PacketC;
+
   components LedsC;
   CC2420TransmitP.Leds -> LedsC;
 }
index cfb0101c49611e2feb01901be7bf5c3d18048ee5..17653d6584c4b471d366a52e2c06ef6b999dbf48 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include "CC2420.h"
+#include "CC2420TimeSyncMessage.h"
 #include "crc.h"
 #include "message.h"
 
@@ -46,13 +47,14 @@ module CC2420TransmitP {
   provides interface StdControl;
   provides interface CC2420Transmit as Send;
   provides interface RadioBackoff;
-  provides interface RadioTimeStamping as TimeStamp;
   provides interface ReceiveIndicator as EnergyIndicator;
   provides interface ReceiveIndicator as ByteIndicator;
   
   uses interface Alarm<T32khz,uint32_t> as BackoffTimer;
   uses interface CC2420Packet;
   uses interface CC2420PacketBody;
+  uses interface PacketTimeStamp<T32khz,uint32_t>;
+  uses interface PacketTimeSyncOffset;
   uses interface GpioCapture as CaptureSFD;
   uses interface GeneralIO as CCA;
   uses interface GeneralIO as CSN;
@@ -234,7 +236,14 @@ implementation {
   }
   
   
-  
+  inline uint32_t time16to32(uint16_t time, uint32_t recent_time)
+  {
+    if ((recent_time&0xFFFF)<time)
+      return ((recent_time-0x10000UL)&0xFFFF0000UL)|time;
+    else
+      return (recent_time&0xFFFF0000UL)|time;
+  }
+
   /**
    * The CaptureSFD event is actually an interrupt from the capture pin
    * which is connected to timing circuitry and timer modules.  This
@@ -249,6 +258,7 @@ implementation {
    * would have picked up and executed had our microcontroller been fast enough.
    */
   async event void CaptureSFD.captured( uint16_t time ) {
+    uint32_t time32 = time16to32(time, call BackoffTimer.getNow());
     atomic {
       switch( m_state ) {
         
@@ -256,7 +266,16 @@ implementation {
         m_state = S_EFD;
         sfdHigh = TRUE;
         call CaptureSFD.captureFallingEdge();
-        signal TimeStamp.transmittedSFD( time, m_msg );
+        call PacketTimeStamp.set(m_msg, time32);
+        if (call PacketTimeSyncOffset.isSet(m_msg)) {
+           timesync_radio_t *timesync = (timesync_radio_t*)((void*)m_msg + call PacketTimeSyncOffset.get(m_msg));
+           // set timesync event time as the offset between the event time and the SFD interrupt time (TEP  133)
+           *timesync  -= time32;
+           call CSN.clr();
+           call TXFIFO_RAM.write( call PacketTimeSyncOffset.get(m_msg), (void*)timesync, sizeof(timesync_radio_t) );
+           call CSN.set();
+        }
+
         if ( (call CC2420PacketBody.getHeader( m_msg ))->fcf & ( 1 << IEEE154_FCF_ACK_REQ ) ) {
           // This is an ack packet, don't release the chip's SPI bus lock.
           abortSpiRelease = TRUE;
@@ -266,7 +285,7 @@ implementation {
 
         
         if ( ( ( (call CC2420PacketBody.getHeader( m_msg ))->fcf >> IEEE154_FCF_FRAME_TYPE ) & 7 ) == IEEE154_TYPE_DATA ) {
-          (call CC2420PacketBody.getMetadata( m_msg ))->time = time;
+          call PacketTimeStamp.set(m_msg, time32);
         }
         
         if ( call SFD.get() ) {
@@ -294,8 +313,7 @@ implementation {
         if ( !m_receiving ) {
           sfdHigh = TRUE;
           call CaptureSFD.captureFallingEdge();
-          signal TimeStamp.receivedSFD( time );
-          call CC2420Receive.sfd( time );
+          call CC2420Receive.sfd( time32 );
           m_receiving = TRUE;
           m_prev_time = time;
           if ( call SFD.get() ) {
@@ -309,6 +327,7 @@ implementation {
         m_receiving = FALSE;
         if ( time - m_prev_time < 10 ) {
           call CC2420Receive.sfd_dropped();
+          call PacketTimeStamp.clear(m_msg);
         }
         break;
       
@@ -666,17 +685,5 @@ implementation {
     call ChipSpiResource.attemptRelease();
     signal Send.sendDone( m_msg, err );
   }
-  
-  
-  
-  /***************** Tasks ****************/
-
-  /***************** Defaults ****************/
-  default async event void TimeStamp.transmittedSFD( uint16_t time, message_t* p_msg ) {
-  }
-  
-  default async event void TimeStamp.receivedSFD( uint16_t time ) {
-  }
-
 }
 
index 3d1e1b2c104aa65fbc8ad3a8e65c42af54dd2577..b4a1746791ada7ee73703413691a27f4002d0bd9 100644 (file)
@@ -37,8 +37,8 @@
 
 /**
  *
- * The Active Message layer on the mica2 platform. This is a naming wrapper
- * around the CC1000 Active Message layer.
+ * The Active Message layer on the intelmote2 platform. This is a naming wrapper
+ * around the CC2420 Active Message layer.
  *
  * @author Philip Levis
  * @date June 19 2005
@@ -48,13 +48,15 @@ configuration ActiveMessageC {
   provides {
     interface SplitControl;
 
-    interface AMSend[uint8_t id];
-    interface Receive[uint8_t id];
-    interface Receive as Snoop[uint8_t id];
+    interface AMSend[am_id_t id];
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
 
     interface Packet;
     interface AMPacket;
     interface PacketAcknowledgements;
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
   }
 }
 implementation {
@@ -68,4 +70,8 @@ implementation {
   Packet       = AM;
   AMPacket     = AM;
   PacketAcknowledgements = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
 }
diff --git a/tos/platforms/intelmote2/TimeSyncMessageC.nc b/tos/platforms/intelmote2/TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..d2fdba6
--- /dev/null
@@ -0,0 +1,78 @@
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 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."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+
+/**
+ *
+ * The Active Message layer on the intelmote2 platform. This is a naming wrapper
+ * around the CC2420 Active Message layer that implemets timesync interface (TEP 133).
+ *
+ * @author Philip Levis
+ * @author Brano Kusy
+ * @date June 19 2005
+ */
+
+configuration TimeSyncMessageC {
+  provides
+  {
+    interface SplitControl;
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
+    interface Packet;
+    interface AMPacket;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+    interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[am_id_t id];
+    interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+
+    interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+    interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+  }
+}
+implementation {
+  components CC2420TimeSyncMessageC as AM;
+
+  SplitControl = AM;
+
+  Receive      = AM.Receive;
+  Snoop        = AM.Snoop;
+  Packet       = AM;
+  AMPacket     = AM;
+  TimeSyncAMSend32khz       = AM;
+  TimeSyncAMSendMilli       = AM;
+  TimeSyncPacket32khz       = AM;
+  TimeSyncPacketMilli       = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
+}
\ No newline at end of file
index ef766ba1f6d954da574c12f659a42515f5d12c66..a60be2cb29b207c07cec059c27c1d11391f6de7a 100644 (file)
@@ -48,13 +48,15 @@ configuration ActiveMessageC {
   provides {
     interface SplitControl;
 
-    interface AMSend[uint8_t id];
-    interface Receive[uint8_t id];
-    interface Receive as Snoop[uint8_t id];
+    interface AMSend[am_id_t id];
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
 
     interface Packet;
     interface AMPacket;
     interface PacketAcknowledgements;
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
   }
 }
 implementation {
@@ -68,4 +70,8 @@ implementation {
   Packet       = AM;
   AMPacket     = AM;
   PacketAcknowledgements = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
 }
diff --git a/tos/platforms/micaz/TimeSyncMessageC.nc b/tos/platforms/micaz/TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..eb4a801
--- /dev/null
@@ -0,0 +1,78 @@
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 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."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+
+/**
+ *
+ * The Active Message layer on the micaz platform. This is a naming wrapper
+ * around the CC2420 Active Message layer that implemets timesync interface (TEP 133).
+ *
+ * @author Philip Levis
+ * @author Brano Kusy
+ * @date June 19 2005
+ */
+
+configuration TimeSyncMessageC {
+  provides
+  {
+    interface SplitControl;
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
+    interface Packet;
+    interface AMPacket;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+    interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[am_id_t id];
+    interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+
+    interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+    interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+  }
+}
+implementation {
+  components CC2420TimeSyncMessageC as AM;
+
+  SplitControl = AM;
+
+  Receive      = AM.Receive;
+  Snoop        = AM.Snoop;
+  Packet       = AM;
+  AMPacket     = AM;
+  TimeSyncAMSend32khz       = AM;
+  TimeSyncAMSendMilli       = AM;
+  TimeSyncPacket32khz       = AM;
+  TimeSyncPacketMilli       = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
+}
\ No newline at end of file
index 36f7797faa95f40c84aa8b7bbe820a970ddb1866..d5c9359aaa38184400b864e5d4d69a25628b6532 100644 (file)
@@ -52,6 +52,8 @@ configuration ActiveMessageC {
     interface Packet;
     interface AMPacket;
     interface PacketAcknowledgements;
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
   }
 }
 implementation {
@@ -65,4 +67,8 @@ implementation {
   Packet       = AM;
   AMPacket     = AM;
   PacketAcknowledgements = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
 }
diff --git a/tos/platforms/shimmer/TimeSyncMessageC.nc b/tos/platforms/shimmer/TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..10bf586
--- /dev/null
@@ -0,0 +1,80 @@
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 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."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+
+/**
+ *
+ * The Active Message layer on the shimmer platform. This is a naming wrapper
+ * around the CC2420 Active Message layer that implemets timesync interface (TEP 133).
+ *
+ * @author Konrad Lorincz
+ * @author Brano Kusy
+ * @date June 19 2005
+ */
+
+configuration TimeSyncMessageC {
+  provides
+  {
+    interface SplitControl;
+    interface Receive[uint8_t id];
+    interface Receive as Snoop[uint8_t id];
+    interface Packet;
+    interface AMPacket;
+    interface PacketAcknowledgements;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+    interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[am_id_t id];
+    interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+
+    interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+    interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+  }
+}
+implementation {
+  components CC2420TimeSyncMessageC as AM;
+
+  SplitControl = AM;
+
+  Receive      = AM.Receive;
+  Snoop        = AM.Snoop;
+  Packet       = AM;
+  AMPacket     = AM;
+  PacketAcknowledgements = AM;
+  TimeSyncAMSend32khz       = AM;
+  TimeSyncAMSendMilli       = AM;
+  TimeSyncPacket32khz       = AM;
+  TimeSyncPacketMilli       = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
+}
\ No newline at end of file
index 4f999b8b69a54f38e10369617a7db85cb44edebf..beb1b8451c27eb8fe0bc83a71f0705d515b7eccb 100644 (file)
@@ -48,13 +48,15 @@ configuration ActiveMessageC {
   provides {
     interface SplitControl;
 
-    interface AMSend[uint8_t id];
-    interface Receive[uint8_t id];
-    interface Receive as Snoop[uint8_t id];
+    interface AMSend[am_id_t id];
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
 
     interface Packet;
     interface AMPacket;
     interface PacketAcknowledgements;
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
   }
 }
 implementation {
@@ -68,4 +70,8 @@ implementation {
   Packet       = AM;
   AMPacket     = AM;
   PacketAcknowledgements = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
 }
diff --git a/tos/platforms/telosa/TimeSyncMessageC.nc b/tos/platforms/telosa/TimeSyncMessageC.nc
new file mode 100644 (file)
index 0000000..432200e
--- /dev/null
@@ -0,0 +1,78 @@
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 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."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+
+/**
+ *
+ * The Active Message layer on the telosa platform. This is a naming wrapper
+ * around the CC2420 Active Message layer that implemets timesync interface (TEP 133).
+ *
+ * @author Philip Levis
+ * @author Brano Kusy
+ * @date June 19 2005
+ */
+
+configuration TimeSyncMessageC {
+  provides
+  {
+    interface SplitControl;
+    interface Receive[am_id_t id];
+    interface Receive as Snoop[am_id_t id];
+    interface Packet;
+    interface AMPacket;
+
+    interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+    interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+
+    interface TimeSyncAMSend<T32khz, uint32_t> as TimeSyncAMSend32khz[am_id_t id];
+    interface TimeSyncPacket<T32khz, uint32_t> as TimeSyncPacket32khz;
+
+    interface TimeSyncAMSend<TMilli, uint32_t> as TimeSyncAMSendMilli[am_id_t id];
+    interface TimeSyncPacket<TMilli, uint32_t> as TimeSyncPacketMilli;
+  }
+}
+implementation {
+  components CC2420TimeSyncMessageC as AM;
+
+  SplitControl = AM;
+
+  Receive      = AM.Receive;
+  Snoop        = AM.Snoop;
+  Packet       = AM;
+  AMPacket     = AM;
+  TimeSyncAMSend32khz       = AM;
+  TimeSyncAMSendMilli       = AM;
+  TimeSyncPacket32khz       = AM;
+  TimeSyncPacketMilli       = AM;
+
+  components CC2420PacketC;
+  PacketTimeStamp32khz = CC2420PacketC;
+  PacketTimeStampMilli = CC2420PacketC;
+}
\ No newline at end of file