From: kusy Date: Tue, 17 Jun 2008 07:28:24 +0000 (+0000) Subject: adding support for timesync/timestamping interfaces (teps 132,133) X-Git-Tag: release_tinyos_2_1_0_0~272 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=0ab1429a57148045a74254930442ecddd47d63a3;p=tinyos-2.x.git adding support for timesync/timestamping interfaces (teps 132,133) --- diff --git a/tos/chips/cc2420/CC2420.h b/tos/chips/cc2420/CC2420.h index a3413ec2..2418c3f1 100644 --- a/tos/chips/cc2420/CC2420.h +++ b/tos/chips/cc2420/CC2420.h @@ -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 index 00000000..a744fd38 --- /dev/null +++ b/tos/chips/cc2420/CC2420TimeSyncMessage.h @@ -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 index 00000000..745bd08e --- /dev/null +++ b/tos/chips/cc2420/CC2420TimeSyncMessageC.nc @@ -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 +#include + +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 as TimeSyncAMSend32khz[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacket32khz; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket 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 index 00000000..a4e11573 --- /dev/null +++ b/tos/chips/cc2420/CC2420TimeSyncMessageP.nc @@ -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 as TimeSyncAMSend32khz[uint8_t id]; + interface TimeSyncAMSend as TimeSyncAMSendMilli[uint8_t id]; + interface Packet; + + interface TimeSyncPacket as TimeSyncPacket32khz; + interface TimeSyncPacket as TimeSyncPacketMilli; + } + + uses + { + interface AMSend as SubSend[uint8_t id]; + interface Packet as SubPacket; + + interface PacketTimeStamp as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + interface PacketTimeSyncOffset; + + interface LocalTime as LocalTime32khz; + interface LocalTime 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); + } +} diff --git a/tos/chips/cc2420/csma/CC2420CsmaP.nc b/tos/chips/cc2420/csma/CC2420CsmaP.nc index 284313ee..df6ffb25 100644 --- a/tos/chips/cc2420/csma/CC2420CsmaP.nc +++ b/tos/chips/cc2420/csma/CC2420CsmaP.nc @@ -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); diff --git a/tos/chips/cc2420/interfaces/CC2420Receive.nc b/tos/chips/cc2420/interfaces/CC2420Receive.nc index 257f942a..77da8419 100644 --- a/tos/chips/cc2420/interfaces/CC2420Receive.nc +++ b/tos/chips/cc2420/interfaces/CC2420Receive.nc @@ -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 index 00000000..0295069b --- /dev/null +++ b/tos/chips/cc2420/interfaces/PacketTimeSyncOffset.nc @@ -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); +} diff --git a/tos/chips/cc2420/packet/CC2420PacketC.nc b/tos/chips/cc2420/packet/CC2420PacketC.nc index 8eeb8a62..51bc23c9 100644 --- a/tos/chips/cc2420/packet/CC2420PacketC.nc +++ b/tos/chips/cc2420/packet/CC2420PacketC.nc @@ -35,67 +35,36 @@ * @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 as PacketTimeStamp32khz; + interface PacketTimeStamp 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 index 00000000..41002d5b --- /dev/null +++ b/tos/chips/cc2420/packet/CC2420PacketP.nc @@ -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 + * @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 as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + interface PacketTimeSyncOffset; + } + + uses interface Packet; + uses interface LocalTime as LocalTime32khz; + uses interface LocalTime 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; + } +} diff --git a/tos/chips/cc2420/receive/CC2420ReceiveC.nc b/tos/chips/cc2420/receive/CC2420ReceiveC.nc index 1c1bb728..14c723f6 100644 --- a/tos/chips/cc2420/receive/CC2420ReceiveC.nc +++ b/tos/chips/cc2420/receive/CC2420ReceiveC.nc @@ -75,6 +75,7 @@ implementation { CC2420ReceiveP.SACK -> Spi.SACK; CC2420ReceiveP.CC2420Packet -> CC2420PacketC; CC2420ReceiveP.CC2420PacketBody -> CC2420PacketC; + CC2420ReceiveP.PacketTimeStamp -> CC2420PacketC; CC2420ReceiveP.CC2420Config -> CC2420ControlC; } diff --git a/tos/chips/cc2420/receive/CC2420ReceiveP.nc b/tos/chips/cc2420/receive/CC2420ReceiveP.nc index c5b672fd..fd757be5 100644 --- a/tos/chips/cc2420/receive/CC2420ReceiveP.nc +++ b/tos/chips/cc2420/receive/CC2420ReceiveP.nc @@ -60,7 +60,8 @@ module CC2420ReceiveP { uses interface CC2420Packet; uses interface CC2420PacketBody; uses interface CC2420Config; - + uses interface PacketTimeStamp; + 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 diff --git a/tos/chips/cc2420/transmit/CC2420TransmitC.nc b/tos/chips/cc2420/transmit/CC2420TransmitC.nc index fb7bcc34..8624d981 100644 --- a/tos/chips/cc2420/transmit/CC2420TransmitC.nc +++ b/tos/chips/cc2420/transmit/CC2420TransmitC.nc @@ -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; } diff --git a/tos/chips/cc2420/transmit/CC2420TransmitP.nc b/tos/chips/cc2420/transmit/CC2420TransmitP.nc index cfb0101c..17653d65 100644 --- a/tos/chips/cc2420/transmit/CC2420TransmitP.nc +++ b/tos/chips/cc2420/transmit/CC2420TransmitP.nc @@ -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 as BackoffTimer; uses interface CC2420Packet; uses interface CC2420PacketBody; + uses interface PacketTimeStamp; + 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)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 ) { - } - } diff --git a/tos/platforms/intelmote2/ActiveMessageC.nc b/tos/platforms/intelmote2/ActiveMessageC.nc index 3d1e1b2c..b4a17467 100644 --- a/tos/platforms/intelmote2/ActiveMessageC.nc +++ b/tos/platforms/intelmote2/ActiveMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp 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 index 00000000..d2fdba6e --- /dev/null +++ b/tos/platforms/intelmote2/TimeSyncMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + + interface TimeSyncAMSend as TimeSyncAMSend32khz[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacket32khz; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket 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 diff --git a/tos/platforms/micaz/ActiveMessageC.nc b/tos/platforms/micaz/ActiveMessageC.nc index ef766ba1..a60be2cb 100644 --- a/tos/platforms/micaz/ActiveMessageC.nc +++ b/tos/platforms/micaz/ActiveMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp 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 index 00000000..eb4a801f --- /dev/null +++ b/tos/platforms/micaz/TimeSyncMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + + interface TimeSyncAMSend as TimeSyncAMSend32khz[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacket32khz; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket 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 diff --git a/tos/platforms/shimmer/ActiveMessageC.nc b/tos/platforms/shimmer/ActiveMessageC.nc index 36f7797f..d5c9359a 100644 --- a/tos/platforms/shimmer/ActiveMessageC.nc +++ b/tos/platforms/shimmer/ActiveMessageC.nc @@ -52,6 +52,8 @@ configuration ActiveMessageC { interface Packet; interface AMPacket; interface PacketAcknowledgements; + interface PacketTimeStamp as PacketTimeStamp32khz; + interface PacketTimeStamp 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 index 00000000..10bf586e --- /dev/null +++ b/tos/platforms/shimmer/TimeSyncMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + + interface TimeSyncAMSend as TimeSyncAMSend32khz[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacket32khz; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket 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 diff --git a/tos/platforms/telosa/ActiveMessageC.nc b/tos/platforms/telosa/ActiveMessageC.nc index 4f999b8b..beb1b845 100644 --- a/tos/platforms/telosa/ActiveMessageC.nc +++ b/tos/platforms/telosa/ActiveMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp 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 index 00000000..432200ea --- /dev/null +++ b/tos/platforms/telosa/TimeSyncMessageC.nc @@ -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 as PacketTimeStamp32khz; + interface PacketTimeStamp as PacketTimeStampMilli; + + interface TimeSyncAMSend as TimeSyncAMSend32khz[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacket32khz; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket 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