diff --git a/tos/chips/atm128rfa1/radio/RFA1ActiveMessageC.nc b/tos/chips/atm128rfa1/radio/RFA1ActiveMessageC.nc index c6896d94ab..3ac99f134d 100644 --- a/tos/chips/atm128rfa1/radio/RFA1ActiveMessageC.nc +++ b/tos/chips/atm128rfa1/radio/RFA1ActiveMessageC.nc @@ -75,21 +75,41 @@ configuration RFA1ActiveMessageC implementation { +// -------- Active Message + + components new ActiveMessageLayerC(); + ActiveMessageLayerC.Config -> RadioP; + ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC; + ActiveMessageLayerC.SubReceive -> RadioC.TinyosReceive; + ActiveMessageLayerC.SubPacket -> RadioC.TinyosPacket; + + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + Snoop = ActiveMessageLayerC.Snoop; + SendNotifier = ActiveMessageLayerC; + AMPacket = ActiveMessageLayerC; + Packet = ActiveMessageLayerC; + + ReceiveDefault = ActiveMessageLayerC.ReceiveDefault; + SnoopDefault = ActiveMessageLayerC.SnoopDefault; + +// -------- Automatic RadioSend Resource + +#ifndef TFRAMES_ENABLED + components new AutoResourceAcquireLayerC(); + AutoResourceAcquireLayerC.Resource -> RadioC.SendResource[unique(RADIO_SEND_RESOURCE)]; +#else + components new DummyLayerC() as AutoResourceAcquireLayerC; +#endif + AutoResourceAcquireLayerC -> RadioC.TinyosSend; + +// -------- Radio + components RFA1RadioC as RadioC; + components RFA1RadioP as RadioP; SplitControl = RadioC; - AMSend = RadioC; - Receive = RadioC.Receive; - Snoop = RadioC.Snoop; - SendNotifier = RadioC; - - ReceiveDefault = RadioC.ReceiveDefault; - SnoopDefault = RadioC.SnoopDefault; - - Packet = RadioC.PacketForActiveMessage; - AMPacket = RadioC; - PacketAcknowledgements = RadioC; LowPowerListening = RadioC; PacketLink = RadioC; diff --git a/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc b/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc new file mode 100644 index 0000000000..6480a86718 --- /dev/null +++ b/tos/chips/atm128rfa1/radio/RFA1Ieee154MessageC.nc @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2007, Vanderbilt University + * 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 copyright holder 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 COPYRIGHT HOLDER OR 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: Miklos Maroti + */ + +#include + +#ifdef TFRAMES_ENABLED +#error "You cannot use Ieee154MessageC with TFRAMES_ENABLED defined" +#endif + +configuration RFA1Ieee154MessageC +{ + provides + { + interface SplitControl; + interface Resource as SendResource[uint8_t clint]; + + interface Ieee154Send; + interface Receive as Ieee154Receive; + interface Ieee154Packet; + interface Packet; + + interface Send as BareSend; + interface Receive as BareReceive; + interface Packet as BarePacket; + + interface SendNotifier; + interface PacketAcknowledgements; + interface LowPowerListening; + interface PacketLink; + interface RadioChannel; + + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + + interface LocalTime as LocalTimeRadio; + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ +// -------- Ieee154 Message + + components new Ieee154MessageLayerC(); + Ieee154MessageLayerC.Ieee154PacketLayer -> RadioC; + Ieee154MessageLayerC.SubSend -> RadioC.Ieee154Send; + Ieee154MessageLayerC.SubReceive -> RadioC.Ieee154Receive; + Ieee154MessageLayerC.RadioPacket -> RadioC.Ieee154Packet; + + Ieee154Send = Ieee154MessageLayerC.Ieee154Send; + Ieee154Receive = Ieee154MessageLayerC.Ieee154Receive; + Ieee154Packet = Ieee154MessageLayerC.Ieee154Packet; + Packet = Ieee154MessageLayerC.Packet; + + BareSend = Ieee154MessageLayerC.BareSend; + BareReceive = Ieee154MessageLayerC.BareReceive; + BarePacket = Ieee154MessageLayerC.BarePacket; + + SendNotifier = Ieee154MessageLayerC; + +// -------- Radio + + components RFA1RadioC as RadioC; + + SplitControl = RadioC; + SendResource = RadioC; + + PacketAcknowledgements = RadioC; + LowPowerListening = RadioC; + PacketLink = RadioC; + RadioChannel = RadioC; + + PacketLinkQuality = RadioC.PacketLinkQuality; + PacketTransmitPower = RadioC.PacketTransmitPower; + PacketRSSI = RadioC.PacketRSSI; + + LocalTimeRadio = RadioC; + PacketTimeStampMilli = RadioC; + PacketTimeStampRadio = RadioC; +} diff --git a/tos/chips/atm128rfa1/radio/RFA1RadioC.nc b/tos/chips/atm128rfa1/radio/RFA1RadioC.nc index ecd27566a6..5e9def1eb1 100644 --- a/tos/chips/atm128rfa1/radio/RFA1RadioC.nc +++ b/tos/chips/atm128rfa1/radio/RFA1RadioC.nc @@ -30,7 +30,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. * * Author: Miklos Maroti - * Author: Andras Biro */ #include @@ -42,30 +41,20 @@ configuration RFA1RadioC interface SplitControl; #ifndef IEEE154FRAMES_ENABLED - interface AMSend[am_id_t id]; - interface Receive[am_id_t id]; - interface Receive as Snoop[am_id_t id]; - interface SendNotifier[am_id_t id]; - - // for TOSThreads - interface Receive as ReceiveDefault[am_id_t id]; - interface Receive as SnoopDefault[am_id_t id]; - - interface AMPacket; - interface Packet as PacketForActiveMessage; + interface BareSend as TinyosSend; + interface BareReceive as TinyosReceive; + interface RadioPacket as TinyosPacket; #endif #ifndef TFRAMES_ENABLED - interface Ieee154Send; - interface Receive as Ieee154Receive; - interface SendNotifier as Ieee154Notifier; - interface Resource as SendResource[uint8_t clint]; - interface Ieee154Packet; - interface Packet as PacketForIeee154Message; + interface BareSend as Ieee154Send; + interface BareReceive as Ieee154Receive; + interface RadioPacket as Ieee154Packet; #endif + interface Ieee154PacketLayer; interface PacketAcknowledgements; interface LowPowerListening; interface PacketLink; @@ -110,57 +99,11 @@ implementation components new RadioAlarmC(); RadioAlarmC.Alarm -> RadioDriverLayerC; -// -------- Active Message - -#ifndef IEEE154FRAMES_ENABLED - components new ActiveMessageLayerC(); - ActiveMessageLayerC.Config -> RadioP; - ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC; - ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive; - ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket; - - AMSend = ActiveMessageLayerC; - Receive = ActiveMessageLayerC.Receive; - Snoop = ActiveMessageLayerC.Snoop; - SendNotifier = ActiveMessageLayerC; - AMPacket = ActiveMessageLayerC; - PacketForActiveMessage = ActiveMessageLayerC; - - ReceiveDefault = ActiveMessageLayerC.ReceiveDefault; - SnoopDefault = ActiveMessageLayerC.SnoopDefault; -#endif - -// -------- Automatic RadioSend Resource - -#ifndef IEEE154FRAMES_ENABLED -#ifndef TFRAMES_ENABLED - components new AutoResourceAcquireLayerC(); - AutoResourceAcquireLayerC.Resource -> SendResourceC.Resource[unique(RADIO_SEND_RESOURCE)]; -#else - components new DummyLayerC() as AutoResourceAcquireLayerC; -#endif - AutoResourceAcquireLayerC -> TinyosNetworkLayerC.TinyosSend; -#endif - // -------- RadioSend Resource #ifndef TFRAMES_ENABLED components new SimpleFcfsArbiterC(RADIO_SEND_RESOURCE) as SendResourceC; SendResource = SendResourceC; - -// -------- Ieee154 Message - - components new Ieee154MessageLayerC(); - Ieee154MessageLayerC.Ieee154PacketLayer -> Ieee154PacketLayerC; - Ieee154MessageLayerC.SubSend -> TinyosNetworkLayerC.Ieee154Send; - Ieee154MessageLayerC.SubReceive -> TinyosNetworkLayerC.Ieee154Receive; - Ieee154MessageLayerC.RadioPacket -> TinyosNetworkLayerC.Ieee154Packet; - - Ieee154Send = Ieee154MessageLayerC; - Ieee154Receive = Ieee154MessageLayerC; - Ieee154Notifier = Ieee154MessageLayerC; - Ieee154Packet = Ieee154PacketLayerC; - PacketForIeee154Message = Ieee154MessageLayerC; #endif // -------- Tinyos Network @@ -171,11 +114,25 @@ implementation TinyosNetworkLayerC.SubReceive -> PacketLinkLayerC; TinyosNetworkLayerC.SubPacket -> Ieee154PacketLayerC; +#ifndef IEEE154FRAMES_ENABLED + TinyosSend = TinyosNetworkLayerC.TinyosSend; + TinyosReceive = TinyosNetworkLayerC.TinyosReceive; + TinyosPacket = TinyosNetworkLayerC.TinyosPacket; +#endif + +#ifndef TFRAMES_ENABLED + Ieee154Send = TinyosNetworkLayerC.Ieee154Send; + Ieee154Receive = TinyosNetworkLayerC.Ieee154Receive; + Ieee154Packet = TinyosNetworkLayerC.Ieee154Packet; +#endif + // -------- IEEE 802.15.4 Packet components new Ieee154PacketLayerC(); Ieee154PacketLayerC.SubPacket -> PacketLinkLayerC; + Ieee154PacketLayer = Ieee154PacketLayerC; + // -------- UniqueLayer Send part (wired twice) components new UniqueLayerC(); @@ -198,7 +155,7 @@ implementation components new LowPowerListeningLayerC(); LowPowerListeningLayerC.Config -> RadioP; LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC; -#else +#else components new LowPowerListeningDummyC() as LowPowerListeningLayerC; #endif LowPowerListeningLayerC.SubControl -> MessageBufferLayerC; @@ -273,19 +230,9 @@ implementation components new DummyLayerC() as TrafficMonitorLayerC; #endif TrafficMonitorLayerC.Config -> RadioP; - TrafficMonitorLayerC -> RadioDriverDebugLayerC.RadioSend; + TrafficMonitorLayerC -> RadioDriverLayerC.RadioSend; TrafficMonitorLayerC -> RadioDriverLayerC.RadioReceive; - TrafficMonitorLayerC -> RadioDriverDebugLayerC.RadioState; - -// -------- Debug - -#ifdef RADIO_DEBUG - components new DebugLayerC("driver") as RadioDriverDebugLayerC; -#else - components new DummyLayerC() as RadioDriverDebugLayerC; -#endif - RadioDriverDebugLayerC.SubState -> RadioDriverLayerC; - RadioDriverDebugLayerC.SubSend -> RadioDriverLayerC; + TrafficMonitorLayerC -> RadioDriverLayerC.RadioState; // -------- Driver diff --git a/tos/chips/rf212/RF212Ieee154MessageC.nc b/tos/chips/rf212/RF212Ieee154MessageC.nc index 4b11764da9..42762bebb9 100644 --- a/tos/chips/rf212/RF212Ieee154MessageC.nc +++ b/tos/chips/rf212/RF212Ieee154MessageC.nc @@ -40,7 +40,7 @@ configuration RF212Ieee154MessageC { - provides + provides { interface SplitControl; @@ -70,29 +70,29 @@ configuration RF212Ieee154MessageC implementation { - components RF212RadioC; + components RF212RadioC as RadioC; - SplitControl = RF212RadioC; + SplitControl = RadioC; - Ieee154Send = RF212RadioC.Ieee154Send; - Ieee154Receive = RF212RadioC.Ieee154Receive; - SendNotifier = RF212RadioC.Ieee154Notifier; + Ieee154Send = RadioC.Ieee154Send; + Ieee154Receive = RadioC.Ieee154Receive; + SendNotifier = RadioC.Ieee154Notifier; - Packet = RF212RadioC.PacketForIeee154Message; - Ieee154Packet = RF212RadioC; - SendResource = RF212RadioC; + Packet = RadioC.PacketForIeee154Message; + Ieee154Packet = RadioC; + SendResource = RadioC; - PacketAcknowledgements = RF212RadioC; - LowPowerListening = RF212RadioC; - PacketLink = RF212RadioC; + PacketAcknowledgements = RadioC; + LowPowerListening = RadioC; + PacketLink = RadioC; - RadioChannel = RF212RadioC; + RadioChannel = RadioC; - PacketLinkQuality = RF212RadioC.PacketLinkQuality; - PacketTransmitPower = RF212RadioC.PacketTransmitPower; - PacketRSSI = RF212RadioC.PacketRSSI; + PacketLinkQuality = RadioC.PacketLinkQuality; + PacketTransmitPower = RadioC.PacketTransmitPower; + PacketRSSI = RadioC.PacketRSSI; - LocalTimeRadio = RF212RadioC; - PacketTimeStampMilli = RF212RadioC; - PacketTimeStampRadio = RF212RadioC; + LocalTimeRadio = RadioC; + PacketTimeStampMilli = RadioC; + PacketTimeStampRadio = RadioC; } diff --git a/tos/chips/rf230/RF230ActiveMessageC.nc b/tos/chips/rf230/RF230ActiveMessageC.nc index 54781d8adc..af1126b3c0 100644 --- a/tos/chips/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf230/RF230ActiveMessageC.nc @@ -74,21 +74,41 @@ configuration RF230ActiveMessageC implementation { +// -------- Active Message + + components new ActiveMessageLayerC(); + ActiveMessageLayerC.Config -> RadioP; + ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC; + ActiveMessageLayerC.SubReceive -> RadioC.TinyosReceive; + ActiveMessageLayerC.SubPacket -> RadioC.TinyosPacket; + + AMSend = ActiveMessageLayerC; + Receive = ActiveMessageLayerC.Receive; + Snoop = ActiveMessageLayerC.Snoop; + SendNotifier = ActiveMessageLayerC; + AMPacket = ActiveMessageLayerC; + Packet = ActiveMessageLayerC; + + ReceiveDefault = ActiveMessageLayerC.ReceiveDefault; + SnoopDefault = ActiveMessageLayerC.SnoopDefault; + +// -------- Automatic RadioSend Resource + +#ifndef TFRAMES_ENABLED + components new AutoResourceAcquireLayerC(); + AutoResourceAcquireLayerC.Resource -> RadioC.SendResource[unique(RADIO_SEND_RESOURCE)]; +#else + components new DummyLayerC() as AutoResourceAcquireLayerC; +#endif + AutoResourceAcquireLayerC -> RadioC.TinyosSend; + +// -------- Radio + components RF230RadioC as RadioC; + components RF230RadioP as RadioP; SplitControl = RadioC; - AMSend = RadioC; - Receive = RadioC.Receive; - Snoop = RadioC.Snoop; - SendNotifier = RadioC; - - ReceiveDefault = RadioC.ReceiveDefault; - SnoopDefault = RadioC.SnoopDefault; - - Packet = RadioC.PacketForActiveMessage; - AMPacket = RadioC; - PacketAcknowledgements = RadioC; LowPowerListening = RadioC; PacketLink = RadioC; diff --git a/tos/chips/rf230/RF230Ieee154MessageC.nc b/tos/chips/rf230/RF230Ieee154MessageC.nc index d8b60936b6..7966731b37 100644 --- a/tos/chips/rf230/RF230Ieee154MessageC.nc +++ b/tos/chips/rf230/RF230Ieee154MessageC.nc @@ -40,22 +40,24 @@ configuration RF230Ieee154MessageC { - provides + provides { interface SplitControl; + interface Resource as SendResource[uint8_t clint]; interface Ieee154Send; interface Receive as Ieee154Receive; - interface SendNotifier; - interface Ieee154Packet; interface Packet; - interface Resource as SendResource[uint8_t clint]; + interface Send as BareSend; + interface Receive as BareReceive; + interface Packet as BarePacket; + + interface SendNotifier; interface PacketAcknowledgements; interface LowPowerListening; interface PacketLink; - interface RadioChannel; interface PacketField as PacketLinkQuality; @@ -70,29 +72,42 @@ configuration RF230Ieee154MessageC implementation { - components RF230RadioC; +// -------- Ieee154 Message + + components new Ieee154MessageLayerC(); + Ieee154MessageLayerC.Ieee154PacketLayer -> RadioC; + Ieee154MessageLayerC.SubSend -> RadioC.Ieee154Send; + Ieee154MessageLayerC.SubReceive -> RadioC.Ieee154Receive; + Ieee154MessageLayerC.RadioPacket -> RadioC.Ieee154Packet; + + Ieee154Send = Ieee154MessageLayerC.Ieee154Send; + Ieee154Receive = Ieee154MessageLayerC.Ieee154Receive; + Ieee154Packet = Ieee154MessageLayerC.Ieee154Packet; + Packet = Ieee154MessageLayerC.Packet; + + BareSend = Ieee154MessageLayerC.BareSend; + BareReceive = Ieee154MessageLayerC.BareReceive; + BarePacket = Ieee154MessageLayerC.BarePacket; - SplitControl = RF230RadioC; + SendNotifier = Ieee154MessageLayerC; - Ieee154Send = RF230RadioC.Ieee154Send; - Ieee154Receive = RF230RadioC.Ieee154Receive; - SendNotifier = RF230RadioC.Ieee154Notifier; +// -------- Radio - Packet = RF230RadioC.PacketForIeee154Message; - Ieee154Packet = RF230RadioC; - SendResource = RF230RadioC; + components RF230RadioC as RadioC; - PacketAcknowledgements = RF230RadioC; - LowPowerListening = RF230RadioC; - PacketLink = RF230RadioC; + SplitControl = RadioC; + SendResource = RadioC; - RadioChannel = RF230RadioC; + PacketAcknowledgements = RadioC; + LowPowerListening = RadioC; + PacketLink = RadioC; + RadioChannel = RadioC; - PacketLinkQuality = RF230RadioC.PacketLinkQuality; - PacketTransmitPower = RF230RadioC.PacketTransmitPower; - PacketRSSI = RF230RadioC.PacketRSSI; + PacketLinkQuality = RadioC.PacketLinkQuality; + PacketTransmitPower = RadioC.PacketTransmitPower; + PacketRSSI = RadioC.PacketRSSI; - LocalTimeRadio = RF230RadioC; - PacketTimeStampMilli = RF230RadioC; - PacketTimeStampRadio = RF230RadioC; + LocalTimeRadio = RadioC; + PacketTimeStampMilli = RadioC; + PacketTimeStampRadio = RadioC; } diff --git a/tos/chips/rf230/RF230RadioC.nc b/tos/chips/rf230/RF230RadioC.nc index 59042f02a6..65af694df4 100644 --- a/tos/chips/rf230/RF230RadioC.nc +++ b/tos/chips/rf230/RF230RadioC.nc @@ -41,30 +41,20 @@ configuration RF230RadioC interface SplitControl; #ifndef IEEE154FRAMES_ENABLED - interface AMSend[am_id_t id]; - interface Receive[am_id_t id]; - interface Receive as Snoop[am_id_t id]; - interface SendNotifier[am_id_t id]; - - // for TOSThreads - interface Receive as ReceiveDefault[am_id_t id]; - interface Receive as SnoopDefault[am_id_t id]; - - interface AMPacket; - interface Packet as PacketForActiveMessage; + interface BareSend as TinyosSend; + interface BareReceive as TinyosReceive; + interface RadioPacket as TinyosPacket; #endif #ifndef TFRAMES_ENABLED - interface Ieee154Send; - interface Receive as Ieee154Receive; - interface SendNotifier as Ieee154Notifier; - interface Resource as SendResource[uint8_t clint]; - interface Ieee154Packet; - interface Packet as PacketForIeee154Message; + interface BareSend as Ieee154Send; + interface BareReceive as Ieee154Receive; + interface RadioPacket as Ieee154Packet; #endif + interface Ieee154PacketLayer; interface PacketAcknowledgements; interface LowPowerListening; interface PacketLink; @@ -109,57 +99,11 @@ implementation components new RadioAlarmC(); RadioAlarmC.Alarm -> RadioDriverLayerC; -// -------- Active Message - -#ifndef IEEE154FRAMES_ENABLED - components new ActiveMessageLayerC(); - ActiveMessageLayerC.Config -> RadioP; - ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC; - ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive; - ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket; - - AMSend = ActiveMessageLayerC; - Receive = ActiveMessageLayerC.Receive; - Snoop = ActiveMessageLayerC.Snoop; - SendNotifier = ActiveMessageLayerC; - AMPacket = ActiveMessageLayerC; - PacketForActiveMessage = ActiveMessageLayerC; - - ReceiveDefault = ActiveMessageLayerC.ReceiveDefault; - SnoopDefault = ActiveMessageLayerC.SnoopDefault; -#endif - -// -------- Automatic RadioSend Resource - -#ifndef IEEE154FRAMES_ENABLED -#ifndef TFRAMES_ENABLED - components new AutoResourceAcquireLayerC(); - AutoResourceAcquireLayerC.Resource -> SendResourceC.Resource[unique(RADIO_SEND_RESOURCE)]; -#else - components new DummyLayerC() as AutoResourceAcquireLayerC; -#endif - AutoResourceAcquireLayerC -> TinyosNetworkLayerC.TinyosSend; -#endif - // -------- RadioSend Resource #ifndef TFRAMES_ENABLED components new SimpleFcfsArbiterC(RADIO_SEND_RESOURCE) as SendResourceC; SendResource = SendResourceC; - -// -------- Ieee154 Message - - components new Ieee154MessageLayerC(); - Ieee154MessageLayerC.Ieee154PacketLayer -> Ieee154PacketLayerC; - Ieee154MessageLayerC.SubSend -> TinyosNetworkLayerC.Ieee154Send; - Ieee154MessageLayerC.SubReceive -> TinyosNetworkLayerC.Ieee154Receive; - Ieee154MessageLayerC.RadioPacket -> TinyosNetworkLayerC.Ieee154Packet; - - Ieee154Send = Ieee154MessageLayerC; - Ieee154Receive = Ieee154MessageLayerC; - Ieee154Notifier = Ieee154MessageLayerC; - Ieee154Packet = Ieee154PacketLayerC; - PacketForIeee154Message = Ieee154MessageLayerC; #endif // -------- Tinyos Network @@ -170,11 +114,25 @@ implementation TinyosNetworkLayerC.SubReceive -> PacketLinkLayerC; TinyosNetworkLayerC.SubPacket -> Ieee154PacketLayerC; +#ifndef IEEE154FRAMES_ENABLED + TinyosSend = TinyosNetworkLayerC.TinyosSend; + TinyosReceive = TinyosNetworkLayerC.TinyosReceive; + TinyosPacket = TinyosNetworkLayerC.TinyosPacket; +#endif + +#ifndef TFRAMES_ENABLED + Ieee154Send = TinyosNetworkLayerC.Ieee154Send; + Ieee154Receive = TinyosNetworkLayerC.Ieee154Receive; + Ieee154Packet = TinyosNetworkLayerC.Ieee154Packet; +#endif + // -------- IEEE 802.15.4 Packet components new Ieee154PacketLayerC(); Ieee154PacketLayerC.SubPacket -> PacketLinkLayerC; + Ieee154PacketLayer = Ieee154PacketLayerC; + // -------- UniqueLayer Send part (wired twice) components new UniqueLayerC(); diff --git a/tos/lib/net/blip/IPDispatchC.nc b/tos/lib/net/blip/IPDispatchC.nc index 95a61a2c9d..464e63f733 100644 --- a/tos/lib/net/blip/IPDispatchC.nc +++ b/tos/lib/net/blip/IPDispatchC.nc @@ -21,7 +21,7 @@ */ /** - * + * * */ #include "IPDispatch.h" @@ -34,13 +34,23 @@ configuration IPDispatchC { interface BlipStatistics; } } implementation { - + components MainC; components NoLedsC as LedsC; /* IPDispatchP wiring -- fragment rassembly and lib6lowpan bindings */ components IPDispatchP; +#if defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB) || \ + defined(PLATFORM_EPIC) || defined(PLATFORM_SHIMMER) || \ + defined(PLATFORM_SHIMMER2) || defined(PLATFORM_INTELMOTE2) || \ + defined(PLATFORM_Z1) + // cc2420 platforms components CC2420RadioC as MessageC; +#elif defined(PLATFORM_IRIS) || defined(PLATFORM_MULLE) || \ + defined(PLATFORM_UCMINI) + // rfxlink platforms + components Ieee154MessageC as MessageC; +#endif components ReadLqiC; components new TimerMilliC(); @@ -75,7 +85,7 @@ configuration IPDispatchC { components new PoolC(struct send_entry, N_FRAGMENTS) as SendEntryPool; components new QueueC(struct send_entry *, N_FRAGMENTS); components new PoolC(struct send_info, N_CONCURRENT_SENDS) as SendInfoPool; - + IPDispatchP.FragPool -> FragPool; IPDispatchP.SendEntryPool -> SendEntryPool; IPDispatchP.SendInfoPool -> SendInfoPool; diff --git a/tos/lib/net/blip/Ieee154AddressC.nc b/tos/lib/net/blip/Ieee154AddressC.nc index 74d83eb43d..e4b4595a08 100644 --- a/tos/lib/net/blip/Ieee154AddressC.nc +++ b/tos/lib/net/blip/Ieee154AddressC.nc @@ -5,13 +5,11 @@ configuration Ieee154AddressC { } implementation { components Ieee154AddressP; components LocalIeeeEui64C; - components MainC; Ieee154Address = Ieee154AddressP; - MainC.SoftwareInit -> Ieee154AddressP; Ieee154AddressP.LocalIeeeEui64 -> LocalIeeeEui64C; // workaround until the radio stack uses this interface - components CC2420ControlC; - Ieee154AddressP.CC2420Config -> CC2420ControlC; + components ActiveMessageAddressC; + Ieee154AddressP.ActiveMessageAddress -> ActiveMessageAddressC; } diff --git a/tos/lib/net/blip/Ieee154AddressP.nc b/tos/lib/net/blip/Ieee154AddressP.nc index 82a58a8b81..d57b84816f 100644 --- a/tos/lib/net/blip/Ieee154AddressP.nc +++ b/tos/lib/net/blip/Ieee154AddressP.nc @@ -1,29 +1,21 @@ module Ieee154AddressP { provides { - interface Init; interface Ieee154Address; } uses { interface LocalIeeeEui64; - interface CC2420Config; + interface ActiveMessageAddress; } } implementation { - ieee154_saddr_t m_saddr; - ieee154_panid_t m_panid; - - command error_t Init.init() { - m_saddr = TOS_NODE_ID; - m_panid = TOS_AM_GROUP; - return SUCCESS; - } command ieee154_panid_t Ieee154Address.getPanId() { - return m_panid; + return call ActiveMessageAddress.amGroup(); } command ieee154_saddr_t Ieee154Address.getShortAddr() { - return m_saddr; + return call ActiveMessageAddress.amAddress(); } + command ieee154_laddr_t Ieee154Address.getExtAddr() { ieee154_laddr_t addr = call LocalIeeeEui64.getId(); int i; @@ -39,12 +31,12 @@ module Ieee154AddressP { } command error_t Ieee154Address.setShortAddr(ieee154_saddr_t addr) { - m_saddr = addr; - call CC2420Config.setShortAddr(addr); - call CC2420Config.sync(); + call ActiveMessageAddress.setAddress(call ActiveMessageAddress.amGroup(), addr); signal Ieee154Address.changed(); return SUCCESS; } - event void CC2420Config.syncDone(error_t err) {} + async event void ActiveMessageAddress.changed() { + signal Ieee154Address.changed(); + } } diff --git a/tos/lib/net/blip/ReadLqiC.nc b/tos/lib/net/blip/ReadLqiC.nc index 3949c209b1..611ee4193a 100644 --- a/tos/lib/net/blip/ReadLqiC.nc +++ b/tos/lib/net/blip/ReadLqiC.nc @@ -4,14 +4,14 @@ * the LQI reading the radio provides. This module wraps the * different ways in platform-independent logic. * - * + * * @author Stephen Dawson-Haggerty */ configuration ReadLqiC { provides interface ReadLqi; } implementation { - + #if defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB) || \ defined(PLATFORM_EPIC) || defined(PLATFORM_SHIMMER) || \ defined(PLATFORM_SHIMMER2) || defined(PLATFORM_INTELMOTE2) || \ @@ -20,11 +20,11 @@ configuration ReadLqiC { components CC2420ReadLqiC, CC2420PacketC; ReadLqi = CC2420ReadLqiC; CC2420ReadLqiC.CC2420Packet -> CC2420PacketC; -#elif defined(PLATFORM_IRIS) || defined(PLATFORM_MULLE) - components RF230ReadLqiC, RF230Ieee154MessageC; - ReadLqi = RF230ReadLqiC; - RF230ReadLqiC.SubLqi -> RF230Ieee154MessageC.PacketLinkQuality; - RF230ReadLqiC.SubRssi -> RF230Ieee154MessageC.PacketRSSI; +#elif defined(PLATFORM_IRIS) || defined(PLATFORM_MULLE) || defined(PLATFORM_UCMINI) + components RFXLinkReadLqiC, Ieee154MessageC; + ReadLqi = RFXLinkReadLqiC; + RFXLinkReadLqiC.SubLqi -> Ieee154MessageC.PacketLinkQuality; + RFXLinkReadLqiC.SubRssi -> Ieee154MessageC.PacketRSSI; #else #error "No radio support is available for your platform" #endif diff --git a/tos/lib/net/blip/platform/RF230ReadLqiC.nc b/tos/lib/net/blip/platform/RFXLinkReadLqiC.nc similarity index 95% rename from tos/lib/net/blip/platform/RF230ReadLqiC.nc rename to tos/lib/net/blip/platform/RFXLinkReadLqiC.nc index 461a5747b6..c2751c72ba 100644 --- a/tos/lib/net/blip/platform/RF230ReadLqiC.nc +++ b/tos/lib/net/blip/platform/RFXLinkReadLqiC.nc @@ -5,7 +5,7 @@ uint16_t adjustLQI(uint8_t val) { return result; } -module RF230ReadLqiC { +module RFXLinkReadLqiC { provides interface ReadLqi; uses interface PacketField as SubLqi; uses interface PacketField as SubRssi; diff --git a/tos/lib/rfxlink/layers/AutoResourceAcquireLayerC.nc b/tos/lib/rfxlink/layers/AutoResourceAcquireLayerC.nc index da8a5e0b2b..264d222da4 100644 --- a/tos/lib/rfxlink/layers/AutoResourceAcquireLayerC.nc +++ b/tos/lib/rfxlink/layers/AutoResourceAcquireLayerC.nc @@ -32,6 +32,8 @@ * Author: Miklos Maroti */ +#include "message.h" + generic module AutoResourceAcquireLayerC() { provides @@ -50,34 +52,50 @@ implementation { message_t *pending; + enum + { + CLIENT_COUNT = uniqueCount(RADIO_SEND_RESOURCE), + }; + command error_t BareSend.send(message_t* msg) { - if( call Resource.immediateRequest() == SUCCESS ) + if( CLIENT_COUNT >= 2 ) { - error_t result = call SubSend.send(msg); - if( result != SUCCESS ) - call Resource.release(); + if( call Resource.immediateRequest() == SUCCESS ) + { + error_t result = call SubSend.send(msg); + if( result != SUCCESS ) + call Resource.release(); + + return result; + } - return result; + pending = msg; + return call Resource.request(); } + else + return call SubSend.send(msg); - pending = msg; - return call Resource.request(); } event void Resource.granted() { - error_t result = call SubSend.send(pending); - if( result != SUCCESS ) + if( CLIENT_COUNT >= 2 ) { - call Resource.release(); - signal BareSend.sendDone(pending, result); + error_t result = call SubSend.send(pending); + if( result != SUCCESS ) + { + call Resource.release(); + signal BareSend.sendDone(pending, result); + } } } event void SubSend.sendDone(message_t* msg, error_t result) { - call Resource.release(); + if( CLIENT_COUNT >= 2 ) + call Resource.release(); + signal BareSend.sendDone(msg, result); } diff --git a/tos/lib/rfxlink/layers/Ieee154MessageLayerC.nc b/tos/lib/rfxlink/layers/Ieee154MessageLayerC.nc index 138ebbf439..7b1a139541 100644 --- a/tos/lib/rfxlink/layers/Ieee154MessageLayerC.nc +++ b/tos/lib/rfxlink/layers/Ieee154MessageLayerC.nc @@ -32,14 +32,23 @@ * Author: Miklos Maroti */ +#include +#include + generic module Ieee154MessageLayerC() { provides { interface Packet; + interface Ieee154Packet; interface Ieee154Send; interface Receive as Ieee154Receive; + interface SendNotifier; + + interface Send as BareSend; + interface Receive as BareReceive; + interface Packet as BarePacket; } uses @@ -88,6 +97,53 @@ implementation return getPayload(msg); } +/*----------------- Ieee154Packet -----------------*/ + + command ieee154_saddr_t Ieee154Packet.address() + { + return call Ieee154PacketLayer.localAddr(); + } + + command ieee154_saddr_t Ieee154Packet.destination(message_t* msg) + { + return call Ieee154PacketLayer.getDestAddr(msg); + } + + command ieee154_saddr_t Ieee154Packet.source(message_t* msg) + { + return call Ieee154PacketLayer.getSrcAddr(msg); + } + + command void Ieee154Packet.setDestination(message_t* msg, ieee154_saddr_t addr) + { + call Ieee154PacketLayer.setDestAddr(msg, addr); + } + + command void Ieee154Packet.setSource(message_t* msg, ieee154_saddr_t addr) + { + call Ieee154PacketLayer.setSrcAddr(msg, addr); + } + + command bool Ieee154Packet.isForMe(message_t* msg) + { + return call Ieee154PacketLayer.isForMe(msg); + } + + command ieee154_panid_t Ieee154Packet.pan(message_t* msg) + { + return call Ieee154PacketLayer.getDestPan(msg); + } + + command void Ieee154Packet.setPan(message_t* msg, ieee154_panid_t grp) + { + call Ieee154PacketLayer.setDestPan(msg, grp); + } + + command ieee154_panid_t Ieee154Packet.localPan() + { + return call Ieee154PacketLayer.localPan(); + } + /*----------------- Ieee154Send -----------------*/ command void * Ieee154Send.getPayload(message_t* msg, uint8_t len) @@ -126,7 +182,9 @@ implementation event void SubSend.sendDone(message_t* msg, error_t error) { + // This is a hack to call both, but both should not be used simultaneously signal Ieee154Send.sendDone(msg, error); + signal BareSend.sendDone(msg, error); } default event void Ieee154Send.sendDone(message_t* msg, error_t error) @@ -148,7 +206,85 @@ implementation return msg; } +/*----------------- BarePacket -----------------*/ + + typedef nx_struct ieee154_header_t + { + nx_uint8_t length; + ieee154_simple_header_t ieee154; +#ifndef TFRAMES_ENABLED + network_header_t network; +#endif + } ieee154_header_t; + + command void BarePacket.clear(message_t* msg) + { + // to clear flags + call RadioPacket.clear(msg); + } + + command uint8_t BarePacket.payloadLength(message_t* msg) + { + return call RadioPacket.payloadLength(msg) + + sizeof(ieee154_header_t); + } + + command void BarePacket.setPayloadLength(message_t* msg, uint8_t len) + { + call RadioPacket.setPayloadLength(msg, + len - sizeof(ieee154_header_t)); + } + + command uint8_t BarePacket.maxPayloadLength() + { + return call RadioPacket.maxPayloadLength() + + sizeof(ieee154_header_t); + } + + command void* BarePacket.getPayload(message_t* msg, uint8_t len) + { + if( len > call RadioPacket.maxPayloadLength() ) + return NULL; + + return getPayload(msg) - sizeof(ieee154_header_t); + } + +/*----------------- BareSend -----------------*/ + + command error_t BareSend.send(message_t* msg, uint8_t len) + { + call BarePacket.setPayloadLength(msg, len); + return call SubSend.send(msg); + } + + command error_t BareSend.cancel(message_t* msg) + { + return call SubSend.cancel(msg); + } + + command uint8_t BareSend.maxPayloadLength() + { + return call BarePacket.maxPayloadLength(); + } + + command void* BareSend.getPayload(message_t* msg, uint8_t len) + { + return call BarePacket.getPayload(msg, len); + } + + default event void BareSend.sendDone(message_t* msg, error_t error) + { + } + +/*----------------- BareReceive -----------------*/ + default event message_t* Ieee154Receive.receive(message_t* msg, void* payload, uint8_t len) + { + return signal BareReceive.receive(msg, payload - sizeof(ieee154_header_t), + len + sizeof(ieee154_header_t)); + } + + default event message_t* BareReceive.receive(message_t *msg, void *payload, uint8_t len) { return msg; } diff --git a/tos/lib/rfxlink/layers/Ieee154PacketLayerC.nc b/tos/lib/rfxlink/layers/Ieee154PacketLayerC.nc index b46f3799dd..7cd65342fa 100644 --- a/tos/lib/rfxlink/layers/Ieee154PacketLayerC.nc +++ b/tos/lib/rfxlink/layers/Ieee154PacketLayerC.nc @@ -37,7 +37,6 @@ generic configuration Ieee154PacketLayerC() provides { interface Ieee154PacketLayer; - interface Ieee154Packet; interface RadioPacket; } @@ -53,7 +52,6 @@ implementation Ieee154PacketLayerP.ActiveMessageAddress -> ActiveMessageAddressC; Ieee154PacketLayer = Ieee154PacketLayerP; - Ieee154Packet = Ieee154PacketLayerP; RadioPacket = Ieee154PacketLayerP; SubPacket = Ieee154PacketLayerP; } diff --git a/tos/lib/rfxlink/layers/Ieee154PacketLayerP.nc b/tos/lib/rfxlink/layers/Ieee154PacketLayerP.nc index 12927c83cb..85c52b446b 100644 --- a/tos/lib/rfxlink/layers/Ieee154PacketLayerP.nc +++ b/tos/lib/rfxlink/layers/Ieee154PacketLayerP.nc @@ -39,7 +39,6 @@ generic module Ieee154PacketLayerP() provides { interface Ieee154PacketLayer; - interface Ieee154Packet; interface RadioPacket; } @@ -230,53 +229,6 @@ implementation { } -/*----------------- Ieee154Packet -----------------*/ - - command ieee154_saddr_t Ieee154Packet.address() - { - return call Ieee154PacketLayer.localAddr(); - } - - command ieee154_saddr_t Ieee154Packet.destination(message_t* msg) - { - return call Ieee154PacketLayer.getDestAddr(msg); - } - - command ieee154_saddr_t Ieee154Packet.source(message_t* msg) - { - return call Ieee154PacketLayer.getSrcAddr(msg); - } - - command void Ieee154Packet.setDestination(message_t* msg, ieee154_saddr_t addr) - { - call Ieee154PacketLayer.setDestAddr(msg, addr); - } - - command void Ieee154Packet.setSource(message_t* msg, ieee154_saddr_t addr) - { - call Ieee154PacketLayer.setSrcAddr(msg, addr); - } - - command bool Ieee154Packet.isForMe(message_t* msg) - { - return call Ieee154PacketLayer.isForMe(msg); - } - - command ieee154_panid_t Ieee154Packet.pan(message_t* msg) - { - return call Ieee154PacketLayer.getDestPan(msg); - } - - command void Ieee154Packet.setPan(message_t* msg, ieee154_panid_t grp) - { - call Ieee154PacketLayer.setDestPan(msg, grp); - } - - command ieee154_panid_t Ieee154Packet.localPan() - { - return call Ieee154PacketLayer.localPan(); - } - /*----------------- RadioPacket -----------------*/ async command uint8_t RadioPacket.headerLength(message_t* msg) diff --git a/tos/lib/rfxlink/layers/TinyosNetworkLayerC.nc b/tos/lib/rfxlink/layers/TinyosNetworkLayerC.nc index 81e3ceb914..0489280c5c 100644 --- a/tos/lib/rfxlink/layers/TinyosNetworkLayerC.nc +++ b/tos/lib/rfxlink/layers/TinyosNetworkLayerC.nc @@ -227,5 +227,33 @@ implementation return signal Ieee154Receive.receive(msg); } +#endif + +/*----------------- Default Events -----------------*/ + +#ifndef IEEE154FRAMES_ENABLED + + default event void TinyosSend.sendDone(message_t* msg, error_t result) + { + } + + default event message_t* TinyosReceive.receive(message_t *msg) + { + return msg; + } + +#endif + +#ifndef TFRAMES_ENABLED + + default event void Ieee154Send.sendDone(message_t* msg, error_t result) + { + } + + default event message_t* Ieee154Receive.receive(message_t *msg) + { + return msg; + } + #endif } diff --git a/tos/platforms/iris/Ieee154MessageC.nc b/tos/platforms/iris/Ieee154MessageC.nc index 56cc27ac70..948098e60f 100644 --- a/tos/platforms/iris/Ieee154MessageC.nc +++ b/tos/platforms/iris/Ieee154MessageC.nc @@ -37,20 +37,27 @@ configuration Ieee154MessageC provides { interface SplitControl; + interface Resource as SendResource[uint8_t clint]; interface Ieee154Send; interface Receive as Ieee154Receive; - interface SendNotifier; - - interface Packet; interface Ieee154Packet; - interface Resource as SendResource[uint8_t clint]; + interface Packet; + + interface Send as BareSend; + interface Receive as BareReceive; + interface Packet as BarePacket; + interface SendNotifier; interface PacketAcknowledgements; interface LowPowerListening; interface PacketLink; interface RadioChannel; + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + interface PacketTimeStamp as PacketTimeStampMicro; interface PacketTimeStamp as PacketTimeStampMilli; } @@ -61,20 +68,27 @@ implementation components RF230Ieee154MessageC as MessageC; SplitControl = MessageC; + SendResource = MessageC; - Ieee154Send = MessageC; - Ieee154Receive = MessageC; - SendNotifier = MessageC; + Ieee154Send = MessageC.Ieee154Send; + Ieee154Receive = MessageC.Ieee154Receive; + Ieee154Packet = MessageC.Ieee154Packet; + Packet = MessageC.Packet; - Packet = MessageC; - Ieee154Packet = MessageC; - SendResource = MessageC; + BareSend = MessageC.BareSend; + BareReceive = MessageC.BareReceive; + BarePacket = MessageC.BarePacket; + SendNotifier = MessageC; PacketAcknowledgements = MessageC; LowPowerListening = MessageC; PacketLink = MessageC; RadioChannel = MessageC; + PacketLinkQuality = MessageC.PacketLinkQuality; + PacketTransmitPower = MessageC.PacketTransmitPower; + PacketRSSI = MessageC.PacketRSSI; + PacketTimeStampMilli = MessageC; PacketTimeStampMicro = MessageC; } diff --git a/tos/platforms/mica/AlarmMilli32C.nc b/tos/platforms/mica/AlarmMilli32C.nc new file mode 100644 index 0000000000..15e3a9e39f --- /dev/null +++ b/tos/platforms/mica/AlarmMilli32C.nc @@ -0,0 +1,56 @@ + +/* Copyright (c) 2000-2003 The Regents of the University of California. + * 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 copyright holders 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 COPYRIGHT HOLDER OR 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. + */ + +/** + * AlarmMilliC is the alarm for async millisecond alarms + * + * @author Cory Sharp + * @see Please refer to TEP 102 for more information about this component and its + * intended use. + */ + +generic configuration AlarmMilli32C() +{ + provides interface Alarm; +} +implementation +{ + components new Alarm32khz32C() as AlarmFrom; + components CounterMilli32C as Counter; + components new TransformAlarmC(TMilli,uint32_t,T32khz,uint32_t,5) as Transform; + + Alarm = Transform; + + Transform.AlarmFrom -> AlarmFrom; + Transform.Counter -> Counter; +} + diff --git a/tos/platforms/mica/CounterMilli32C.nc b/tos/platforms/mica/CounterMilli32C.nc new file mode 100644 index 0000000000..09248d0e69 --- /dev/null +++ b/tos/platforms/mica/CounterMilli32C.nc @@ -0,0 +1,54 @@ + +/* Copyright (c) 2000-2003 The Regents of the University of California. + * 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 copyright holders 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 COPYRIGHT HOLDER OR 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. + */ + +/** + * CounterMilli32C provides at 32-bit counter at 1024 ticks per second. + * + * @author Cory Sharp + * @see Please refer to TEP 102 for more information about this component and its + * intended use. + */ + +configuration CounterMilli32C +{ + provides interface Counter; +} +implementation +{ + components Counter32khz32C as CounterFrom; + components new TransformCounterC(TMilli,uint32_t,T32khz,uint32_t,5,uint32_t) as Transform; + + Counter = Transform.Counter; + + Transform.CounterFrom -> CounterFrom; +} + diff --git a/tos/platforms/mica/PlatformLed.h b/tos/platforms/mica/PlatformLed.h new file mode 100644 index 0000000000..9a87c7ccaa --- /dev/null +++ b/tos/platforms/mica/PlatformLed.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2010 People Power Co. + * 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 People Power 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 + * PEOPLE POWER CO. 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 + * + */ + +#ifndef _PLATFORM_TMOTE_LED_H_ +#define _PLATFORM_TMOTE_LED_H_ + +/** Constants used in the generic LedC module to determine how many + * named Led interfaces should be published. The value should match + * the size of the table in PlatformLedsP, but we're not going to + * guess that table's public name. */ +#define PLATFORM_LED_COUNT 3 + +/** Map to the LED index for the red LED */ +#define PLATFORM_LED_RED 0 + +/** Map to the LED index for the green LED */ +#define PLATFORM_LED_GREEN 1 + +/** Map to the LED index for the blue LED */ +#define PLATFORM_LED_BLUE 2 + +#endif // _PLATFORM_TMOTE_LED_H_ diff --git a/tos/platforms/mica/PlatformLedC.nc b/tos/platforms/mica/PlatformLedC.nc new file mode 100644 index 0000000000..4388d1e1af --- /dev/null +++ b/tos/platforms/mica/PlatformLedC.nc @@ -0,0 +1,49 @@ +/* Copyright (c) 2010 People Power Co. + * 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 People Power 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 + * PEOPLE POWER CO. 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 + * + */ + +/** Defines the Led and MultiLed interfaces in terms of the underlying + * LedsC component. + * + * @author Peter A. Bigot + */ +configuration PlatformLedC { + provides { + interface MultiLed; + interface Led[uint8_t led_id]; + } +} implementation { + components LedsC; + components PlatformLedP; + + MultiLed = PlatformLedP; + Led = PlatformLedP; + PlatformLedP.Leds -> LedsC; +} diff --git a/tos/platforms/mica/PlatformLedP.nc b/tos/platforms/mica/PlatformLedP.nc new file mode 100644 index 0000000000..0e05a02f51 --- /dev/null +++ b/tos/platforms/mica/PlatformLedP.nc @@ -0,0 +1,95 @@ +/* Copyright (c) 2010 People Power Co. + * 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 People Power 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 + * PEOPLE POWER CO. 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 + * + */ + +/** Defines the Led and MultiLed interfaces in terms of the underlying + * LedsC component. + * + * @author Peter A. Bigot + */ +module PlatformLedP { + provides { + interface MultiLed; + interface Led[uint8_t led_id]; + } + uses { + interface Leds; + } +} implementation { + + async command void Led.on[ uint8_t led_id ] () + { + switch(led_id) { + case 0: call Leds.led0On(); break; + case 1: call Leds.led1On(); break; + case 2: call Leds.led2On(); break; + } + } + + async command void Led.off[ uint8_t led_id ] () + { + switch(led_id) { + case 0: call Leds.led0Off(); break; + case 1: call Leds.led1Off(); break; + case 2: call Leds.led2Off(); break; + } + } + + async command void Led.set[ uint8_t led_id ] (bool turn_on) + { + if (turn_on) { + call Led.on[led_id](); + } else { + call Led.off[led_id](); + } + } + + async command void Led.toggle[ uint8_t led_id ] () + { + switch(led_id) { + case 0: call Leds.led0Toggle(); break; + case 1: call Leds.led1Toggle(); break; + case 2: call Leds.led2Toggle(); break; + } + } + + async command unsigned int MultiLed.get () { return call Leds.get(); } + + async command void MultiLed.set (unsigned int val) { call Leds.set(val); } + + async command void MultiLed.on (unsigned int led_id) { call Led.on[led_id](); } + + async command void MultiLed.off (unsigned int led_id) { call Led.off[led_id](); } + + async command void MultiLed.setSingle (unsigned int led_id, bool turn_on) { call Led.set[led_id](turn_on); } + + async command void MultiLed.toggle (unsigned int led_id) { call Led.toggle[led_id](); } + +} diff --git a/tos/platforms/ucmini/Ieee154MessageC.nc b/tos/platforms/ucmini/Ieee154MessageC.nc new file mode 100644 index 0000000000..ae3441e0ef --- /dev/null +++ b/tos/platforms/ucmini/Ieee154MessageC.nc @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2009, Vanderbilt University + * 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 copyright holder 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 COPYRIGHT HOLDER OR 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: Miklos Maroti + */ + +configuration Ieee154MessageC +{ + provides + { + interface SplitControl; + interface Resource as SendResource[uint8_t clint]; + + interface Ieee154Send; + interface Receive as Ieee154Receive; + interface Ieee154Packet; + interface Packet; + + interface Send as BareSend; + interface Receive as BareReceive; + interface Packet as BarePacket; + + interface SendNotifier; + interface PacketAcknowledgements; + interface LowPowerListening; + interface PacketLink; + interface RadioChannel; + + interface PacketField as PacketLinkQuality; + interface PacketField as PacketTransmitPower; + interface PacketField as PacketRSSI; + + interface PacketTimeStamp as PacketTimeStampRadio; + interface PacketTimeStamp as PacketTimeStampMilli; + } +} + +implementation +{ + components RFA1Ieee154MessageC as MessageC; + + SplitControl = MessageC; + SendResource = MessageC; + + Ieee154Send = MessageC.Ieee154Send; + Ieee154Receive = MessageC.Ieee154Receive; + Ieee154Packet = MessageC.Ieee154Packet; + Packet = MessageC.Packet; + + BareSend = MessageC.BareSend; + BareReceive = MessageC.BareReceive; + BarePacket = MessageC.BarePacket; + + SendNotifier = MessageC; + PacketAcknowledgements = MessageC; + LowPowerListening = MessageC; + PacketLink = MessageC; + RadioChannel = MessageC; + + PacketLinkQuality = MessageC.PacketLinkQuality; + PacketTransmitPower = MessageC.PacketTransmitPower; + PacketRSSI = MessageC.PacketRSSI; + + PacketTimeStampMilli = MessageC; + PacketTimeStampRadio = MessageC; +}