From: mmaroti Date: Sun, 8 Mar 2009 22:02:38 +0000 (+0000) Subject: Prepare to support the RF212 chip (reorganization of timer and HPL constants) X-Git-Tag: rc_6_tinyos_2_1_1~476 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=d4dbb904d4c5a34dcacf5fc657ceb6023a421159 Prepare to support the RF212 chip (reorganization of timer and HPL constants) --- diff --git a/tos/chips/rf230/HplRF230.nc b/tos/chips/rf230/HplRF230.nc deleted file mode 100644 index 75d6592e..00000000 --- a/tos/chips/rf230/HplRF230.nc +++ /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); -} diff --git a/tos/chips/rf230/RF230ActiveMessageC.nc b/tos/chips/rf230/RF230ActiveMessageC.nc index 892da9d9..b0b641cc 100644 --- a/tos/chips/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf230/RF230ActiveMessageC.nc @@ -21,7 +21,7 @@ * Author: Miklos Maroti */ -#include +#include configuration RF230ActiveMessageC { diff --git a/tos/chips/rf230/RF230ActiveMessageP.nc b/tos/chips/rf230/RF230ActiveMessageP.nc index 0337bbd9..23096286 100644 --- a/tos/chips/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf230/RF230ActiveMessageP.nc @@ -22,7 +22,7 @@ */ #include -#include +#include #include 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() { } diff --git a/tos/chips/rf230/RF230LayerC.nc b/tos/chips/rf230/RF230LayerC.nc index 43c1a836..a89a808f 100644 --- a/tos/chips/rf230/RF230LayerC.nc +++ b/tos/chips/rf230/RF230LayerC.nc @@ -21,8 +21,6 @@ * Author: Miklos Maroti */ -#include - 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; diff --git a/tos/chips/rf230/RF230LayerP.nc b/tos/chips/rf230/RF230LayerP.nc index 0099fab0..fb429b93 100644 --- a/tos/chips/rf230/RF230LayerP.nc +++ b/tos/chips/rf230/RF230LayerP.nc @@ -26,6 +26,7 @@ #include #include #include +#include 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()); } diff --git a/tos/chips/rf230/RF230PacketC.nc b/tos/chips/rf230/RF230PacketC.nc index b8173616..9d09b314 100644 --- a/tos/chips/rf230/RF230PacketC.nc +++ b/tos/chips/rf230/RF230PacketC.nc @@ -21,8 +21,6 @@ * Author: Miklos Maroti */ -#include - 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; diff --git a/tos/chips/rf230/RF230TimeSyncMessageC.nc b/tos/chips/rf230/RF230TimeSyncMessageC.nc index e0693cb3..dc321af0 100644 --- a/tos/chips/rf230/RF230TimeSyncMessageC.nc +++ b/tos/chips/rf230/RF230TimeSyncMessageC.nc @@ -23,7 +23,7 @@ #include #include -#include +#include configuration RF230TimeSyncMessageC { diff --git a/tos/chips/rf230/RF230TimeSyncMessageP.nc b/tos/chips/rf230/RF230TimeSyncMessageP.nc index 447b746f..f60110a4 100644 --- a/tos/chips/rf230/RF230TimeSyncMessageP.nc +++ b/tos/chips/rf230/RF230TimeSyncMessageP.nc @@ -22,7 +22,7 @@ */ #include -#include +#include module RF230TimeSyncMessageP { diff --git a/tos/platforms/iris/chips/rf230/HplRF230.h b/tos/platforms/iris/chips/rf230/HplRF230.h index 0a69cea9..63ae9db6 100644 --- a/tos/platforms/iris/chips/rf230/HplRF230.h +++ b/tos/platforms/iris/chips/rf230/HplRF230.h @@ -25,6 +25,7 @@ #define __HPLRF230_H__ #include +#include 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__ diff --git a/tos/platforms/iris/chips/rf230/HplRF230C.nc b/tos/platforms/iris/chips/rf230/HplRF230C.nc index 0394f93e..5ef56e04 100644 --- a/tos/platforms/iris/chips/rf230/HplRF230C.nc +++ b/tos/platforms/iris/chips/rf230/HplRF230C.nc @@ -36,8 +36,6 @@ configuration HplRF230C interface GpioCapture as IRQ; interface Alarm 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; diff --git a/tos/platforms/iris/chips/rf230/HplRF230P.nc b/tos/platforms/iris/chips/rf230/HplRF230P.nc index 2b9bf487..652c60a7 100644 --- a/tos/platforms/iris/chips/rf230/HplRF230P.nc +++ b/tos/platforms/iris/chips/rf230/HplRF230P.nc @@ -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 index 00000000..18976592 --- /dev/null +++ b/tos/platforms/iris/chips/rf230/RadioAlarm.h @@ -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 + +/** + * 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__