+++ /dev/null
-/*
- * Copyright (c) 2007, Vanderbilt University
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
- * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Author: Miklos Maroti
- */
-
-interface HplRF230
-{
- /**
- * Calculates the crc. For some unknown reason the standard
- * tinyos crcByte command swiches endianness.
- */
- async command uint16_t crcByte(uint16_t crc, uint8_t data);
-}
* Author: Miklos Maroti
*/
-#include <HplRF230.h>
+#include <RadioAlarm.h>
configuration RF230ActiveMessageC
{
*/
#include <RF230Packet.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
#include <Tasklet.h>
module RF230ActiveMessageP
async command uint16_t SoftwareAckConfig.getAckTimeout()
{
- return (uint16_t)(800 * RF230_ALARM_MICROSEC);
+ return (uint16_t)(800 * RADIO_ALARM_MICROSEC);
}
tasklet_async command void SoftwareAckConfig.reportChannelError()
async command uint16_t RandomCollisionConfig.getMinimumBackoff()
{
- return (uint16_t)(320 * RF230_ALARM_MICROSEC);
+ return (uint16_t)(320 * RADIO_ALARM_MICROSEC);
}
async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg)
{
- return (uint16_t)(9920 * RF230_ALARM_MICROSEC);
+ return (uint16_t)(9920 * RADIO_ALARM_MICROSEC);
}
async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
{
- return (uint16_t)(2240 * RF230_ALARM_MICROSEC);
+ return (uint16_t)(2240 * RADIO_ALARM_MICROSEC);
}
async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
// estimated response time (download the message, etc) is 5-8 bytes
if( call IEEE154Packet.requiresAckReply(msg) )
- time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RF230_ALARM_MICROSEC);
+ time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
else
- time += (uint16_t)(32 * (-5 + 5) * RF230_ALARM_MICROSEC);
+ time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC);
return time;
}
async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg)
{
// the preamble (4 bytes), SFD (1 byte), plus two extra for safety
- return getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RF230_ALARM_MICROSEC);
+ return getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
}
async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
{
- return (uint16_t)(2 * 7 * 32 * RF230_ALARM_MICROSEC);
+ return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
}
default tasklet_async event void SlottedCollisionConfig.timerTick() { }
* Author: Miklos Maroti
*/
-#include <HplRF230.h>
-
configuration RF230LayerC
{
provides
RF230LayerP.SELN -> HplRF230C.SELN;
RF230LayerP.SpiResource -> HplRF230C.SpiResource;
RF230LayerP.FastSpiByte -> HplRF230C;
- RF230LayerP.HplRF230 -> HplRF230C;
RF230LayerP.SLP_TR -> HplRF230C.SLP_TR;
RF230LayerP.RSTN -> HplRF230C.RSTN;
#include <Tasklet.h>
#include <RadioAssert.h>
#include <TimeSyncMessage.h>
+#include <RadioAlarm.h>
module RF230LayerP
{
interface Resource as SpiResource;
interface FastSpiByte;
- interface HplRF230;
interface GeneralIO as SLP_TR;
interface GeneralIO as RSTN;
enum
{
- SLEEP_WAKEUP_TIME = (uint16_t)(880 * RF230_ALARM_SEC / 1000000UL),
- CCA_REQUEST_TIME = (uint16_t)(140 * RF230_ALARM_SEC / 1000000UL),
+ SLEEP_WAKEUP_TIME = (uint16_t)(880 * RADIO_ALARM_MICROSEC),
+ CCA_REQUEST_TIME = (uint16_t)(140 * RADIO_ALARM_MICROSEC),
- TX_SFD_DELAY = (uint16_t)(176 * RF230_ALARM_SEC / 1000000UL),
- RX_SFD_DELAY = (uint16_t)(8 * RF230_ALARM_SEC / 1000000UL),
+ TX_SFD_DELAY = (uint16_t)(176 * RADIO_ALARM_MICROSEC),
+ RX_SFD_DELAY = (uint16_t)(8 * RADIO_ALARM_MICROSEC),
};
tasklet_async event void RadioAlarm.fired()
length -= read;
do {
- crc = call HplRF230.crcByte(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
+ crc = RF230_CRCBYTE_COMMAND(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
}
while( --read != 0 );
if( signal RadioReceive.header(rxMsg) )
{
while( length-- != 0 )
- crc = call HplRF230.crcByte(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
+ crc = RF230_CRCBYTE_COMMAND(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
- crc = call HplRF230.crcByte(crc, call FastSpiByte.splitReadWrite(0));
- crc = call HplRF230.crcByte(crc, call FastSpiByte.splitReadWrite(0));
+ crc = RF230_CRCBYTE_COMMAND(crc, call FastSpiByte.splitReadWrite(0));
+ crc = RF230_CRCBYTE_COMMAND(crc, call FastSpiByte.splitReadWrite(0));
call PacketLinkQuality.set(rxMsg, call FastSpiByte.splitRead());
}
* Author: Miklos Maroti
*/
-#include <HplRF230.h>
-
configuration RF230PacketC
{
provides
AMPacket = IEEE154PacketC;
PacketAcknowledgements = RF230PacketP;
- PacketLinkQuality = RF230PacketP.PacketLinkQuality;
- PacketTransmitPower = RF230PacketP.PacketTransmitPower;
- PacketRSSI = RF230PacketP.PacketRSSI;
- PacketSleepInterval = RF230PacketP.PacketSleepInterval;
+ PacketLinkQuality = RF230PacketP.PacketLinkQuality;
+ PacketTransmitPower = RF230PacketP.PacketTransmitPower;
+ PacketRSSI = RF230PacketP.PacketRSSI;
+ PacketSleepInterval = RF230PacketP.PacketSleepInterval;
PacketTimeSyncOffset = RF230PacketP.PacketTimeSyncOffset;
PacketTimeStampRadio = RF230PacketP;
#include <Timer.h>
#include <AM.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
configuration RF230TimeSyncMessageC
{
*/
#include <TimeSyncMessage.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
module RF230TimeSyncMessageP
{
#define __HPLRF230_H__
#include <RF230.h>
+#include <util/crc16.h>
enum
{
RF230_CCA_THRES_VALUE = 0xC7,
};
-/**
- * This is the timer type of the RF230 alarm interface
- */
-typedef TOne TRadio;
-
-
-/**
- * The number of alarm ticks per one second (921600)
- */
-#define RF230_ALARM_SEC ((7372800UL / MHZ / 32) * (1 << MICA_DIVIDE_ONE_FOR_32KHZ_LOG2))
-
-/**
- * The number of alarm ticks per one microsecond (0.9216)
- */
-#define RF230_ALARM_MICROSEC (RF230_ALARM_SEC / 1000000.0)
-
/* This is the default value of the TX_PWR field of the PHY_TX_PWR register. */
#ifndef RF230_DEF_RFPOWER
#define RF230_DEF_RFPOWER 0
#define RF230_DEF_CHANNEL 11
#endif
+// TODO: Check why the default crcByte implementation is in a different endianness
+inline uint16_t RF230_CRCBYTE_COMMAND(uint16_t crc, uint8_t data)
+{
+ return _crc_ccitt_update(crc, data);
+}
+
#endif//__HPLRF230_H__
interface GpioCapture as IRQ;
interface Alarm<TRadio, uint16_t> as Alarm;
-
- interface HplRF230;
}
}
components Atm128SpiC as SpiC;
SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];
- HplRF230 = HplRF230P;
FastSpiByte = HplRF230P;
components HplAtm128GeneralIOC as IO;
interface Init as PlatformInit;
interface FastSpiByte;
- interface HplRF230;
}
uses
call Capture.stop();
}
- // TODO: Check why the default crcByte implementation is in a different endianness
- inline async command uint16_t HplRF230.crcByte(uint16_t crc, uint8_t data)
- {
- return _crc_ccitt_update(crc, data);
- }
-
inline async command void FastSpiByte.splitWrite(uint8_t data)
{
// the SPI must have been started, so do not waste time here
--- /dev/null
+/*
+ * Copyright (c) 2007, Vanderbilt University
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+#ifndef __RADIOALARM_H__
+#define __RADIOALARM_H__
+
+#include <MicaTimer.h>
+
+/**
+ * This is the timer type of the radio alarm interface
+ */
+typedef TOne TRadio;
+
+/**
+ * The number of radio alarm ticks per one microsecond (0.9216). We use integers
+ * and no parentheses just to make deputy happy.
+ */
+#define RADIO_ALARM_MICROSEC (7372800UL / MHZ / 32) * (1 << MICA_DIVIDE_ONE_FOR_32KHZ_LOG2) / 1000000UL
+
+#endif//__RADIOALARM_H__