From: mmaroti Date: Mon, 16 Jun 2008 19:03:53 +0000 (+0000) Subject: move TimeSyncC to RF230TimeSyncC X-Git-Tag: release_tinyos_2_1_0_0~286 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=ac43bdecf67f77e66c2c07ee1e5ea3e8c80b8402 move TimeSyncC to RF230TimeSyncC --- diff --git a/tos/chips/rf230/RF230TimeSyncMessageC.nc b/tos/chips/rf230/RF230TimeSyncMessageC.nc new file mode 100644 index 00000000..70b6440d --- /dev/null +++ b/tos/chips/rf230/RF230TimeSyncMessageC.nc @@ -0,0 +1,72 @@ +/* + * 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 + */ + +#include +#include +#include + +configuration RF230TimeSyncMessageC +{ + provides + { + interface SplitControl; + + interface Receive[uint8_t id]; + interface Receive as Snoop[am_id_t id]; + interface Packet; + interface AMPacket; + + interface TimeSyncAMSend as TimeSyncAMSendRadio[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacketRadio; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacketMilli; + } +} + +implementation +{ + components RF230TimeSyncMessageP, RF230ActiveMessageC, LocalTimeMilliC, LocalTimeMicroC as LocalTimeRadioC, RF230PacketC; + + TimeSyncAMSendRadio = RF230TimeSyncMessageP; + TimeSyncPacketRadio = RF230TimeSyncMessageP; + + TimeSyncAMSendMilli = RF230TimeSyncMessageP; + TimeSyncPacketMilli = RF230TimeSyncMessageP; + + Packet = RF230TimeSyncMessageP; + RF230TimeSyncMessageP.SubSend -> RF230ActiveMessageC.AMSend; + RF230TimeSyncMessageP.SubPacket -> RF230ActiveMessageC.Packet; + + RF230TimeSyncMessageP.PacketTimeStampRadio -> RF230ActiveMessageC; + RF230TimeSyncMessageP.PacketTimeStampMilli -> RF230ActiveMessageC; + RF230TimeSyncMessageP.LocalTimeRadio -> LocalTimeRadioC; + RF230TimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC; + + RF230TimeSyncMessageP.PacketTimeSyncOffset -> RF230PacketC.PacketTimeSyncOffset; + + SplitControl = RF230ActiveMessageC; + Receive = RF230ActiveMessageC.Receive; + Snoop = RF230ActiveMessageC.Snoop; + AMPacket = RF230ActiveMessageC; +} diff --git a/tos/chips/rf230/RF230TimeSyncMessageP.nc b/tos/chips/rf230/RF230TimeSyncMessageP.nc new file mode 100644 index 00000000..181d5c20 --- /dev/null +++ b/tos/chips/rf230/RF230TimeSyncMessageP.nc @@ -0,0 +1,187 @@ +/* + * 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 + */ + +#include +#include + +module RF230TimeSyncMessageP +{ + provides + { + interface TimeSyncAMSend as TimeSyncAMSendRadio[uint8_t id]; + interface TimeSyncAMSend as TimeSyncAMSendMilli[uint8_t id]; + interface Packet; + + interface TimeSyncPacket as TimeSyncPacketRadio; + interface TimeSyncPacket as TimeSyncPacketMilli; + } + + uses + { + interface AMSend as SubSend[uint8_t id]; + interface Packet as SubPacket; + + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + + interface LocalTime as LocalTimeRadio; + interface LocalTime as LocalTimeMilli; + + interface PacketField as PacketTimeSyncOffset; + } +} + +implementation +{ + 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 SubPacket.clear(msg); + } + + command void Packet.setPayloadLength(message_t* msg, uint8_t len) + { + call SubPacket.setPayloadLength(msg, len + sizeof(timesync_relative_t)); + } + + command uint8_t Packet.payloadLength(message_t* msg) + { + return call SubPacket.payloadLength(msg) - sizeof(timesync_relative_t); + } + + command uint8_t Packet.maxPayloadLength() + { + return call SubPacket.maxPayloadLength() - sizeof(timesync_relative_t); + } + + command void* Packet.getPayload(message_t* msg, uint8_t len) + { + return call SubPacket.getPayload(msg, len + sizeof(timesync_relative_t)); + } + +/*----------------- TimeSyncAMSendRadio -----------------*/ + + command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time) + { + *(timesync_absolute_t*)(msg->data + len) = event_time; + + call PacketTimeSyncOffset.set(msg, len); + + return call SubSend.send[id](addr, msg, len + sizeof(timesync_relative_t)); + } + + command error_t TimeSyncAMSendRadio.cancel[am_id_t id](message_t* msg) + { + return call SubSend.cancel[id](msg); + } + + default event void TimeSyncAMSendRadio.sendDone[am_id_t id](message_t* msg, error_t error) + { + } + + command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]() + { + return call SubSend.maxPayloadLength[id]() - sizeof(timesync_relative_t); + } + + command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len) + { + return call SubSend.getPayload[id](msg, len + sizeof(timesync_relative_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 = ((int32_t)(event_time - call LocalTimeMilli.get()) << 10) + call LocalTimeRadio.get(); + + return call TimeSyncAMSendRadio.send[id](addr, msg, len, event_time); + } + + command error_t TimeSyncAMSendMilli.cancel[am_id_t id](message_t* msg) + { + return call TimeSyncAMSendRadio.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 TimeSyncAMSendRadio.maxPayloadLength[id](); + } + + command void* TimeSyncAMSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len) + { + return call TimeSyncAMSendRadio.getPayload[id](msg, len); + } + + /*----------------- SubSend.sendDone -------------------*/ + + event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error) + { + signal TimeSyncAMSendRadio.sendDone[id](msg, error); + signal TimeSyncAMSendMilli.sendDone[id](msg, error); + } + + /*----------------- TimeSyncPacketRadio -----------------*/ + + command bool TimeSyncPacketRadio.isValid(message_t* msg) + { + timesync_relative_t* timesync = getFooter(msg); + + return call PacketTimeStampRadio.isValid(msg) && *timesync != 0x80000000L; + } + + command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg) + { + timesync_relative_t* timesync = getFooter(msg); + + return (*timesync) + call PacketTimeStampRadio.timestamp(msg); + } + + /*----------------- TimeSyncPacketMilli -----------------*/ + + command bool TimeSyncPacketMilli.isValid(message_t* msg) + { + timesync_relative_t* timesync = getFooter(msg); + + return call PacketTimeStampMilli.isValid(msg) && *timesync != 0x80000000L; + } + + command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg) + { + timesync_relative_t* timesync = getFooter(msg); + + return ((int32_t)(*timesync) >> 10) + call PacketTimeStampMilli.timestamp(msg); + } +} diff --git a/tos/chips/rf230/TimeSyncMessageC.nc b/tos/chips/rf230/TimeSyncMessageC.nc deleted file mode 100644 index 3f23bdb5..00000000 --- a/tos/chips/rf230/TimeSyncMessageC.nc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - */ - -#include -#include -#include - -configuration TimeSyncMessageC -{ - provides - { - interface SplitControl; - - interface Receive[uint8_t id]; - interface Receive as Snoop[am_id_t id]; - interface Packet; - interface AMPacket; - - interface TimeSyncAMSend as TimeSyncAMSendRadio[am_id_t id]; - interface TimeSyncPacket as TimeSyncPacketRadio; - - interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; - interface TimeSyncPacket as TimeSyncPacketMilli; - } -} - -implementation -{ - components TimeSyncMessageP, RF230ActiveMessageC, LocalTimeMilliC, LocalTimeMicroC as LocalTimeRadioC, RF230PacketC; - - TimeSyncAMSendRadio = TimeSyncMessageP; - TimeSyncPacketRadio = TimeSyncMessageP; - - TimeSyncAMSendMilli = TimeSyncMessageP; - TimeSyncPacketMilli = TimeSyncMessageP; - - Packet = TimeSyncMessageP; - TimeSyncMessageP.SubSend -> RF230ActiveMessageC.AMSend; - TimeSyncMessageP.SubPacket -> RF230ActiveMessageC.Packet; - - TimeSyncMessageP.PacketTimeStampRadio -> RF230ActiveMessageC; - TimeSyncMessageP.PacketTimeStampMilli -> RF230ActiveMessageC; - TimeSyncMessageP.LocalTimeRadio -> LocalTimeRadioC; - TimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC; - - TimeSyncMessageP.PacketTimeSyncOffset -> RF230PacketC.PacketTimeSyncOffset; - - SplitControl = RF230ActiveMessageC; - Receive = RF230ActiveMessageC.Receive; - Snoop = RF230ActiveMessageC.Snoop; - AMPacket = RF230ActiveMessageC; -} diff --git a/tos/chips/rf230/TimeSyncMessageP.nc b/tos/chips/rf230/TimeSyncMessageP.nc deleted file mode 100644 index c4f9ca3e..00000000 --- a/tos/chips/rf230/TimeSyncMessageP.nc +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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 - */ - -#include -#include - -module TimeSyncMessageP -{ - provides - { - interface TimeSyncAMSend as TimeSyncAMSendRadio[uint8_t id]; - interface TimeSyncAMSend as TimeSyncAMSendMilli[uint8_t id]; - interface Packet; - - interface TimeSyncPacket as TimeSyncPacketRadio; - interface TimeSyncPacket as TimeSyncPacketMilli; - } - - uses - { - interface AMSend as SubSend[uint8_t id]; - interface Packet as SubPacket; - - interface PacketTimeStamp as PacketTimeStampRadio; - interface PacketTimeStamp as PacketTimeStampMilli; - - interface LocalTime as LocalTimeRadio; - interface LocalTime as LocalTimeMilli; - - interface PacketField as PacketTimeSyncOffset; - } -} - -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 SubPacket.clear(msg); - } - - command void Packet.setPayloadLength(message_t* msg, uint8_t len) - { - call SubPacket.setPayloadLength(msg, len + sizeof(timesync_relative_t)); - } - - command uint8_t Packet.payloadLength(message_t* msg) - { - return call SubPacket.payloadLength(msg) - sizeof(timesync_relative_t); - } - - command uint8_t Packet.maxPayloadLength() - { - return call SubPacket.maxPayloadLength() - sizeof(timesync_relative_t); - } - - command void* Packet.getPayload(message_t* msg, uint8_t len) - { - return call SubPacket.getPayload(msg, len + sizeof(timesync_relative_t)); - } - -/*----------------- TimeSyncAMSendRadio -----------------*/ - - command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time) - { - *(timesync_absolute_t*)(msg->data + len) = event_time; - - call PacketTimeSyncOffset.set(msg, len); - - return call SubSend.send[id](addr, msg, len + sizeof(timesync_relative_t)); - } - - command error_t TimeSyncAMSendRadio.cancel[am_id_t id](message_t* msg) - { - return call SubSend.cancel[id](msg); - } - - default event void TimeSyncAMSendRadio.sendDone[am_id_t id](message_t* msg, error_t error) - { - } - - command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]() - { - return call SubSend.maxPayloadLength[id]() - sizeof(timesync_relative_t); - } - - command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len) - { - return call SubSend.getPayload[id](msg, len + sizeof(timesync_relative_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 = ((int32_t)(event_time - call LocalTimeMilli.get()) << 10) + call LocalTimeRadio.get(); - - return call TimeSyncAMSendRadio.send[id](addr, msg, len, event_time); - } - - command error_t TimeSyncAMSendMilli.cancel[am_id_t id](message_t* msg) - { - return call TimeSyncAMSendRadio.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 TimeSyncAMSendRadio.maxPayloadLength[id](); - } - - command void* TimeSyncAMSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len) - { - return call TimeSyncAMSendRadio.getPayload[id](msg, len); - } - - /*----------------- SubSend.sendDone -------------------*/ - - event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error) - { - signal TimeSyncAMSendRadio.sendDone[id](msg, error); - signal TimeSyncAMSendMilli.sendDone[id](msg, error); - } - - /*----------------- TimeSyncPacketRadio -----------------*/ - - async command bool TimeSyncPacketRadio.isValid(message_t* msg) - { - timesync_relative_t* timesync = getFooter(msg); - - return call PacketTimeStampRadio.isValid(msg) && *timesync != 0x80000000L; - } - - async command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg) - { - timesync_relative_t* timesync = getFooter(msg); - - return (*timesync) + call PacketTimeStampRadio.timestamp(msg); - } - - /*----------------- TimeSyncPacketMilli -----------------*/ - - async command bool TimeSyncPacketMilli.isValid(message_t* msg) - { - timesync_relative_t* timesync = getFooter(msg); - - return call PacketTimeStampMilli.isValid(msg) && *timesync != 0x80000000L; - } - - async command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg) - { - timesync_relative_t* timesync = getFooter(msg); - - return ((int32_t)(*timesync) >> 10) + call PacketTimeStampMilli.timestamp(msg); - } -} diff --git a/tos/platforms/iris/TimeSyncMessageC.nc b/tos/platforms/iris/TimeSyncMessageC.nc new file mode 100644 index 00000000..aca670b3 --- /dev/null +++ b/tos/platforms/iris/TimeSyncMessageC.nc @@ -0,0 +1,60 @@ +/* + * 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 + */ + +#include + +configuration TimeSyncMessageC +{ + provides + { + interface SplitControl; + + interface Receive[uint8_t id]; + interface Receive as Snoop[am_id_t id]; + interface Packet; + interface AMPacket; + + interface TimeSyncAMSend as TimeSyncAMSendRadio[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacketRadio; + + interface TimeSyncAMSend as TimeSyncAMSendMilli[am_id_t id]; + interface TimeSyncPacket as TimeSyncPacketMilli; + } +} + +implementation +{ + components RF230TimeSyncMessageC; + + SplitControl = RF230TimeSyncMessageC; + + Receive = RF230TimeSyncMessageC.Receive; + Snoop = RF230TimeSyncMessageC.Snoop; + Packet = RF230TimeSyncMessageC; + AMPacket = RF230TimeSyncMessageC; + + TimeSyncAMSendRadio = RF230TimeSyncMessageC; + TimeSyncPacketRadio = RF230TimeSyncMessageC; + TimeSyncAMSendMilli = RF230TimeSyncMessageC; + TimeSyncPacketMilli = RF230TimeSyncMessageC; +}