]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/iris/chips/rf230/RadioConfig.h
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / tos / platforms / iris / chips / rf230 / RadioConfig.h
diff --git a/tos/platforms/iris/chips/rf230/RadioConfig.h b/tos/platforms/iris/chips/rf230/RadioConfig.h
new file mode 100644 (file)
index 0000000..e73d354
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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 __RADIOCONFIG_H__
+#define __RADIOCONFIG_H__
+
+#include <MicaTimer.h>
+#include <RF230DriverLayer.h>
+#include <util/crc16.h>
+
+enum
+{
+       /**
+        * This is the value of the TRX_CTRL_0 register
+        * which configures the output pin currents and the CLKM clock
+        */
+       RF230_TRX_CTRL_0_VALUE = 0,
+
+       /**
+        * This is the default value of the CCA_MODE field in the PHY_CC_CCA register
+        * which is used to configure the default mode of the clear channel assesment
+        */
+       RF230_CCA_MODE_VALUE = RF230_CCA_MODE_3,
+
+       /**
+        * This is the value of the CCA_THRES register that controls the
+        * energy levels used for clear channel assesment
+        */
+       RF230_CCA_THRES_VALUE = 0xC7,
+};
+
+/* 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
+#endif
+
+/* This is the default value of the CHANNEL field of the PHY_CC_CCA register. */
+#ifndef RF230_DEF_CHANNEL
+#define RF230_DEF_CHANNEL      11
+#endif
+
+/* The number of microseconds a sending IRIS mote will wait for an acknowledgement */
+#ifndef SOFTWAREACK_TIMEOUT
+#define SOFTWAREACK_TIMEOUT    800
+#endif
+
+/*
+ * This is the command used to calculate the CRC for the RF230 chip. 
+ * 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);
+}
+
+/**
+ * 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.
+ * Ok, further hacks were required for deputy, I removed 00 from the
+ * beginning and end to ba able to handle longer wait periods.
+ */
+#define RADIO_ALARM_MICROSEC   (73728UL / MHZ / 32) * (1 << MICA_DIVIDE_ONE_FOR_32KHZ_LOG2) / 10000UL
+
+/**
+ * The base two logarithm of the number of radio alarm ticks per one millisecond
+ */
+#define RADIO_ALARM_MILLI_EXP  (5 + MICA_DIVIDE_ONE_FOR_32KHZ_LOG2)
+
+/**
+ * Make PACKET_LINK automaticaly enabled for Ieee154MessageC
+ */
+#if !defined(TFRAMES_ENABLED) && !defined(PACKET_LINK)
+#define PACKET_LINK
+#endif
+
+#endif//__RADIOCONFIG_H__