--- /dev/null
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * 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 Technische Universitaet Berlin 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
+ * OWNER 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.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+#include "TKN154.h"
+#include "TKN154_DEBUG.h"
+configuration Ieee802154MacC
+{
+ provides
+ {
+ // MCPS-SAP
+ interface MCPS_DATA;
+ interface MCPS_PURGE;
+
+ // MLME-SAP
+ interface MLME_ASSOCIATE;
+ interface MLME_BEACON_NOTIFY;
+ interface MLME_COMM_STATUS;
+ interface MLME_DISASSOCIATE;
+ interface MLME_GET;
+/* interface MLME_GTS;*/
+ interface MLME_ORPHAN;
+ interface MLME_POLL;
+ interface MLME_RESET;
+ interface MLME_RX_ENABLE;
+ interface MLME_SCAN;
+ interface MLME_SET;
+ interface MLME_START;
+ interface MLME_SYNC;
+ interface MLME_SYNC_LOSS;
+ interface IEEE154Frame;
+ interface IEEE154BeaconFrame;
+ interface IEEE154TxBeaconPayload;
+ interface SplitControl as PromiscuousMode;
+ interface Get<uint64_t> as LocalExtendedAddress;
+ interface Timestamp;
+ interface Packet;
+ }
+}
+implementation
+{
+ components TKN154P as MAC;
+
+ MLME_START = MAC;
+ MLME_GET = MAC;
+ MLME_SET = MAC;
+ MLME_RESET = MAC;
+ MLME_SYNC = MAC;
+ MLME_SYNC_LOSS = MAC;
+ MLME_BEACON_NOTIFY = MAC;
+ MLME_SCAN = MAC;
+ MCPS_DATA = MAC;
+ MCPS_PURGE = MAC;
+ MLME_ASSOCIATE = MAC;
+ MLME_DISASSOCIATE = MAC;
+ MLME_COMM_STATUS = MAC;
+ MLME_RX_ENABLE = MAC;
+ MLME_POLL = MAC;
+ MLME_ORPHAN = MAC;
+ IEEE154Frame = MAC;
+ IEEE154BeaconFrame = MAC;
+ LocalExtendedAddress = MAC;
+ IEEE154TxBeaconPayload = MAC;
+ PromiscuousMode = MAC;
+ Packet = MAC;
+
+ components CC2420TKN154C as PHY,
+ new Alarm62500hz32VirtualizedC() as PHYAlarm1,
+ new Alarm62500hz32VirtualizedC() as PHYAlarm2,
+ LocalTime62500hzC, TKN154TimingP;
+
+ // wire PHY to the PIB
+ PHY.PIBUpdate[IEEE154_macShortAddress] -> MAC.PIBUpdate[IEEE154_macShortAddress];
+ PHY.PIBUpdate[IEEE154_macPANId] -> MAC.PIBUpdate[IEEE154_macPANId];
+ PHY.PIBUpdate[IEEE154_phyCurrentChannel] -> MAC.PIBUpdate[IEEE154_phyCurrentChannel];
+ PHY.PIBUpdate[IEEE154_phyTransmitPower] -> MAC.PIBUpdate[IEEE154_phyTransmitPower];
+ PHY.PIBUpdate[IEEE154_phyCCAMode] -> MAC.PIBUpdate[IEEE154_phyCCAMode];
+ PHY.PIBUpdate[IEEE154_macPanCoordinator] -> MAC.PIBUpdate[IEEE154_macPanCoordinator];
+
+ Timestamp = PHY;
+ PHY.Alarm1 -> PHYAlarm1;
+ PHY.Alarm2 -> PHYAlarm2;
+ PHY.LocalTime -> LocalTime62500hzC;
+ PHY.CaptureTime -> TKN154TimingP;
+ PHY.ReliableWait -> TKN154TimingP;
+ PHY.ReferenceTime -> TKN154TimingP;
+ PHY.TimeCalc -> MAC;
+ PHY.Leds -> LedsC;
+ TKN154TimingP.TimeCalc -> MAC;
+ TKN154TimingP.LocalTime -> LocalTime62500hzC;
+
+ components new Alarm62500hz32VirtualizedC() as MACAlarm1,
+ new Alarm62500hz32VirtualizedC() as MACAlarm2,
+ new Alarm62500hz32VirtualizedC() as MACAlarm3,
+ new Alarm62500hz32VirtualizedC() as MACAlarm4,
+ new Alarm62500hz32VirtualizedC() as MACAlarm5,
+ new Alarm62500hz32VirtualizedC() as MACAlarm6,
+ new Alarm62500hz32VirtualizedC() as MACAlarm7,
+ new Alarm62500hz32VirtualizedC() as MACAlarm8,
+ new Alarm62500hz32VirtualizedC() as MACAlarm9,
+
+ new Timer62500C() as MACTimer1,
+ new Timer62500C() as MACTimer2,
+ new Timer62500C() as MACTimer3,
+ new Timer62500C() as MACTimer4,
+ new Timer62500C() as MACTimer5;
+
+ MAC.Alarm1 -> MACAlarm1;
+ MAC.Alarm2 -> MACAlarm2;
+ MAC.Alarm3 -> MACAlarm3;
+ MAC.Alarm4 -> MACAlarm4;
+ MAC.Alarm5 -> MACAlarm5;
+ MAC.Alarm6 -> MACAlarm6;
+ MAC.Alarm7 -> MACAlarm7;
+ MAC.Alarm8 -> MACAlarm8;
+ MAC.Alarm9 -> MACAlarm9;
+
+ MAC.Timer1 -> MACTimer1;
+ MAC.Timer2 -> MACTimer2;
+ MAC.Timer3 -> MACTimer3;
+ MAC.Timer4 -> MACTimer4;
+ MAC.Timer5 -> MACTimer5;
+ MAC.LocalTime -> LocalTime62500hzC;
+
+ // wire MAC <-> PHY
+ MAC.RadioTx -> PHY;
+ MAC.RadioRx -> PHY;
+ MAC.RadioOff -> PHY;
+ MAC.EnergyDetection -> PHY;
+ MAC.PhySplitControl -> PHY;
+ MAC.RadioPromiscuousMode -> PHY.RadioPromiscuousMode;
+ PHY.FrameUtility -> MAC;
+
+ components RandomC, LedsC, NoLedsC;
+ MAC.Random -> RandomC;
+ MAC.Leds -> LedsC;
+
+ components NoDebugP;
+ MAC.Ieee802154Debug -> NoDebugP;
+}
--- /dev/null
+CFLAGS += -I$(TOSDIR)/platforms/telosb/mac/tkn154 \
+ -I$(TOSDIR)/platforms/telosb/mac/tkn154/timer \
+ -I$(TOSDIR)/chips/cc2420_tkn154
+
--- /dev/null
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * extraification, 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 Technische Universitaet Berlin 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
+ * OWNER 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.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+/**
+ * NOTE:
+ * In slotted CSMA-CA frames must be sent on backoff boundaries (slot width:
+ * 320 us). On TelosB the only clock source with sufficient accuracy is the
+ * external quartz, unfortunately it is not precise enough (32.768 Hz).
+ * Therefore, currently the following code is not even trying to achieve
+ * accurate timing.
+ */
+
+#include "TKN154_platform.h"
+module TKN154TimingP
+{
+ provides interface CaptureTime;
+ provides interface ReliableWait;
+ provides interface ReferenceTime;
+ uses interface TimeCalc;
+ uses interface LocalTime<T62500hz>;
+}
+implementation
+{
+
+#define UWAIT1 nop();nop();nop();nop()
+#define UWAIT2 UWAIT1;UWAIT1
+#define UWAIT4 UWAIT2;UWAIT2
+#define UWAIT8 UWAIT4;UWAIT4
+
+ async command void CaptureTime.convert(uint16_t time, ieee154_reftime_t *localTime, int16_t offset)
+ {
+ // TimerB is used for capturing, it is sourced by ACLK (32768Hz),
+ // we now need to convert the capture "time" into ieee154_reftime_t.
+ // With the 32768Hz quartz we don't have enough precision anyway,
+ // so the code below generates a timestamp that is not accurate
+ // (deviating about +-50 microseconds; this could probably
+ // improved if we don't go through LocalTime)
+ uint16_t tbr1, tbr2, delta;
+ uint32_t now;
+ atomic {
+ do {
+ tbr1 = TBR;
+ tbr2 = TBR;
+ } while (tbr1 != tbr2); // majority vote required (see msp430 manual)
+ now = call LocalTime.get();
+ }
+ if (time < tbr1)
+ delta = tbr1 - time;
+ else
+ delta = ~(time - tbr1) + 1;
+ *localTime = now - delta*2 + offset;
+ }
+
+ async command void ReliableWait.busyWait(uint16_t dt)
+ {
+ uint32_t start = call LocalTime.get();
+ while (!call TimeCalc.hasExpired(start, dt))
+ ;
+ }
+
+ async command void ReliableWait.waitCCA(ieee154_reftime_t *t0, uint16_t dt)
+ {
+ while (!call TimeCalc.hasExpired(*t0, dt))
+ ;
+ signal ReliableWait.waitCCADone();
+ }
+
+ async command void ReliableWait.waitTx(ieee154_reftime_t *t0, uint16_t dt)
+ {
+ while (!call TimeCalc.hasExpired(*t0, dt))
+ ;
+ signal ReliableWait.waitTxDone();
+ }
+
+ async command void ReliableWait.waitRx(ieee154_reftime_t *t0, uint16_t dt)
+ {
+ while (!call TimeCalc.hasExpired(*t0, dt))
+ ;
+ signal ReliableWait.waitRxDone();
+ }
+
+ async command void ReferenceTime.getNow(ieee154_reftime_t* reftime, uint16_t dt)
+ {
+ *reftime = call LocalTime.get();
+ }
+
+ async command uint32_t ReferenceTime.toLocalTime(ieee154_reftime_t* refTime)
+ {
+ return *refTime;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * 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 Technische Universitaet Berlin 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
+ * OWNER 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.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#ifndef __TKN154_platform_H
+#define __TKN154_platform_H
+
+/****************************************************
+ * The following constants define guard times on Tmote Sky / TelosB.
+ * All values are in symbol time (1 symbol = 16 us)
+ */
+
+enum {
+ // guard time to give up the token before actual end of CAP/CFP
+ IEEE154_RADIO_GUARD_TIME = 1000,
+
+ // the expected time for a RadioTx.prepare() operation to execute (return)
+ IEEE154_RADIO_TX_PREPARE_DELAY = 220,
+
+ // the *guaranteed maximum* time between calling a RadioTx.transmit() and the
+ // first PPDU bit being put onto the channel, assuming that RadioTx.transmit()
+ // is called inside an atomic block
+ IEEE154_RADIO_TX_SEND_DELAY = 100,
+
+ // the expected time for a RadioRx.prepare() operation to execute (return)
+ IEEE154_RADIO_RX_PREPARE_DELAY = 300,
+
+ // the *guaranteed maximum* time between calling a RadioTx.transmit() and the
+ // first PPDU bit being put onto the channel, assuming that RadioTx.transmit()
+ // is called inside an atomic block
+ IEEE154_RADIO_RX_DELAY = 100,
+
+ // defines at what time the MAC payload for a beacon frame is assembled prior
+ // to the next scheduled beacon transmission time; must be smaller than both
+ // the beacon interval and IEEE154_RADIO_TX_PREPARE_DELAY
+ BEACON_PAYLOAD_UPDATE_INTERVAL = 2500,
+};
+
+typedef uint32_t ieee154_reftime_t;
+
+#endif
+
--- /dev/null
+
+
+
+#ifndef PLATFORM_MESSAGE_H
+#define PLATFORM_MESSAGE_H
+
+#include <Serial.h>
+
+#ifndef IEEE154_OLD_INTERFACES
+#include <TKN154_MAC.h>
+#else
+typedef struct {
+ uint8_t control; // stores length (lower 7 bits), top bit -> promiscuous mode
+ uint8_t mhr[23];
+} ieee154_header_t;
+
+typedef struct {
+ uint8_t rssi;
+ uint8_t linkQuality;
+ uint32_t timestamp;
+} ieee154_metadata_t;
+#endif
+
+#ifdef TOSH_DATA_LENGTH
+#undef TOSH_DATA_LENGTH
+#endif
+// TOSH_DATA_LENGTH may be smaller than 118, but then we'll
+// not be able to receive/send all IEEE 802.15.4 packets
+#define TOSH_DATA_LENGTH 118
+
+typedef union message_header {
+ ieee154_header_t ieee154;
+ serial_header_t serial;
+} message_header_t;
+
+typedef union TOSRadioFooter {
+} message_footer_t;
+
+typedef union TOSRadioMetadata {
+ ieee154_metadata_t ieee154;
+} message_metadata_t;
+
+#endif
--- /dev/null
+#include "Timer62500hz.h"
+configuration Alarm32khz32VirtualizedP
+{
+ provides interface Alarm<T32khz,uint32_t> as Alarm[ uint8_t num ];
+}
+implementation
+{
+ components new Alarm32khz32C(), MainC;
+ components new VirtualizeAlarmC(T32khz, uint32_t, uniqueCount(UQ_ALARM_32KHZ32));
+
+ Alarm = VirtualizeAlarmC;
+
+ MainC -> Alarm32khz32C.Init;
+ MainC -> VirtualizeAlarmC.Init;
+ VirtualizeAlarmC.AlarmFrom -> Alarm32khz32C;
+}
--- /dev/null
+// here we introduce an error
+generic module Alarm32khzTo62500hzTransformC()
+{
+ provides interface Alarm<T62500hz,uint32_t> as Alarm;
+ uses interface Alarm<T32khz,uint32_t> as AlarmFrom;
+}
+implementation
+{
+ async command void Alarm.start(uint32_t dt){ call AlarmFrom.start(dt >> 1);}
+ async command void Alarm.stop(){ call AlarmFrom.stop();}
+ async event void AlarmFrom.fired(){ signal Alarm.fired();}
+ async command bool Alarm.isRunning(){ return call AlarmFrom.isRunning();}
+ async command void Alarm.startAt(uint32_t t0, uint32_t dt){ call AlarmFrom.startAt(t0 >> 1, dt >> 1);}
+ async command uint32_t Alarm.getNow(){ return call AlarmFrom.getNow() << 1;}
+ async command uint32_t Alarm.getAlarm(){ return call AlarmFrom.getAlarm() << 1;}
+ default async event void Alarm.fired(){}
+}
--- /dev/null
+
+/* "Copyright (c) 2000-2003 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."
+ */
+
+/**
+ * Alarm62500hzC is the alarm for async 62500hz alarms (virtualized)
+ * This is the place where we cheat: since we don't have a clock source
+ * running at 62500 Hz, we cast 2 symbols to 1 tick of the 32768
+ * clock, which introduces a small error.
+ *
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ * @see Please refer to TEP 102 for more information about this component and its
+ * intended use.
+ */
+
+//#include "Timer.h"
+#include "Timer62500hz.h"
+generic configuration Alarm62500hz32VirtualizedC()
+{
+ provides interface Alarm<T62500hz,uint32_t>;
+}
+implementation
+{
+#warning "Warning: MAC timing is not standard compliant (the symbol clock is based on the 32768 Hz oscillator)!"
+ components new Alarm32khzTo62500hzTransformC();
+ components Alarm32khz32VirtualizedP;
+
+ Alarm = Alarm32khzTo62500hzTransformC;
+ Alarm32khzTo62500hzTransformC.AlarmFrom -> Alarm32khz32VirtualizedP.Alarm[unique(UQ_ALARM_32KHZ32)];
+}
+
--- /dev/null
+
+/* "Copyright (c) 2000-2003 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."
+ */
+
+/**
+ * Alarm62500hzC is the alarm for async 62500hz alarms (virtualized)
+ * This is the place where we cheat: since we don't have a clock source
+ * running at 62500 Hz, we cast 2 symbols to 1 tick of the 32768
+ * clock, which introduces a small error.
+ *
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * @see Please refer to TEP 102 for more information about this component and its
+ * intended use.
+ */
+
+//#include "Timer.h"
+#include "Timer62500hz.h"
+generic configuration Alarm62500hz32VirtualizedHilC()
+{
+ provides interface Alarm<T62500hz,uint32_t>;
+}
+implementation
+{
+ components new Alarm32khzTo62500hzTransformC();
+ components Alarm62500hz32VirtualizedHilP;
+
+ Alarm = Alarm32khzTo62500hzTransformC;
+ Alarm32khzTo62500hzTransformC.AlarmFrom -> Alarm62500hz32VirtualizedHilP.Alarm[unique(UQ_ALARM_32KHZ32)];
+}
+
--- /dev/null
+#include "Timer62500hz.h"
+configuration Alarm62500hz32VirtualizedHilP
+{
+ provides interface Alarm<T32khz,uint32_t> as Alarm[ uint8_t num ];
+}
+implementation
+{
+ components new Alarm32khz32C(), MainC;
+ components new VirtualizeAlarmC(T32khz, uint32_t, uniqueCount(UQ_ALARM_32KHZ32));
+
+ Alarm = VirtualizeAlarmC;
+
+ MainC -> Alarm32khz32C.Init;
+ MainC -> VirtualizeAlarmC.Init;
+ VirtualizeAlarmC.AlarmFrom -> Alarm32khz32C;
+}
--- /dev/null
+
+/* "Copyright (c) 2000-2003 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."
+ */
+
+/**
+ *
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (62500hz)
+ * @see Please refer to TEP 102 for more information about this component and its
+ * intended use.
+ */
+
+#include "Timer.h"
+#include "Timer62500hz.h"
+configuration HilTimer62500hzC
+{
+ provides interface Timer<T62500hz> as Timer62500hz[ uint8_t num ];
+}
+implementation
+{
+ components new Alarm62500hz32VirtualizedHilC() as Alarm;
+ components new AlarmToTimerC(T62500hz);
+ components new VirtualizeTimerC(T62500hz,uniqueCount(UQ_TIMER_62500HZ));
+
+ Timer62500hz = VirtualizeTimerC;
+
+ VirtualizeTimerC.TimerFrom -> AlarmToTimerC;
+ AlarmToTimerC.Alarm -> Alarm;
+}
--- /dev/null
+#include "Timer62500hz.h"
+configuration LocalTime62500hzC
+{
+ provides interface LocalTime<T62500hz>;
+}
+implementation
+{
+ // should be done properly one day (not wasting an alarm slot)
+ components new Alarm62500hz32VirtualizedC(), LocalTime62500hzP;
+ LocalTime = LocalTime62500hzP;
+ LocalTime62500hzP.Alarm -> Alarm62500hz32VirtualizedC.Alarm;
+}
+
--- /dev/null
+#include "Timer62500hz.h"
+module LocalTime62500hzP
+{
+ provides interface LocalTime<T62500hz>;
+ uses interface Alarm<T62500hz,uint32_t>;
+}
+implementation
+{
+ async command uint32_t LocalTime.get()
+ {
+ return call Alarm.getNow();
+ }
+ async event void Alarm.fired(){}
+}
+
--- /dev/null
+// $Id$
+/*
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ *
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * The virtualized 62500 Hz timer abstraction. Instantiating this
+ * component gives an 62500 Hz granularity timer.
+ *
+ * @author Philip Levis
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (62500hz)
+ * @date January 16 2006
+ * @see TEP 102: Timers
+ */
+
+#include "Timer62500hz.h"
+
+generic configuration Timer62500C() {
+ provides interface Timer<T62500hz>;
+}
+implementation {
+ components Timer62500P;
+ Timer = Timer62500P.Timer62500[unique(UQ_TIMER_62500HZ)];
+}
+
--- /dev/null
+// $Id$
+/* tab:4
+ * "Copyright (c) 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."
+ *
+ */
+/*
+ *
+ * @author Philip Levis
+ * @author Cory Sharp
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (62500hz)
+ * @date May 16 2005
+ */
+
+#include "Timer.h"
+
+configuration Timer62500P {
+ provides interface Timer<T62500hz> as Timer62500[uint8_t id];
+}
+implementation {
+ components HilTimer62500hzC;
+ Timer62500 = HilTimer62500hzC;
+}
+
--- /dev/null
+#ifndef _H_Timer_62500hz_h
+#define _H_Timer_62500hz_h
+
+typedef struct { } T62500hz;
+
+#define UQ_ALARM_32KHZ32 "Virtual.32khz32Alarm"
+#define UQ_ALARM_62500HZ32 "Virtual.62500hzAlarm"
+#define UQ_TIMER_62500HZ "HilTimer62500hzC.Timer"
+#endif
+