]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Prepare to support the RF212 chip (reorganization of timer and HPL constants)
authormmaroti <mmaroti>
Sun, 8 Mar 2009 22:02:38 +0000 (22:02 +0000)
committermmaroti <mmaroti>
Sun, 8 Mar 2009 22:02:38 +0000 (22:02 +0000)
12 files changed:
tos/chips/rf230/HplRF230.nc [deleted file]
tos/chips/rf230/RF230ActiveMessageC.nc
tos/chips/rf230/RF230ActiveMessageP.nc
tos/chips/rf230/RF230LayerC.nc
tos/chips/rf230/RF230LayerP.nc
tos/chips/rf230/RF230PacketC.nc
tos/chips/rf230/RF230TimeSyncMessageC.nc
tos/chips/rf230/RF230TimeSyncMessageP.nc
tos/platforms/iris/chips/rf230/HplRF230.h
tos/platforms/iris/chips/rf230/HplRF230C.nc
tos/platforms/iris/chips/rf230/HplRF230P.nc
tos/platforms/iris/chips/rf230/RadioAlarm.h [new file with mode: 0644]

diff --git a/tos/chips/rf230/HplRF230.nc b/tos/chips/rf230/HplRF230.nc
deleted file mode 100644 (file)
index 75d6592..0000000
+++ /dev/null
@@ -1,31 +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
- */
-
-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);
-}
index 892da9d95346fdfbf4b4ba1a19abe8d8234aff7f..b0b641cc3168aa58d0d65c4a5228bfbee4db23b0 100644 (file)
@@ -21,7 +21,7 @@
  * Author: Miklos Maroti
  */
 
-#include <HplRF230.h>
+#include <RadioAlarm.h>
 
 configuration RF230ActiveMessageC
 {
index 0337bbd92c54f054489c4ee75e334a556f9c05f5..2309628628e3d4c705fef91f6557ad9a0792c177 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <RF230Packet.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
 #include <Tasklet.h>
 
 module RF230ActiveMessageP
@@ -131,7 +131,7 @@ implementation
 
        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()
@@ -228,17 +228,17 @@ implementation
 
        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)
@@ -250,9 +250,9 @@ implementation
 
                // 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;
        }
@@ -280,12 +280,12 @@ implementation
        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() { }
index 43c1a836def01b5ba8f91bccd2a6f1190ad4a369..a89a808fbb6283b8a3a3a00da44e9b49f4ddd208 100644 (file)
@@ -21,8 +21,6 @@
  * Author: Miklos Maroti
  */
 
-#include <HplRF230.h>
-
 configuration RF230LayerC
 {
        provides
@@ -60,7 +58,6 @@ implementation
        RF230LayerP.SELN -> HplRF230C.SELN;
        RF230LayerP.SpiResource -> HplRF230C.SpiResource;
        RF230LayerP.FastSpiByte -> HplRF230C;
-       RF230LayerP.HplRF230 -> HplRF230C;
 
        RF230LayerP.SLP_TR -> HplRF230C.SLP_TR;
        RF230LayerP.RSTN -> HplRF230C.RSTN;
index 0099fab001562d70aa70aaaeb21a01f3377bad13..fb429b933b54b5d26c7b1feb361b397e71a0fd85 100644 (file)
@@ -26,6 +26,7 @@
 #include <Tasklet.h>
 #include <RadioAssert.h>
 #include <TimeSyncMessage.h>
+#include <RadioAlarm.h>
 
 module RF230LayerP
 {
@@ -46,7 +47,6 @@ module RF230LayerP
                interface Resource as SpiResource;
 
                interface FastSpiByte;
-               interface HplRF230;
 
                interface GeneralIO as SLP_TR;
                interface GeneralIO as RSTN;
@@ -150,11 +150,11 @@ implementation
 
        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()
@@ -580,17 +580,17 @@ implementation
                        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());
                        }
index b8173616cd648c4dccc03b8762dc1d101338dcb0..9d09b3140aace298a10c3a521d13e2080c8fdc68 100644 (file)
@@ -21,8 +21,6 @@
  * Author: Miklos Maroti
  */
 
-#include <HplRF230.h>
-
 configuration RF230PacketC
 {
        provides
@@ -53,10 +51,10 @@ implementation
        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;
index e0693cb35bfbd703f22fc88764ad9dd901af896e..dc321af022035ce99a8a1da7e80db9dbbe1fd5c5 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <Timer.h>
 #include <AM.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
 
 configuration RF230TimeSyncMessageC
 {
index 447b746f6e6854ed329e6b21696be613eaa6b35c..f60110a4bcf2ce4dc19fb69539191d99d25b9c92 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <TimeSyncMessage.h>
-#include <HplRF230.h>
+#include <RadioAlarm.h>
 
 module RF230TimeSyncMessageP
 {
index 0a69cea9f1ca3e88272cbdf755e67ee812dced76..63ae9db6e9d070764883e7f1fc43921aa70209bb 100644 (file)
@@ -25,6 +25,7 @@
 #define __HPLRF230_H__
 
 #include <RF230.h>
+#include <util/crc16.h>
 
 enum
 {
@@ -47,22 +48,6 @@ 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
@@ -73,4 +58,10 @@ typedef TOne TRadio;
 #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__
index 0394f93e31208dca324759b3127064a13cfd034f..5ef56e044006d161ca33b7fa5b5cb583fa14ff9e 100644 (file)
@@ -36,8 +36,6 @@ configuration HplRF230C
 
                interface GpioCapture as IRQ;
                interface Alarm<TRadio, uint16_t> as Alarm;
-
-               interface HplRF230;
        }
 }
 
@@ -52,7 +50,6 @@ implementation
        components Atm128SpiC as SpiC;
        SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];
 
-       HplRF230 = HplRF230P;
        FastSpiByte = HplRF230P;
 
        components HplAtm128GeneralIOC as IO;
index 2b9bf4875d0f7dcfb2f87467346057742541c1cc..652c60a784521b2fb0b67679ac926a37abc74ed2 100644 (file)
@@ -32,7 +32,6 @@ module HplRF230P
                interface Init as PlatformInit;
 
                interface FastSpiByte;
-               interface HplRF230;
        }
 
        uses
@@ -86,12 +85,6 @@ implementation
                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
diff --git a/tos/platforms/iris/chips/rf230/RadioAlarm.h b/tos/platforms/iris/chips/rf230/RadioAlarm.h
new file mode 100644 (file)
index 0000000..1897659
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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__