Port of RadioHead version 1.48 to mbed. It is a little messy and only works for SPI at this time.

Committer:
davidr99
Date:
Thu Oct 15 01:27:00 2015 +0000
Revision:
0:ab4e012489ef
Messy start, but a port for RadioHead.; Currently the SPI modulus are the only ones that work.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davidr99 0:ab4e012489ef 1 // RadioHead.h
davidr99 0:ab4e012489ef 2 // Author: Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY
davidr99 0:ab4e012489ef 3 // Copyright (C) 2014 Mike McCauley
davidr99 0:ab4e012489ef 4 // $Id: RadioHead.h,v 1.50 2015/08/14 21:20:12 mikem Exp mikem $
davidr99 0:ab4e012489ef 5
davidr99 0:ab4e012489ef 6 /// \mainpage RadioHead Packet Radio library for embedded microprocessors
davidr99 0:ab4e012489ef 7 ///
davidr99 0:ab4e012489ef 8 /// This is the RadioHead Packet Radio library for embedded microprocessors.
davidr99 0:ab4e012489ef 9 /// It provides a complete object-oriented library for sending and receiving packetized messages
davidr99 0:ab4e012489ef 10 /// via a variety of common data radios and other transports on a range of embedded microprocessors.
davidr99 0:ab4e012489ef 11 ///
davidr99 0:ab4e012489ef 12 /// The version of the package that this documentation refers to can be downloaded
davidr99 0:ab4e012489ef 13 /// from http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.48.zip
davidr99 0:ab4e012489ef 14 /// You can find the latest version at http://www.airspayce.com/mikem/arduino/RadioHead
davidr99 0:ab4e012489ef 15 ///
davidr99 0:ab4e012489ef 16 /// You can also find online help and discussion at
davidr99 0:ab4e012489ef 17 /// http://groups.google.com/group/radiohead-arduino
davidr99 0:ab4e012489ef 18 /// Please use that group for all questions and discussions on this topic.
davidr99 0:ab4e012489ef 19 /// Do not contact the author directly, unless it is to discuss commercial licensing.
davidr99 0:ab4e012489ef 20 /// Before asking a question or reporting a bug, please read
davidr99 0:ab4e012489ef 21 /// - http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/How_to_ask_a_software_question
davidr99 0:ab4e012489ef 22 /// - http://www.catb.org/esr/faqs/smart-questions.html
davidr99 0:ab4e012489ef 23 /// - http://www.chiark.greenend.org.uk/~shgtatham/bugs.html
davidr99 0:ab4e012489ef 24 ///
davidr99 0:ab4e012489ef 25 /// \par Overview
davidr99 0:ab4e012489ef 26 ///
davidr99 0:ab4e012489ef 27 /// RadioHead consists of 2 main sets of classes: Drivers and Managers.
davidr99 0:ab4e012489ef 28 ///
davidr99 0:ab4e012489ef 29 /// - Drivers provide low level access to a range of different packet radios and other packetized message transports.
davidr99 0:ab4e012489ef 30 /// - Managers provide high level message sending and receiving facilities for a range of different requirements.
davidr99 0:ab4e012489ef 31 ///
davidr99 0:ab4e012489ef 32 /// Every RadioHead program will have an instance of a Driver to provide access to the data radio or transport,
davidr99 0:ab4e012489ef 33 /// and a Manager that uses that driver to send and receive messages for the application. The programmer is required
davidr99 0:ab4e012489ef 34 /// to instantiate a Driver and a Manager, and to initialise the Manager. Thereafter the facilities of the Manager
davidr99 0:ab4e012489ef 35 /// can be used to send and receive messages.
davidr99 0:ab4e012489ef 36 ///
davidr99 0:ab4e012489ef 37 /// It is also possible to use a Driver on its own, without a Manager, although this only allows unaddressed,
davidr99 0:ab4e012489ef 38 /// unreliable transport via the Driver's facilities.
davidr99 0:ab4e012489ef 39 ///
davidr99 0:ab4e012489ef 40 /// In some specialised use cases, it is possible to instantiate more than one Driver and more than one Manager.
davidr99 0:ab4e012489ef 41 ///
davidr99 0:ab4e012489ef 42 /// A range of different common embedded microprocessor platforms are supported, allowing your project to run
davidr99 0:ab4e012489ef 43 /// on your choice of processor.
davidr99 0:ab4e012489ef 44 ///
davidr99 0:ab4e012489ef 45 /// Example programs are included to show the main modes of use.
davidr99 0:ab4e012489ef 46 ///
davidr99 0:ab4e012489ef 47 /// \par Drivers
davidr99 0:ab4e012489ef 48 ///
davidr99 0:ab4e012489ef 49 /// The following Drivers are provided:
davidr99 0:ab4e012489ef 50 ///
davidr99 0:ab4e012489ef 51 /// - RH_RF22
davidr99 0:ab4e012489ef 52 /// Works with Hope-RF
davidr99 0:ab4e012489ef 53 /// RF22B and RF23B based transceivers, and compatible chips and modules,
davidr99 0:ab4e012489ef 54 /// including the RFM22B transceiver module such as
davidr99 0:ab4e012489ef 55 /// this bare module: http://www.sparkfun.com/products/10153
davidr99 0:ab4e012489ef 56 /// and this shield: http://www.sparkfun.com/products/11018
davidr99 0:ab4e012489ef 57 /// and this board: http://www.anarduino.com/miniwireless
davidr99 0:ab4e012489ef 58 /// and RF23BP modules such as: http://www.anarduino.com/details.jsp?pid=130
davidr99 0:ab4e012489ef 59 /// Supports GFSK, FSK and OOK. Access to other chip
davidr99 0:ab4e012489ef 60 /// features such as on-chip temperature measurement, analog-digital
davidr99 0:ab4e012489ef 61 /// converter, transmitter power control etc is also provided.
davidr99 0:ab4e012489ef 62 ///
davidr99 0:ab4e012489ef 63 /// - RH_RF24
davidr99 0:ab4e012489ef 64 /// Works with Silicon Labs Si4460/4461/4463/4464 family of transceivers chip, and the equivalent
davidr99 0:ab4e012489ef 65 /// HopeRF RF24/26/27 family of chips and the HopeRF RFM24W/26W/27W modules.
davidr99 0:ab4e012489ef 66 /// Supports GFSK, FSK and OOK. Access to other chip
davidr99 0:ab4e012489ef 67 /// features such as on-chip temperature measurement, analog-digital
davidr99 0:ab4e012489ef 68 /// converter, transmitter power control etc is also provided.
davidr99 0:ab4e012489ef 69 ///
davidr99 0:ab4e012489ef 70 /// - RH_RF69
davidr99 0:ab4e012489ef 71 /// Works with Hope-RF
davidr99 0:ab4e012489ef 72 /// RF69B based radio modules, such as the RFM69 module, (as used on the excellent Moteino and Moteino-USB
davidr99 0:ab4e012489ef 73 /// boards from LowPowerLab http://lowpowerlab.com/moteino/ )
davidr99 0:ab4e012489ef 74 /// and compatible chips and modules such as RFM69W, RFM69HW, RFM69CW, RFM69HCW (Semtech SX1231, SX1231H).
davidr99 0:ab4e012489ef 75 /// Also works with Anarduino MiniWireless -CW and -HW boards http://www.anarduino.com/miniwireless/ including
davidr99 0:ab4e012489ef 76 /// the marvellous high powered MinWireless-HW (with 20dBm output for excellent range).
davidr99 0:ab4e012489ef 77 /// Supports GFSK, FSK.
davidr99 0:ab4e012489ef 78 ///
davidr99 0:ab4e012489ef 79 /// - RH_NRF24
davidr99 0:ab4e012489ef 80 /// Works with Nordic nRF24 based 2.4GHz radio modules, such as nRF24L01 and others.
davidr99 0:ab4e012489ef 81 /// Also works with Hope-RF RFM73
davidr99 0:ab4e012489ef 82 /// and compatible devices (such as BK2423). nRF24L01 and RFM73 can interoperate
davidr99 0:ab4e012489ef 83 /// with each other.
davidr99 0:ab4e012489ef 84 ///
davidr99 0:ab4e012489ef 85 /// - RH_NRF905
davidr99 0:ab4e012489ef 86 /// Works with Nordic nRF905 based 433/868/915 MHz radio modules.
davidr99 0:ab4e012489ef 87 ///
davidr99 0:ab4e012489ef 88 /// - RH_NRF51
davidr99 0:ab4e012489ef 89 /// Works with Nordic nRF51 compatible 2.4 GHz SoC/devices such as the nRF51822.
davidr99 0:ab4e012489ef 90 ///
davidr99 0:ab4e012489ef 91 /// - RH_RF95
davidr99 0:ab4e012489ef 92 /// Works with Semtech SX1276/77/78 and HopeRF RFM95/96/97/98 and other similar LoRa capable radios.
davidr99 0:ab4e012489ef 93 /// Supports Long Range (LoRa) with spread spectrum frequency hopping, large payloads etc.
davidr99 0:ab4e012489ef 94 /// FSK/GFSK/OOK modes are not (yet) supported.
davidr99 0:ab4e012489ef 95 ///
davidr99 0:ab4e012489ef 96 /// - RH_ASK
davidr99 0:ab4e012489ef 97 /// Works with a range of inexpensive ASK (amplitude shift keying) RF transceivers such as RX-B1
davidr99 0:ab4e012489ef 98 /// (also known as ST-RX04-ASK) receiver; TX-C1 transmitter and DR3100 transceiver; FS1000A/XY-MK-5V transceiver;
davidr99 0:ab4e012489ef 99 /// HopeRF RFM83C / RFM85. Supports ASK (OOK).
davidr99 0:ab4e012489ef 100 ///
davidr99 0:ab4e012489ef 101 /// - RH_Serial
davidr99 0:ab4e012489ef 102 /// Works with RS232, RS422, RS485, RS488 and other point-to-point and multidropped serial connections,
davidr99 0:ab4e012489ef 103 /// or with TTL serial UARTs such as those on Arduino and many other processors,
davidr99 0:ab4e012489ef 104 /// or with data radios with a
davidr99 0:ab4e012489ef 105 /// serial port interface. RH_Serial provides packetization and error detection over any hardware or
davidr99 0:ab4e012489ef 106 /// virtual serial connection. Also builds and runs on Linux and OSX.
davidr99 0:ab4e012489ef 107 ///
davidr99 0:ab4e012489ef 108 /// - RH_TCP
davidr99 0:ab4e012489ef 109 /// For use with simulated sketches compiled and running on Linux.
davidr99 0:ab4e012489ef 110 /// Works with tools/etherSimulator.pl to pass messages between simulated sketches, allowing
davidr99 0:ab4e012489ef 111 /// testing of Manager classes on Linux and without need for real radios or other transport hardware.
davidr99 0:ab4e012489ef 112 ///
davidr99 0:ab4e012489ef 113 /// Drivers can be used on their own to provide unaddressed, unreliable datagrams.
davidr99 0:ab4e012489ef 114 /// All drivers have the same identical API.
davidr99 0:ab4e012489ef 115 /// Or you can use any Driver with any of the Managers described below.
davidr99 0:ab4e012489ef 116 ///
davidr99 0:ab4e012489ef 117 /// We welcome contributions of well tested and well documented code to support other transports.
davidr99 0:ab4e012489ef 118 ///
davidr99 0:ab4e012489ef 119 /// \par Managers
davidr99 0:ab4e012489ef 120 ///
davidr99 0:ab4e012489ef 121 /// The following Mangers are provided:
davidr99 0:ab4e012489ef 122 ///
davidr99 0:ab4e012489ef 123 /// - RHDatagram
davidr99 0:ab4e012489ef 124 /// Addressed, unreliable variable length messages, with optional broadcast facilities.
davidr99 0:ab4e012489ef 125 ///
davidr99 0:ab4e012489ef 126 /// - RHReliableDatagram
davidr99 0:ab4e012489ef 127 /// Addressed, reliable, retransmitted, acknowledged variable length messages.
davidr99 0:ab4e012489ef 128 ///
davidr99 0:ab4e012489ef 129 /// - RHRouter
davidr99 0:ab4e012489ef 130 /// Multi-hop delivery from source node to destination node via 0 or more intermediate nodes, with manual routing.
davidr99 0:ab4e012489ef 131 ///
davidr99 0:ab4e012489ef 132 /// - RHMesh
davidr99 0:ab4e012489ef 133 /// Multi-hop delivery with automatic route discovery and rediscovery.
davidr99 0:ab4e012489ef 134 ///
davidr99 0:ab4e012489ef 135 /// Any Manager may be used with any Driver.
davidr99 0:ab4e012489ef 136 ///
davidr99 0:ab4e012489ef 137 /// \par Platforms
davidr99 0:ab4e012489ef 138 ///
davidr99 0:ab4e012489ef 139 /// A range of platforms is supported:
davidr99 0:ab4e012489ef 140 ///
davidr99 0:ab4e012489ef 141 /// - Arduino and the Arduino IDE (version 1.0 to 1.6.5 and later)
davidr99 0:ab4e012489ef 142 /// Including Diecimila, Uno, Mega, Leonardo, Yun, Due, Zero etc. http://arduino.cc/, Also similar boards such as
davidr99 0:ab4e012489ef 143 /// - Moteino http://lowpowerlab.com/moteino/
davidr99 0:ab4e012489ef 144 /// - Anarduino Mini http://www.anarduino.com/mini/
davidr99 0:ab4e012489ef 145 /// - RedBearLab Blend V1.0 http://redbearlab.com/blend/ (with Arduino 1.0.5 and RedBearLab Blend Add-On version 20140701)
davidr99 0:ab4e012489ef 146 /// - MoteinoMEGA https://lowpowerlab.com/shop/moteinomega
davidr99 0:ab4e012489ef 147 /// (with Arduino 1.0.5 and the MoteinoMEGA Arduino Core
davidr99 0:ab4e012489ef 148 /// https://github.com/LowPowerLab/Moteino/tree/master/MEGA/Core)
davidr99 0:ab4e012489ef 149 /// - etc.
davidr99 0:ab4e012489ef 150 ///
davidr99 0:ab4e012489ef 151 /// - ChipKit Uno32 board and the MPIDE development environment
davidr99 0:ab4e012489ef 152 /// http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-UNO32
davidr99 0:ab4e012489ef 153 ///
davidr99 0:ab4e012489ef 154 /// - Maple and Flymaple boards with libmaple and the Maple-IDE development environment
davidr99 0:ab4e012489ef 155 /// http://leaflabs.com/devices/maple/ and http://www.open-drone.org/flymaple
davidr99 0:ab4e012489ef 156 ///
davidr99 0:ab4e012489ef 157 /// - Teensy including Teensy 3.1 and earlier built using Arduino IDE 1.0.5 to 1.6.4 and later with
davidr99 0:ab4e012489ef 158 /// teensyduino addon 1.18 to 1.23 and later.
davidr99 0:ab4e012489ef 159 /// http://www.pjrc.com/teensy
davidr99 0:ab4e012489ef 160 ///
davidr99 0:ab4e012489ef 161 /// - ATtiny built using Arduino IDE 1.0.5 with the arduino-tiny support from https://code.google.com/p/arduino-tiny/
davidr99 0:ab4e012489ef 162 /// (Caution: these are very small processors and not all RadioHead features may be available, depending on memory requirements)
davidr99 0:ab4e012489ef 163 ///
davidr99 0:ab4e012489ef 164 /// - nRF51 compatible Arm chips such as nRF51822 with Arduino 1.6.4 and later using the procedures
davidr99 0:ab4e012489ef 165 /// in http://redbearlab.com/getting-started-nrf51822/
davidr99 0:ab4e012489ef 166 ///
davidr99 0:ab4e012489ef 167 /// - Raspberry Pi
davidr99 0:ab4e012489ef 168 /// Uses BCM2835 library for GPIO http://www.airspayce.com/mikem/bcm2835/
davidr99 0:ab4e012489ef 169 /// Currently works only with RH_NRF24 driver or other drivers that do not require interrupt support.
davidr99 0:ab4e012489ef 170 /// Contributed by Mike Poublon.
davidr99 0:ab4e012489ef 171 ///
davidr99 0:ab4e012489ef 172 /// - Linux and OSX
davidr99 0:ab4e012489ef 173 /// Using the RHutil/HardwareSerial class, the RH_Serial driver and any manager will
davidr99 0:ab4e012489ef 174 /// build and run on Linux and OSX. These can be used to build programs that talk securely and reliably to
davidr99 0:ab4e012489ef 175 /// Arduino and other processors or to other Linux or OSX hosts on a reliable, error detected datagram
davidr99 0:ab4e012489ef 176 /// protocol over a serial line.
davidr99 0:ab4e012489ef 177 ///
davidr99 0:ab4e012489ef 178 /// Other platforms are partially supported, such as Generic AVR 8 bit processors, MSP430.
davidr99 0:ab4e012489ef 179 /// We welcome contributions that will expand the range of supported platforms.
davidr99 0:ab4e012489ef 180 ///
davidr99 0:ab4e012489ef 181 /// RadioHead is available (through the efforts of others)
davidr99 0:ab4e012489ef 182 /// for PlatformIO. PlatformIO is a cross-platform code builder and the missing library manager.
davidr99 0:ab4e012489ef 183 /// http://platformio.org/#!/lib/show/124/RadioHead
davidr99 0:ab4e012489ef 184 ///
davidr99 0:ab4e012489ef 185 /// \par History
davidr99 0:ab4e012489ef 186 ///
davidr99 0:ab4e012489ef 187 /// RadioHead was created in April 2014, substantially based on code from some of our other earlier Radio libraries:
davidr99 0:ab4e012489ef 188 ///
davidr99 0:ab4e012489ef 189 /// - RHMesh, RHRouter, RHReliableDatagram and RHDatagram are derived from the RF22 library version 1.39.
davidr99 0:ab4e012489ef 190 /// - RH_RF22 is derived from the RF22 library version 1.39.
davidr99 0:ab4e012489ef 191 /// - RH_RF69 is derived from the RF69 library version 1.2.
davidr99 0:ab4e012489ef 192 /// - RH_ASK is based on the VirtualWire library version 1.26, after significant conversion to C++.
davidr99 0:ab4e012489ef 193 /// - RH_Serial was new.
davidr99 0:ab4e012489ef 194 /// - RH_NRF24 is based on the NRF24 library version 1.12, with some significant changes.
davidr99 0:ab4e012489ef 195 ///
davidr99 0:ab4e012489ef 196 /// During this combination and redevelopment, we have tried to retain all the processor dependencies and support from
davidr99 0:ab4e012489ef 197 /// the libraries that were contributed by other people. However not all platforms can be tested by us, so if you
davidr99 0:ab4e012489ef 198 /// find that support from some platform has not been successfully migrated, please feel free to fix it and send us a
davidr99 0:ab4e012489ef 199 /// patch.
davidr99 0:ab4e012489ef 200 ///
davidr99 0:ab4e012489ef 201 /// Users of RHMesh, RHRouter, RHReliableDatagram and RHDatagram in the previous RF22 library will find that their
davidr99 0:ab4e012489ef 202 /// existing code will run mostly without modification. See the RH_RF22 documentation for more details.
davidr99 0:ab4e012489ef 203 ///
davidr99 0:ab4e012489ef 204 /// \par Installation
davidr99 0:ab4e012489ef 205 ///
davidr99 0:ab4e012489ef 206 /// Install in the usual way: unzip the distribution zip file to the libraries
davidr99 0:ab4e012489ef 207 /// sub-folder of your sketchbook.
davidr99 0:ab4e012489ef 208 /// The example sketches will be visible in in your Arduino, mpide, maple-ide or whatever.
davidr99 0:ab4e012489ef 209 /// http://arduino.cc/en/Guide/Libraries
davidr99 0:ab4e012489ef 210 ///
davidr99 0:ab4e012489ef 211 /// \par Compatible Hardware Suppliers
davidr99 0:ab4e012489ef 212 ///
davidr99 0:ab4e012489ef 213 /// We have had good experiences with the following suppliers of RadioHead compatible hardware:
davidr99 0:ab4e012489ef 214 ///
davidr99 0:ab4e012489ef 215 /// - LittleBird http://littlebirdelectronics.com.au in Australia for all manner of Arduinos and radios.
davidr99 0:ab4e012489ef 216 /// - LowPowerLab http://lowpowerlab.com/moteino in USA for the excellent Moteino and Moteino-USB
davidr99 0:ab4e012489ef 217 /// boards which include Hope-RF RF69B radios on-board.
davidr99 0:ab4e012489ef 218 /// - Anarduino and HopeRF USA (http://www.hoperfusa.com and http://www.anarduino.com) who have a wide range
davidr99 0:ab4e012489ef 219 /// of HopeRF radios and Arduino integrated modules.
davidr99 0:ab4e012489ef 220 /// - SparkFun https://www.sparkfun.com/ in USA who design and sell a wide range of Arduinos and radio modules.
davidr99 0:ab4e012489ef 221 ///
davidr99 0:ab4e012489ef 222 /// \par Donations
davidr99 0:ab4e012489ef 223 ///
davidr99 0:ab4e012489ef 224 /// This library is offered under a free GPL license for those who want to use it that way.
davidr99 0:ab4e012489ef 225 /// We try hard to keep it up to date, fix bugs
davidr99 0:ab4e012489ef 226 /// and to provide free support. If this library has helped you save time or money, please consider donating at
davidr99 0:ab4e012489ef 227 /// http://www.airspayce.com or here:
davidr99 0:ab4e012489ef 228 ///
davidr99 0:ab4e012489ef 229 /// \htmlonly <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_donations" /> <input type="hidden" name="business" value="mikem@airspayce.com" /> <input type="hidden" name="lc" value="AU" /> <input type="hidden" name="item_name" value="Airspayce" /> <input type="hidden" name="item_number" value="RadioHead" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" /> <input type="image" alt="PayPal — The safer, easier way to pay online." name="submit" src="https://www.paypalobjects.com/en_AU/i/btn/btn_donateCC_LG.gif" /> <img alt="" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1" border="0" /></form> \endhtmlonly
davidr99 0:ab4e012489ef 230 ///
davidr99 0:ab4e012489ef 231 /// \par Trademarks
davidr99 0:ab4e012489ef 232 ///
davidr99 0:ab4e012489ef 233 /// RadioHead is a trademark of AirSpayce Pty Ltd. The RadioHead mark was first used on April 12 2014 for
davidr99 0:ab4e012489ef 234 /// international trade, and is used only in relation to data communications hardware and software and related services.
davidr99 0:ab4e012489ef 235 /// It is not to be confused with any other similar marks covering other goods and services.
davidr99 0:ab4e012489ef 236 ///
davidr99 0:ab4e012489ef 237 /// \par Copyright
davidr99 0:ab4e012489ef 238 ///
davidr99 0:ab4e012489ef 239 /// This software is Copyright (C) 2011-2014 Mike McCauley. Use is subject to license
davidr99 0:ab4e012489ef 240 /// conditions. The main licensing options available are GPL V2 or Commercial:
davidr99 0:ab4e012489ef 241 ///
davidr99 0:ab4e012489ef 242 /// \par Open Source Licensing GPL V2
davidr99 0:ab4e012489ef 243 ///
davidr99 0:ab4e012489ef 244 /// This is the appropriate option if you want to share the source code of your
davidr99 0:ab4e012489ef 245 /// application with everyone you distribute it to, and you also want to give them
davidr99 0:ab4e012489ef 246 /// the right to share who uses it. If you wish to use this software under Open
davidr99 0:ab4e012489ef 247 /// Source Licensing, you must contribute all your source code to the open source
davidr99 0:ab4e012489ef 248 /// community in accordance with the GPL Version 2 when your application is
davidr99 0:ab4e012489ef 249 /// distributed. See http://www.gnu.org/copyleft/gpl.html
davidr99 0:ab4e012489ef 250 ///
davidr99 0:ab4e012489ef 251 /// \par Commercial Licensing
davidr99 0:ab4e012489ef 252 ///
davidr99 0:ab4e012489ef 253 /// This is the appropriate option if you are creating proprietary applications
davidr99 0:ab4e012489ef 254 /// and you are not prepared to distribute and share the source code of your
davidr99 0:ab4e012489ef 255 /// application. Contact info@airspayce.com for details (do not use this address for anything other than
davidr99 0:ab4e012489ef 256 /// commercial license enquiries. For all other queries, using the RadioHead mailing list).
davidr99 0:ab4e012489ef 257 ///
davidr99 0:ab4e012489ef 258 /// \par Revision History
davidr99 0:ab4e012489ef 259 /// \version 1.1 2014-04-14<br>
davidr99 0:ab4e012489ef 260 /// Initial public release
davidr99 0:ab4e012489ef 261 /// \version 1.2 2014-04-23<br>
davidr99 0:ab4e012489ef 262 /// Fixed various typos. <br>
davidr99 0:ab4e012489ef 263 /// Added links to compatible Anarduino products.<br>
davidr99 0:ab4e012489ef 264 /// Added RHNRFSPIDriver, RH_NRF24 classes to support Nordic NRF24 based radios.
davidr99 0:ab4e012489ef 265 /// \version 1.3 2014-04-28<br>
davidr99 0:ab4e012489ef 266 /// Various documentation fixups.<br>
davidr99 0:ab4e012489ef 267 /// RHDatagram::setThisAddress() did not set the local copy of thisAddress. Reported by Steve Childress.<br>
davidr99 0:ab4e012489ef 268 /// Fixed a problem on Teensy with RF22 and RF69, where the interrupt pin needs to be set for input, <br>
davidr99 0:ab4e012489ef 269 /// else pin interrupt doesn't work properly. Reported by Steve Childress and patched by
davidr99 0:ab4e012489ef 270 /// Adrien van den Bossche. Thanks.<br>
davidr99 0:ab4e012489ef 271 /// Fixed a problem that prevented RF22 honouring setPromiscuous(true). Reported by Steve Childress.<br>
davidr99 0:ab4e012489ef 272 /// Updated documentation to clarify some issues to do with maximum message lengths
davidr99 0:ab4e012489ef 273 /// reported by Steve Childress.<br>
davidr99 0:ab4e012489ef 274 /// Added support for yield() on systems that support it (currently Arduino 1.5.5 and later)
davidr99 0:ab4e012489ef 275 /// so that spin-loops can suport multitasking. Suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 276 /// Added RH_RF22::setGpioReversed() so the reversal it can be configured at run-time after
davidr99 0:ab4e012489ef 277 /// radio initialisation. It must now be called _after_ init(). Suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 278 /// \version 1.4 2014-04-29<br>
davidr99 0:ab4e012489ef 279 /// Fixed further problems with Teensy compatibility for RH_RF22. Tested on Teensy 3.1.
davidr99 0:ab4e012489ef 280 /// The example/rf22_* examples now run out of the box with the wiring connections as documented for Teensy
davidr99 0:ab4e012489ef 281 /// in RH_RF22.<br>
davidr99 0:ab4e012489ef 282 /// Added YIELDs to spin-loops in RHRouter, RHMesh and RHReliableDatagram, RH_NRF24.<br>
davidr99 0:ab4e012489ef 283 /// Tested RH_Serial examples with Teensy 3.1: they now run out of the box.<br>
davidr99 0:ab4e012489ef 284 /// Tested RH_ASK examples with Teensy 3.1: they now run out of the box.<br>
davidr99 0:ab4e012489ef 285 /// Reduced default SPI speed for NRF24 from 8MHz to 1MHz on Teensy, to improve reliability when
davidr99 0:ab4e012489ef 286 /// poor wiring is in use.<br>
davidr99 0:ab4e012489ef 287 /// on some devices such as Teensy.<br>
davidr99 0:ab4e012489ef 288 /// Tested RH_NRF24 examples with Teensy 3.1: they now run out of the box.<br>
davidr99 0:ab4e012489ef 289 /// \version 1.5 2014-04-29<br>
davidr99 0:ab4e012489ef 290 /// Added support for Nordic Semiconductor nRF905 transceiver with RH_NRF905 driver. Also
davidr99 0:ab4e012489ef 291 /// added examples for nRF905 and tested on Teensy 3.1
davidr99 0:ab4e012489ef 292 /// \version 1.6 2014-04-30<br>
davidr99 0:ab4e012489ef 293 /// NRF905 examples were missing
davidr99 0:ab4e012489ef 294 /// \version 1.7 2014-05-03<br>
davidr99 0:ab4e012489ef 295 /// Added support for Arduino Due. Tested with RH_NRF905, RH_Serial, RH_ASK.
davidr99 0:ab4e012489ef 296 /// IMPORTANT CHANGE to interrupt pins on Arduino with RH_RF22 and RH_RF69 constructors:
davidr99 0:ab4e012489ef 297 /// previously, you had to specify the interrupt _number_ not the interrupt _pin_. Arduinos and Uno32
davidr99 0:ab4e012489ef 298 /// are now consistent with all other platforms: you must specify the interrupt pin number. Default
davidr99 0:ab4e012489ef 299 /// changed to pin 2 (a common choice with RF22 shields).
davidr99 0:ab4e012489ef 300 /// Removed examples/maple/maple_rf22_reliable_datagram_client and
davidr99 0:ab4e012489ef 301 /// examples/maple/maple_rf22_reliable_datagram_client since the rf22 examples now work out
davidr99 0:ab4e012489ef 302 /// of the box with Flymaple.
davidr99 0:ab4e012489ef 303 /// Removed examples/uno32/uno32_rf22_reliable_datagram_client and
davidr99 0:ab4e012489ef 304 /// examples/uno32/uno32_rf22_reliable_datagram_client since the rf22 examples now work out
davidr99 0:ab4e012489ef 305 /// of the box with ChipKit Uno32.
davidr99 0:ab4e012489ef 306 /// \version 1.8 2014-05-08 <br>
davidr99 0:ab4e012489ef 307 /// Added support for YIELD in Teensy 2 and 3, suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 308 /// Documentation updates. Clarify use of headers and Flags<br>
davidr99 0:ab4e012489ef 309 /// Fixed misalignment in RH_RF69 between ModemConfigChoice definitions and the implemented choices
davidr99 0:ab4e012489ef 310 /// which meant you didnt get the choice you thought and GFSK_Rb55555Fd50 hung the transmitter.<br>
davidr99 0:ab4e012489ef 311 /// Preliminary work on Linux simulator.
davidr99 0:ab4e012489ef 312 /// \version 1.9 2014-05-14 <br>
davidr99 0:ab4e012489ef 313 /// Added support for using Timer 2 instead of Timer 1 on Arduino in RH_ASK when
davidr99 0:ab4e012489ef 314 /// RH_ASK_ARDUINO_USE_TIMER2 is defined. With the kind assistance of
davidr99 0:ab4e012489ef 315 /// Luc Small. Thanks!<br>
davidr99 0:ab4e012489ef 316 /// Updated comments in RHReliableDatagram concerning servers, retries, timeouts and delays.
davidr99 0:ab4e012489ef 317 /// Fixed an error in RHReliableDatagram where recvfrom return value was not checked.
davidr99 0:ab4e012489ef 318 /// Reported by Steve Childress.<br>
davidr99 0:ab4e012489ef 319 /// Added Linux simulator support so simple RadioHead sketches can be compiled and run on Linux.<br>
davidr99 0:ab4e012489ef 320 /// Added RH_TCP driver to permit message passing between simulated sketches on Linux.<br>
davidr99 0:ab4e012489ef 321 /// Added example simulator sketches.<br>
davidr99 0:ab4e012489ef 322 /// Added tools/etherSimulator.pl, a simulator of the 'Luminiferous Ether' that passes
davidr99 0:ab4e012489ef 323 /// messages between simulated sketches and can simulate random message loss etc.<br>
davidr99 0:ab4e012489ef 324 /// Fixed a number of typos and improved some documentation.<br>
davidr99 0:ab4e012489ef 325 /// \version 1.10 2014-05-15 <br>
davidr99 0:ab4e012489ef 326 /// Added support for RFM73 modules to RH_NRF24. These 2 radios are very similar, and can interoperate
davidr99 0:ab4e012489ef 327 /// with each other. Added new RH_NRF24::TransmitPower enums for the RFM73, which has a different
davidr99 0:ab4e012489ef 328 /// range of available powers<br>
davidr99 0:ab4e012489ef 329 /// reduced the default SPI bus speed for RH_NRF24 to 1MHz, since so many modules and CPU have problems
davidr99 0:ab4e012489ef 330 /// with 8MHz.<br>
davidr99 0:ab4e012489ef 331 /// \version 1.11 2014-05-18<br>
davidr99 0:ab4e012489ef 332 /// Testing RH_RF22 with RFM23BP and 3.3V Teensy 3.1 and 5V Arduinos.
davidr99 0:ab4e012489ef 333 /// Updated documentation with respect to GPIO and antenna
davidr99 0:ab4e012489ef 334 /// control pins for RFM23. Updated documentation with respect to transmitter power control for RFM23<br>
davidr99 0:ab4e012489ef 335 /// Fixed a problem with RH_RF22 driver, where GPIO TX and RX pins were not configured during
davidr99 0:ab4e012489ef 336 /// initialisation, causing poor transmit power and sensitivity on those RF22/RF23 devices where GPIO controls
davidr99 0:ab4e012489ef 337 /// the antenna selection pins.
davidr99 0:ab4e012489ef 338 /// \version 1.12 2014-05-20<br>
davidr99 0:ab4e012489ef 339 /// Testing with RF69HW and the RH_RF69 driver. Works well with the Anarduino MiniWireless -CW and -HW
davidr99 0:ab4e012489ef 340 /// boards http://www.anarduino.com/miniwireless/ including
davidr99 0:ab4e012489ef 341 /// the marvellous high powered MinWireless-HW (with 20dBm output for excellent range).<br>
davidr99 0:ab4e012489ef 342 /// Clarified documentation of RH_RF69::setTxPower values for different models of RF69.<br>
davidr99 0:ab4e012489ef 343 /// Added RHReliableDatagram::resetRetransmissions().<br>
davidr99 0:ab4e012489ef 344 /// Retransmission count precision increased to uin32_t.<br>
davidr99 0:ab4e012489ef 345 /// Added data about actual power measurements from RFM22 module.<br>
davidr99 0:ab4e012489ef 346 /// \version 1.13 2014-05-23<br>
davidr99 0:ab4e012489ef 347 /// setHeaderFlags(flags) changed to setHeaderFlags(set, clear), enabling any flags to be
davidr99 0:ab4e012489ef 348 /// individually set and cleared by either RadioHead or application code. Requested by Steve Childress.<br>
davidr99 0:ab4e012489ef 349 /// Fixed power output setting for boost power on RF69HW for 18, 19 and 20dBm.<br>
davidr99 0:ab4e012489ef 350 /// Added data about actual power measurements from RFM69W and RFM69HW modules.<br>
davidr99 0:ab4e012489ef 351 /// \version 1.14 2014-05-26<br>
davidr99 0:ab4e012489ef 352 /// RH_RF69::init() now always sets the PA boost back to the default settings, else can get invalid
davidr99 0:ab4e012489ef 353 /// PA power modes after uploading new sketches without a power cycle. Reported by Bryan.<br>
davidr99 0:ab4e012489ef 354 /// Added new macros RH_VERSION_MAJOR RH_VERSION_MINOR, with automatic maintenance in Makefile.<br>
davidr99 0:ab4e012489ef 355 /// Improvements to RH_TCP: constructor now honours the server argument in the form "servername:port".<br>
davidr99 0:ab4e012489ef 356 /// Added YIELD to RHReliableDatagram::recvfromAckTimeout. Requested by Steve Childress.<br>
davidr99 0:ab4e012489ef 357 /// Fixed a problem with RH_RF22 reliable datagram acknowledgements that was introduced in version 1.13.
davidr99 0:ab4e012489ef 358 /// Reported by Steve Childress.<br>
davidr99 0:ab4e012489ef 359 /// \version 1.15 2014-05-27<br>
davidr99 0:ab4e012489ef 360 /// Fixed a problem with the RadioHead .zip link.
davidr99 0:ab4e012489ef 361 /// \version 1.16 2014-05-30 <br>
davidr99 0:ab4e012489ef 362 /// Fixed RH_RF22 so that lastRssi() returns the signal strength in dBm. Suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 363 /// Added support for getLastPreambleTime() to RH_RF69. Requested by Steve Childress.<br>
davidr99 0:ab4e012489ef 364 /// RH_NRF24::init() now checks if there is a device connected and responding, else init() will fail.
davidr99 0:ab4e012489ef 365 /// Suggested by Steve Brown.<br>
davidr99 0:ab4e012489ef 366 /// RHSoftwareSPI now initialises default values for SPI pins MOSI = 12, MISO = 11 and SCK = 13.<br>
davidr99 0:ab4e012489ef 367 /// Fixed some problems that prevented RH_NRF24 working with mixed software and hardware SPI
davidr99 0:ab4e012489ef 368 /// on different devices: a race condition
davidr99 0:ab4e012489ef 369 /// due to slow SPI transfers and fast acknowledgement.<br>
davidr99 0:ab4e012489ef 370 /// \version 1.17 2014-06-02 <br>
davidr99 0:ab4e012489ef 371 /// Fixed a debug typo in RHReliableDatagram that was introduced in 1.16.<br>
davidr99 0:ab4e012489ef 372 /// RH_NRF24 now sets default power, data rate and channel in init(), in case another
davidr99 0:ab4e012489ef 373 /// app has previously set different values without powerdown.<br>
davidr99 0:ab4e012489ef 374 /// Caution: there are still problems with RH_NRF24 and Software SPI. Do not use.<br>
davidr99 0:ab4e012489ef 375 /// \version 1.18 2014-06-02<br>
davidr99 0:ab4e012489ef 376 /// Improvements to performance of RH_NRF24 statusRead, allowing RH_NRF24 and Software SPI
davidr99 0:ab4e012489ef 377 /// to operate on slow devices like Arduino Uno.<br>
davidr99 0:ab4e012489ef 378 /// \version 1.19 2014-06-19<br>
davidr99 0:ab4e012489ef 379 /// Added examples ask_transmitter.pde and ask_receiver.pde.<br>
davidr99 0:ab4e012489ef 380 /// Fixed an error in the RH_RF22 doc for connection of Teensy to RF22.<br>
davidr99 0:ab4e012489ef 381 /// Improved documentation of start symbol bit patterns in RH_ASK.cpp
davidr99 0:ab4e012489ef 382 /// \version 1.20 2014-06-24<br>
davidr99 0:ab4e012489ef 383 /// Fixed a problem with compiling on platforms such as ATTiny where SS is not defined.<br>
davidr99 0:ab4e012489ef 384 /// Added YIELD to RHMesh::recvfromAckTimeout().<br>
davidr99 0:ab4e012489ef 385 /// \version 1.21 2014-06-24<br>
davidr99 0:ab4e012489ef 386 /// Fixed an issue in RH_Serial where characters might be lost with back-to-back frames.
davidr99 0:ab4e012489ef 387 /// Suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 388 /// Brought previous RHutil/crc16.h code into mainline RHCRC.cpp to prevent name collisions
davidr99 0:ab4e012489ef 389 /// with other similarly named code in other libraries. Suggested by Steve Childress.<br>
davidr99 0:ab4e012489ef 390 /// Fix SPI bus speed errors on 8MHz Arduinos.
davidr99 0:ab4e012489ef 391 /// \version 1.22 2014-07-01<br>
davidr99 0:ab4e012489ef 392 /// Update RH_ASK documentation for common wiring connections.<br>
davidr99 0:ab4e012489ef 393 /// Testing RH_ASK with HopeRF RFM83C/RFM85 courtesy Anarduino http://www.anarduino.com/<br>
davidr99 0:ab4e012489ef 394 /// Testing RH_NRF24 with Itead Studio IBoard Pro http://imall.iteadstudio.com/iboard-pro.html
davidr99 0:ab4e012489ef 395 /// using both hardware SPI on the ITDB02 Parallel LCD Module Interface pins and software SPI
davidr99 0:ab4e012489ef 396 /// on the nRF24L01+ Module Interface pins. Documented wiring required.<br>
davidr99 0:ab4e012489ef 397 /// Added support for AVR 1284 and 1284p, contributed by Peter Scargill.
davidr99 0:ab4e012489ef 398 /// Added support for Semtech SX1276/77/78 and HopeRF RFM95/96/97/98 and other similar LoRa capable radios
davidr99 0:ab4e012489ef 399 /// in LoRa mode only. Tested with the excellent MiniWirelessLoRa from
davidr99 0:ab4e012489ef 400 /// Anarduino http://www.anarduino.com/miniwireless<br>
davidr99 0:ab4e012489ef 401 /// \version 1.23 2014-07-03<br>
davidr99 0:ab4e012489ef 402 /// Changed the default modulation for RH_RF69 to GFSK_Rb250Fd250, since the previous default
davidr99 0:ab4e012489ef 403 /// was not very reliable.<br>
davidr99 0:ab4e012489ef 404 /// Documented RH_RF95 range tests.<br>
davidr99 0:ab4e012489ef 405 /// Improvements to RH_RF22 RSSI readings so that lastRssi correctly returns the last message in dBm.<br>
davidr99 0:ab4e012489ef 406 /// \version 1.24 2014-07-18
davidr99 0:ab4e012489ef 407 /// Added support for building RadioHead for STM32F4 Discovery boards, using the native STM Firmware libraries,
davidr99 0:ab4e012489ef 408 /// in order to support Codec2WalkieTalkie (http://www.airspayce.com/mikem/Codec2WalkieTalkie)
davidr99 0:ab4e012489ef 409 /// and other projects. See STM32ArduinoCompat.<br>
davidr99 0:ab4e012489ef 410 /// Default modulation for RH_RF95 was incorrectly set to a very slow Bw125Cr48Sf4096
davidr99 0:ab4e012489ef 411 /// \version 1.25 2014-07-25
davidr99 0:ab4e012489ef 412 /// The available() function will longer terminate any current transmission, and force receive mode.
davidr99 0:ab4e012489ef 413 /// Now, if there is no unprocessed incoming message and an outgoing message is currently being transmitted,
davidr99 0:ab4e012489ef 414 /// available() will return false.<br>
davidr99 0:ab4e012489ef 415 /// RHRouter::sendtoWait(uint8_t*, uint8_t, uint8_t, uint8_t) renamed to sendtoFromSourceWait due to conflicts
davidr99 0:ab4e012489ef 416 /// with new sendtoWait() with optional flags.<br>
davidr99 0:ab4e012489ef 417 /// RHMEsh and RHRouter already supported end-to-end application layer flags, but RHMesh::sendtoWait()
davidr99 0:ab4e012489ef 418 /// and RHRouter::sendToWait have now been extended to expose a way to send optional application layer flags.
davidr99 0:ab4e012489ef 419 /// \version 1.26 2014-08-12
davidr99 0:ab4e012489ef 420 /// Fixed a Teensy 2.0 compile problem due yield() not available on Teensy < 3.0. <br>
davidr99 0:ab4e012489ef 421 /// Adjusted the algorithm of RH_RF69::temperatureRead() to more closely reflect reality.<br>
davidr99 0:ab4e012489ef 422 /// Added functions to RHGenericDriver to get driver packet statistics: rxBad(), rxGood(), txGood().<br>
davidr99 0:ab4e012489ef 423 /// Added RH_RF69::printRegisters().<br>
davidr99 0:ab4e012489ef 424 /// RH_RF95::printRegisters() was incorrectly printing the register index instead of the address.
davidr99 0:ab4e012489ef 425 /// Reported by Phang Moh Lim.<br>
davidr99 0:ab4e012489ef 426 /// RH_RF95, added definitions for some more registers that are usable in LoRa mode.<br>
davidr99 0:ab4e012489ef 427 /// RH_RF95::setTxPower now uses RH_RF95_PA_DAC_ENABLE to achieve 21, 22 and 23dBm.<br>
davidr99 0:ab4e012489ef 428 /// RH_RF95, updated power output measurements.<br>
davidr99 0:ab4e012489ef 429 /// Testing RH_RF69 on Teensy 3.1 with RF69 on PJRC breakout board. OK.<br>
davidr99 0:ab4e012489ef 430 /// Improvements so RadioHead will build under Arduino where SPI is not supported, such as
davidr99 0:ab4e012489ef 431 /// ATTiny.<br>
davidr99 0:ab4e012489ef 432 /// Improvements so RadioHead will build for ATTiny using Arduino IDE and tinycore arduino-tiny-0100-0018.zip.<br>
davidr99 0:ab4e012489ef 433 /// Testing RH_ASK on ATTiny85. Reduced RAM footprint.
davidr99 0:ab4e012489ef 434 /// Added helpful documentation. Caution: RAM memory is *very* tight on this platform.<br>
davidr99 0:ab4e012489ef 435 /// RH_RF22 and RH_RF69, added setIdleMode() function to allow the idle mode radio operating state
davidr99 0:ab4e012489ef 436 /// to be controlled for lower idle power consumption at the expense of slower transitions to TX and RX.<br>
davidr99 0:ab4e012489ef 437 /// \version 1.27 2014-08-13
davidr99 0:ab4e012489ef 438 /// All RH_RF69 modulation schemes now have data whitening enabled by default.<br>
davidr99 0:ab4e012489ef 439 /// Tested and added a number of OOK modulation schemes to RH_RF69 Modem config table.<br>
davidr99 0:ab4e012489ef 440 /// Minor improvements to a number of the faster RH_RF69 modulation schemes, but some slower ones
davidr99 0:ab4e012489ef 441 /// are still not working correctly.<br>
davidr99 0:ab4e012489ef 442 /// \version 1.28 2014-08-20
davidr99 0:ab4e012489ef 443 /// Added new RH_RF24 driver to support Si446x, RF24/26/26, RFM24/26/27 family of transceivers.
davidr99 0:ab4e012489ef 444 /// Tested with the excellent
davidr99 0:ab4e012489ef 445 /// Anarduino Mini and RFM24W and RFM26W with the generous assistance of the good people at
davidr99 0:ab4e012489ef 446 /// Anarduino http://www.anarduino.com.
davidr99 0:ab4e012489ef 447 /// \version 1.29 2014-08-21
davidr99 0:ab4e012489ef 448 /// Fixed a compile error in RH_RF24 introduced at the last minute in hte previous release.<br>
davidr99 0:ab4e012489ef 449 /// Improvements to RH_RF69 modulation schemes: now include the AFCBW in teh ModemConfig.<br>
davidr99 0:ab4e012489ef 450 /// ModemConfig RH_RF69::FSK_Rb2Fd5 and RH_RF69::GFSK_Rb2Fd5 are now working.<br>
davidr99 0:ab4e012489ef 451 /// \version 1.30 2014-08-25
davidr99 0:ab4e012489ef 452 /// Fixed some compile problems with ATtiny84 on Arduino 1.5.5 reported by Glen Cook.<br>
davidr99 0:ab4e012489ef 453 /// \version 1.31 2014-08-27
davidr99 0:ab4e012489ef 454 /// Changed RH_RF69 FSK and GFSK modulations from Rb2_4Fd2_4 to Rb2_4Fd4_8 and FSK_Rb4_8Fd4_8 to FSK_Rb4_8Fd9_6
davidr99 0:ab4e012489ef 455 /// since the previous ones were unreliable (they had modulation indexes of 1).<br>
davidr99 0:ab4e012489ef 456 /// \version 1.32 2014-08-28
davidr99 0:ab4e012489ef 457 /// Testing with RedBearLab Blend board http://redbearlab.com/blend/. OK.<br>
davidr99 0:ab4e012489ef 458 /// Changed more RH_RF69 FSK and GFSK slowish modulations to have modulation index of 2 instead of 1.
davidr99 0:ab4e012489ef 459 /// This required chnaging the symbolic names.<br>
davidr99 0:ab4e012489ef 460 /// \version 1.33 2014-09-01
davidr99 0:ab4e012489ef 461 /// Added support for sleep mode in RHGeneric driver, with new mode
davidr99 0:ab4e012489ef 462 /// RHModeSleep and new virtual function sleep().<br>
davidr99 0:ab4e012489ef 463 /// Added support for sleep to RH_RF69, RH_RF22, RH_NRF24, RH_RF24, RH_RF95 drivers.<br>
davidr99 0:ab4e012489ef 464 /// \version 1.34 2014-09-19
davidr99 0:ab4e012489ef 465 /// Fixed compile errors in example rf22_router_test.<br>
davidr99 0:ab4e012489ef 466 /// Fixed a problem with RH_NRF24::setNetworkAddress, also improvements to RH_NRF24 register printing.
davidr99 0:ab4e012489ef 467 /// Patched by Yveaux.<br>
davidr99 0:ab4e012489ef 468 /// Improvements to RH_NRF24 initialisation for version 2.0 silicon.<br>
davidr99 0:ab4e012489ef 469 /// Fixed problem with ambigiguous print call in RH_RFM69 when compiling for Codec2.<br>
davidr99 0:ab4e012489ef 470 /// Fixed a problem with RH_NRF24 on RFM73 where the LNA gain was not set properly, reducing the sensitivity
davidr99 0:ab4e012489ef 471 /// of the receiver.
davidr99 0:ab4e012489ef 472 /// \version 1.35 2014-09-19
davidr99 0:ab4e012489ef 473 /// Fixed a problem with interrupt setup on RH_RF95 with Teensy3.1. Reported by AD.<br>
davidr99 0:ab4e012489ef 474 /// \version 1.36 2014-09-22
davidr99 0:ab4e012489ef 475 /// Improvements to interrupt pin assignments for __AVR_ATmega1284__ and__AVR_ATmega1284P__, provided by
davidr99 0:ab4e012489ef 476 /// Peter Scargill.<br>
davidr99 0:ab4e012489ef 477 /// Work around a bug in Arduino 1.0.6 where digitalPinToInterrupt is defined but NOT_AN_INTERRUPT is not.<br>
davidr99 0:ab4e012489ef 478 /// \version 1.37 2014-10-19
davidr99 0:ab4e012489ef 479 /// Updated doc for connecting RH_NRF24 to Arduino Mega.<br>
davidr99 0:ab4e012489ef 480 /// Changes to RHGenericDriver::setHeaderFlags(), so that the default for the clear argument
davidr99 0:ab4e012489ef 481 /// is now RH_FLAGS_APPLICATION_SPECIFIC, which is less surprising to users.
davidr99 0:ab4e012489ef 482 /// Testing with the excellent MoteinoMEGA from LowPowerLab
davidr99 0:ab4e012489ef 483 /// https://lowpowerlab.com/shop/moteinomega with on-board RFM69W.
davidr99 0:ab4e012489ef 484 /// \version 1.38 2014-12-29
davidr99 0:ab4e012489ef 485 /// Fixed compile warning on some platforms where RH_RF24::send and RH_RF24::writeTxFifo
davidr99 0:ab4e012489ef 486 /// did not return a value.<br>
davidr99 0:ab4e012489ef 487 /// Fixed some more compiler warnings in RH_RF24 on some platforms.<br>
davidr99 0:ab4e012489ef 488 /// Refactored printRegisters for some radios. Printing to Serial
davidr99 0:ab4e012489ef 489 /// is now controlled by the definition of RH_HAVE_SERIAL.<br>
davidr99 0:ab4e012489ef 490 /// Added partial support for ARM M4 w/CMSIS with STM's Hardware Abstraction lib for
davidr99 0:ab4e012489ef 491 /// Steve Childress.<br>
davidr99 0:ab4e012489ef 492 /// \version 1.39 2014-12-30
davidr99 0:ab4e012489ef 493 /// Fix some compiler warnings under IAR.<br>
davidr99 0:ab4e012489ef 494 /// RH_HAVE_SERIAL and Serial.print calls removed for ATTiny platforms.<br>
davidr99 0:ab4e012489ef 495 /// \version 1.40 2015-03-09
davidr99 0:ab4e012489ef 496 /// Added notice about availability on PlatformIO, thanks to Ivan Kravets.<br>
davidr99 0:ab4e012489ef 497 /// Fixed a problem with RH_NRF24 where short packet lengths would occasionally not be trasmitted
davidr99 0:ab4e012489ef 498 /// due to a race condition with RH_NRF24_TX_DS. Reported by Mark Fox.<br>
davidr99 0:ab4e012489ef 499 /// \version 1.41 2015-03-29
davidr99 0:ab4e012489ef 500 /// RH_RF22, RH_RF24, RH_RF69 and RH_RF95 improved to allow driver.init() to be called multiple
davidr99 0:ab4e012489ef 501 /// times without reallocating a new interrupt, allowing the driver to be reinitialised
davidr99 0:ab4e012489ef 502 /// after sleeping or powering down.
davidr99 0:ab4e012489ef 503 /// \version 1.42 2015-05-17
davidr99 0:ab4e012489ef 504 /// Added support for RH_NRF24 driver on Raspberry Pi, using BCM2835
davidr99 0:ab4e012489ef 505 /// library for GPIO pin IO. Contributed by Mike Poublon.<br>
davidr99 0:ab4e012489ef 506 /// Tested RH_NRF24 module with NRF24L01+PA+LNA SMA Antenna Wireless Transceiver modules
davidr99 0:ab4e012489ef 507 /// similar to: http://www.elecfreaks.com/wiki/index.php?title=2.4G_Wireless_nRF24L01p_with_PA_and_LNA
davidr99 0:ab4e012489ef 508 /// works with no software changes. Measured max power output 18dBm.<br>
davidr99 0:ab4e012489ef 509 /// \version 1.43 2015-08-02
davidr99 0:ab4e012489ef 510 /// Added RH_NRF51 driver to support Nordic nRF51 family processor with 2.4GHz radio such
davidr99 0:ab4e012489ef 511 /// as nRF51822, to be built on Arduino 1.6.4 and later. Tested with RedBearLabs nRF51822 board
davidr99 0:ab4e012489ef 512 /// and BLE Nano kit<br>
davidr99 0:ab4e012489ef 513 /// \version 1.44 2015-08-08
davidr99 0:ab4e012489ef 514 /// Fixed errors with compiling on some platforms without serial, such as ATTiny.
davidr99 0:ab4e012489ef 515 /// Reported by Friedrich Müller.<br>
davidr99 0:ab4e012489ef 516 /// \version 1.45 2015-08-13
davidr99 0:ab4e012489ef 517 /// Added support for using RH_Serial on Linux and OSX (new class RHutil/HardwareSerial
davidr99 0:ab4e012489ef 518 /// encapsulates serial ports on those platforms). Example examples/serial*/* upgraded
davidr99 0:ab4e012489ef 519 /// to build and run on Linux and OSX using the tools/simBuild builder.
davidr99 0:ab4e012489ef 520 /// RHMesh, RHRouter and RHReliableDatagram updated so they can use RH_Serial without
davidr99 0:ab4e012489ef 521 /// polling loops on Linux and OSX for CPU efficiency.<br>
davidr99 0:ab4e012489ef 522 /// \version 1.46 2015-08-14
davidr99 0:ab4e012489ef 523 /// Amplified some doc concerning Linux and OSX RH_Serial. Added support for 230400
davidr99 0:ab4e012489ef 524 /// baud rate in HardwareSerial.<br>
davidr99 0:ab4e012489ef 525 /// Added sample sketches nrf51_audio_tx and nrf51_audio_rx which show how to
davidr99 0:ab4e012489ef 526 /// build an audio TX/RX pair with RedBear nRF51822 boards and a SparkFun MCP4725 DAC board.
davidr99 0:ab4e012489ef 527 /// Uses the built-in ADC of the nRF51822 to sample audio at 5kHz and transmit packets
davidr99 0:ab4e012489ef 528 /// to the receiver which plays them via the DAC.<br>
davidr99 0:ab4e012489ef 529 /// \version 1.47 2015-09-18
davidr99 0:ab4e012489ef 530 /// Removed top level Makefile from distribution: its only used by the developer and
davidr99 0:ab4e012489ef 531 /// its presence confuses some people.<br>
davidr99 0:ab4e012489ef 532 /// Fixed a problem with RHReliableDatagram with some versions of Raspberry Pi random() that causes
davidr99 0:ab4e012489ef 533 /// problems: random(min, max) sometimes exceeds its max limit.
davidr99 0:ab4e012489ef 534 /// \version 1.48 2015-09-30
davidr99 0:ab4e012489ef 535 /// Added support for Arduino Zero. Tested on Arduino Zero Pro.
davidr99 0:ab4e012489ef 536 ///
davidr99 0:ab4e012489ef 537 /// \author Mike McCauley. DO NOT CONTACT THE AUTHOR DIRECTLY. USE THE MAILING LIST GIVEN ABOVE
davidr99 0:ab4e012489ef 538
davidr99 0:ab4e012489ef 539 #ifndef RadioHead_h
davidr99 0:ab4e012489ef 540 #define RadioHead_h
davidr99 0:ab4e012489ef 541
davidr99 0:ab4e012489ef 542 // Official version numbers are maintained automatically by Makefile:
davidr99 0:ab4e012489ef 543 #define RH_VERSION_MAJOR 1
davidr99 0:ab4e012489ef 544 #define RH_VERSION_MINOR 48
davidr99 0:ab4e012489ef 545
davidr99 0:ab4e012489ef 546 // Symbolic names for currently supported platform types
davidr99 0:ab4e012489ef 547 #define RH_PLATFORM_ARDUINO 1
davidr99 0:ab4e012489ef 548 #define RH_PLATFORM_MSP430 2
davidr99 0:ab4e012489ef 549 #define RH_PLATFORM_STM32 3
davidr99 0:ab4e012489ef 550 #define RH_PLATFORM_GENERIC_AVR8 4
davidr99 0:ab4e012489ef 551 #define RH_PLATFORM_UNO32 5
davidr99 0:ab4e012489ef 552 #define RH_PLATFORM_UNIX 6
davidr99 0:ab4e012489ef 553 #define RH_PLATFORM_STM32STD 7
davidr99 0:ab4e012489ef 554 #define RH_PLATFORM_STM32F4_HAL 8
davidr99 0:ab4e012489ef 555 #define RH_PLATFORM_RASPI 9
davidr99 0:ab4e012489ef 556 #define RH_PLATFORM_NRF51 10
davidr99 0:ab4e012489ef 557
davidr99 0:ab4e012489ef 558 ////////////////////////////////////////////////////
davidr99 0:ab4e012489ef 559 // Select platform automatically, if possible
davidr99 0:ab4e012489ef 560 #ifndef RH_PLATFORM
davidr99 0:ab4e012489ef 561 #if defined(MPIDE)
davidr99 0:ab4e012489ef 562 #define RH_PLATFORM RH_PLATFORM_UNO32
davidr99 0:ab4e012489ef 563 #elif defined(NRF51)
davidr99 0:ab4e012489ef 564 #define RH_PLATFORM RH_PLATFORM_NRF51
davidr99 0:ab4e012489ef 565 #elif defined(ARDUINO)
davidr99 0:ab4e012489ef 566 #define RH_PLATFORM RH_PLATFORM_ARDUINO
davidr99 0:ab4e012489ef 567 #elif defined(__MSP430G2452__) || defined(__MSP430G2553__)
davidr99 0:ab4e012489ef 568 #define RH_PLATFORM RH_PLATFORM_MSP430
davidr99 0:ab4e012489ef 569 #elif defined(MCU_STM32F103RE)
davidr99 0:ab4e012489ef 570 #define RH_PLATFORM RH_PLATFORM_STM32
davidr99 0:ab4e012489ef 571 #elif defined(USE_STDPERIPH_DRIVER)
davidr99 0:ab4e012489ef 572 #define RH_PLATFORM RH_PLATFORM_STM32STD
davidr99 0:ab4e012489ef 573 #elif defined(RASPBERRY_PI)
davidr99 0:ab4e012489ef 574 #define RH_PLATFORM RH_PLATFORM_RASPI
davidr99 0:ab4e012489ef 575 #elif defined(__unix__) // Linux
davidr99 0:ab4e012489ef 576 #define RH_PLATFORM RH_PLATFORM_UNIX
davidr99 0:ab4e012489ef 577 #elif defined(__APPLE__) // OSX
davidr99 0:ab4e012489ef 578 #define RH_PLATFORM RH_PLATFORM_UNIX
davidr99 0:ab4e012489ef 579 #elif defined(TARGET_STM32F407) // Mbed STM32F4
davidr99 0:ab4e012489ef 580 #define RH_PLATFORM RH_PLATFORM_MBED
davidr99 0:ab4e012489ef 581 #else
davidr99 0:ab4e012489ef 582 #error Platform not defined!
davidr99 0:ab4e012489ef 583 #endif
davidr99 0:ab4e012489ef 584 #endif
davidr99 0:ab4e012489ef 585
davidr99 0:ab4e012489ef 586 #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtinyX4__) || defined(__AVR_ATtinyX5__) || defined(__AVR_ATtiny2313__) || defined(__AVR_ATtiny4313__) || defined(__AVR_ATtinyX313__)
davidr99 0:ab4e012489ef 587 #define RH_PLATFORM_ATTINY
davidr99 0:ab4e012489ef 588 #endif
davidr99 0:ab4e012489ef 589
davidr99 0:ab4e012489ef 590 ////////////////////////////////////////////////////
davidr99 0:ab4e012489ef 591 // Platform specific headers:
davidr99 0:ab4e012489ef 592 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
davidr99 0:ab4e012489ef 593 #if (ARDUINO >= 100)
davidr99 0:ab4e012489ef 594 #include <Arduino.h>
davidr99 0:ab4e012489ef 595 #else
davidr99 0:ab4e012489ef 596 #include <wiring.h>
davidr99 0:ab4e012489ef 597 #endif
davidr99 0:ab4e012489ef 598 #ifdef RH_PLATFORM_ATTINY
davidr99 0:ab4e012489ef 599 #warning Arduino TinyCore does not support hardware SPI. Use software SPI instead.
davidr99 0:ab4e012489ef 600 #else
davidr99 0:ab4e012489ef 601 #include <SPI.h>
davidr99 0:ab4e012489ef 602 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 603 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 604 #endif
davidr99 0:ab4e012489ef 605
davidr99 0:ab4e012489ef 606 #elif (RH_PLATFORM == RH_PLATFORM_MSP430) // LaunchPad specific
davidr99 0:ab4e012489ef 607 #include "legacymsp430.h"
davidr99 0:ab4e012489ef 608 #include "Energia.h"
davidr99 0:ab4e012489ef 609 #include <SPI.h>
davidr99 0:ab4e012489ef 610 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 611 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 612
davidr99 0:ab4e012489ef 613 #elif (RH_PLATFORM == RH_PLATFORM_UNO32)
davidr99 0:ab4e012489ef 614 #include <WProgram.h>
davidr99 0:ab4e012489ef 615 #include <string.h>
davidr99 0:ab4e012489ef 616 #include <SPI.h>
davidr99 0:ab4e012489ef 617 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 618 #define memcpy_P memcpy
davidr99 0:ab4e012489ef 619 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 620
davidr99 0:ab4e012489ef 621 #elif (RH_PLATFORM == RH_PLATFORM_STM32) // Maple, Flymaple etc
davidr99 0:ab4e012489ef 622 #include <wirish.h>
davidr99 0:ab4e012489ef 623 #include <stdint.h>
davidr99 0:ab4e012489ef 624 #include <string.h>
davidr99 0:ab4e012489ef 625 #include <HardwareSPI.h>
davidr99 0:ab4e012489ef 626 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 627 // Defines which timer to use on Maple
davidr99 0:ab4e012489ef 628 #define MAPLE_TIMER 1
davidr99 0:ab4e012489ef 629 #define PROGMEM
davidr99 0:ab4e012489ef 630 #define memcpy_P memcpy
davidr99 0:ab4e012489ef 631 #define Serial SerialUSB
davidr99 0:ab4e012489ef 632 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 633
davidr99 0:ab4e012489ef 634 #elif (RH_PLATFORM == RH_PLATFORM_STM32STD) // STM32 with STM32F4xx_StdPeriph_Driver
davidr99 0:ab4e012489ef 635 #include <stm32f4xx.h>
davidr99 0:ab4e012489ef 636 #include <wirish.h>
davidr99 0:ab4e012489ef 637 #include <stdint.h>
davidr99 0:ab4e012489ef 638 #include <string.h>
davidr99 0:ab4e012489ef 639 #include <math.h>
davidr99 0:ab4e012489ef 640 #include <HardwareSPI.h>
davidr99 0:ab4e012489ef 641 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 642 #define Serial SerialUSB
davidr99 0:ab4e012489ef 643 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 644
davidr99 0:ab4e012489ef 645 #elif (RH_PLATFORM == RH_PLATFORM_GENERIC_AVR8)
davidr99 0:ab4e012489ef 646 #include <avr/io.h>
davidr99 0:ab4e012489ef 647 #include <avr/interrupt.h>
davidr99 0:ab4e012489ef 648 #include <util/delay.h>
davidr99 0:ab4e012489ef 649 #include <string.h>
davidr99 0:ab4e012489ef 650 #include <stdbool.h>
davidr99 0:ab4e012489ef 651 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 652 #include <SPI.h>
davidr99 0:ab4e012489ef 653
davidr99 0:ab4e012489ef 654 // For Steve Childress port to ARM M4 w/CMSIS with STM's Hardware Abstraction lib.
davidr99 0:ab4e012489ef 655 // See ArduinoWorkarounds.h (not supplied)
davidr99 0:ab4e012489ef 656 #elif (RH_PLATFORM == RH_PLATFORM_STM32F4_HAL)
davidr99 0:ab4e012489ef 657 #include <ArduinoWorkarounds.h>
davidr99 0:ab4e012489ef 658 #include <stm32f4xx.h> // Also using ST's CubeMX to generate I/O and CPU setup source code for IAR/EWARM, not GCC ARM.
davidr99 0:ab4e012489ef 659 #include <stdint.h>
davidr99 0:ab4e012489ef 660 #include <string.h>
davidr99 0:ab4e012489ef 661 #include <math.h>
davidr99 0:ab4e012489ef 662 #define RH_HAVE_HARDWARE_SPI // using HAL (Hardware Abstraction Libraries from ST along with CMSIS, not arduino libs or pins concept.
davidr99 0:ab4e012489ef 663
davidr99 0:ab4e012489ef 664 #elif (RH_PLATFORM == RH_PLATFORM_RASPI)
davidr99 0:ab4e012489ef 665 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 666 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 667 #define PROGMEM
davidr99 0:ab4e012489ef 668 #include <RHutil/RasPi.h>
davidr99 0:ab4e012489ef 669 #include <string.h>
davidr99 0:ab4e012489ef 670 //Define SS for CS0 or pin 24
davidr99 0:ab4e012489ef 671 #define SS 8
davidr99 0:ab4e012489ef 672
davidr99 0:ab4e012489ef 673 #elif (RH_PLATFORM == RH_PLATFORM_NRF51)
davidr99 0:ab4e012489ef 674 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 675 #define PROGMEM
davidr99 0:ab4e012489ef 676 #include <Arduino.h>
davidr99 0:ab4e012489ef 677
davidr99 0:ab4e012489ef 678 #elif (RH_PLATFORM == RH_PLATFORM_UNIX)
davidr99 0:ab4e012489ef 679 // Simulate the sketch on Linux and OSX
davidr99 0:ab4e012489ef 680 #include <RHutil/simulator.h>
davidr99 0:ab4e012489ef 681 #define RH_HAVE_SERIAL
davidr99 0:ab4e012489ef 682
davidr99 0:ab4e012489ef 683 #elif (RH_PLATFORM == RH_PLATFORM_MBED)
davidr99 0:ab4e012489ef 684 #include <mbed.h>
davidr99 0:ab4e012489ef 685 #define RH_HAVE_HARDWARE_SPI
davidr99 0:ab4e012489ef 686
davidr99 0:ab4e012489ef 687 extern Timer _millisTimer;
davidr99 0:ab4e012489ef 688
davidr99 0:ab4e012489ef 689 #define PROGMEM
davidr99 0:ab4e012489ef 690
davidr99 0:ab4e012489ef 691 #define HIGH 1
davidr99 0:ab4e012489ef 692 #define LOW 0
davidr99 0:ab4e012489ef 693
davidr99 0:ab4e012489ef 694 #define millis() _millisTimer.read_ms()
davidr99 0:ab4e012489ef 695 #define delay(ms) wait_ms(ms)
davidr99 0:ab4e012489ef 696 #define digitalWrite(pin, val) pin = val
davidr99 0:ab4e012489ef 697 #define digitalRead(pin) pin
davidr99 0:ab4e012489ef 698 #define memcpy_P memcpy
davidr99 0:ab4e012489ef 699
davidr99 0:ab4e012489ef 700 #else
davidr99 0:ab4e012489ef 701 #error Platform unknown!
davidr99 0:ab4e012489ef 702 #endif
davidr99 0:ab4e012489ef 703
davidr99 0:ab4e012489ef 704
davidr99 0:ab4e012489ef 705 #if (RH_PLATFORM == RH_PLATFORM_MBED)
davidr99 0:ab4e012489ef 706 #define PINS PinName
davidr99 0:ab4e012489ef 707 #else
davidr99 0:ab4e012489ef 708 #define PINS uint8_t
davidr99 0:ab4e012489ef 709 #endif
davidr99 0:ab4e012489ef 710
davidr99 0:ab4e012489ef 711 ////////////////////////////////////////////////////
davidr99 0:ab4e012489ef 712 // This is an attempt to make a portable atomic block
davidr99 0:ab4e012489ef 713 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO)
davidr99 0:ab4e012489ef 714 #if defined(__arm__)
davidr99 0:ab4e012489ef 715 #include <RHutil/atomic.h>
davidr99 0:ab4e012489ef 716 #else
davidr99 0:ab4e012489ef 717 #include <util/atomic.h>
davidr99 0:ab4e012489ef 718 #endif
davidr99 0:ab4e012489ef 719 #define ATOMIC_BLOCK_START ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
davidr99 0:ab4e012489ef 720 #define ATOMIC_BLOCK_END }
davidr99 0:ab4e012489ef 721 #elif (RH_PLATFORM == RH_PLATFORM_UNO32)
davidr99 0:ab4e012489ef 722 #include <peripheral/int.h>
davidr99 0:ab4e012489ef 723 #define ATOMIC_BLOCK_START unsigned int __status = INTDisableInterrupts(); {
davidr99 0:ab4e012489ef 724 #define ATOMIC_BLOCK_END } INTRestoreInterrupts(__status);
davidr99 0:ab4e012489ef 725 #else
davidr99 0:ab4e012489ef 726 // TO BE DONE:
davidr99 0:ab4e012489ef 727 #define ATOMIC_BLOCK_START
davidr99 0:ab4e012489ef 728 #define ATOMIC_BLOCK_END
davidr99 0:ab4e012489ef 729 #endif
davidr99 0:ab4e012489ef 730
davidr99 0:ab4e012489ef 731 ////////////////////////////////////////////////////
davidr99 0:ab4e012489ef 732 // Try to be compatible with systems that support yield() and multitasking
davidr99 0:ab4e012489ef 733 // instead of spin-loops
davidr99 0:ab4e012489ef 734 // Recent Arduino IDE or Teensy 3 has yield()
davidr99 0:ab4e012489ef 735 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO && ARDUINO >= 155 && !defined(RH_PLATFORM_ATTINY)) || (TEENSYDUINO && defined(__MK20DX128__))
davidr99 0:ab4e012489ef 736 #define YIELD yield();
davidr99 0:ab4e012489ef 737 #else
davidr99 0:ab4e012489ef 738 #define YIELD
davidr99 0:ab4e012489ef 739 #endif
davidr99 0:ab4e012489ef 740
davidr99 0:ab4e012489ef 741 ////////////////////////////////////////////////////
davidr99 0:ab4e012489ef 742 // digitalPinToInterrupt is not available prior to Arduino 1.5.6 and 1.0.6
davidr99 0:ab4e012489ef 743 // See http://arduino.cc/en/Reference/attachInterrupt
davidr99 0:ab4e012489ef 744 #ifndef NOT_AN_INTERRUPT
davidr99 0:ab4e012489ef 745 #define NOT_AN_INTERRUPT -1
davidr99 0:ab4e012489ef 746 #endif
davidr99 0:ab4e012489ef 747 #ifndef digitalPinToInterrupt
davidr99 0:ab4e012489ef 748 #if (RH_PLATFORM == RH_PLATFORM_ARDUINO) && !defined(__arm__)
davidr99 0:ab4e012489ef 749
davidr99 0:ab4e012489ef 750 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
davidr99 0:ab4e012489ef 751 // Arduino Mega, Mega ADK, Mega Pro
davidr99 0:ab4e012489ef 752 // 2->0, 3->1, 21->2, 20->3, 19->4, 18->5
davidr99 0:ab4e012489ef 753 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT)))
davidr99 0:ab4e012489ef 754
davidr99 0:ab4e012489ef 755 #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
davidr99 0:ab4e012489ef 756 // Arduino 1284 and 1284P - See Manicbug and Optiboot
davidr99 0:ab4e012489ef 757 // 10->0, 11->1, 2->2
davidr99 0:ab4e012489ef 758 #define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))
davidr99 0:ab4e012489ef 759
davidr99 0:ab4e012489ef 760 #elif defined(__AVR_ATmega32U4__)
davidr99 0:ab4e012489ef 761 // Leonardo, Yun, Micro, Pro Micro, Flora, Esplora
davidr99 0:ab4e012489ef 762 // 3->0, 2->1, 0->2, 1->3, 7->4
davidr99 0:ab4e012489ef 763 #define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
davidr99 0:ab4e012489ef 764
davidr99 0:ab4e012489ef 765 #else
davidr99 0:ab4e012489ef 766 // All other arduino except Due:
davidr99 0:ab4e012489ef 767 // Serial Arduino, Extreme, NG, BT, Uno, Diecimila, Duemilanove, Nano, Menta, Pro, Mini 04, Fio, LilyPad, Ethernet etc
davidr99 0:ab4e012489ef 768 // 2->0, 3->1
davidr99 0:ab4e012489ef 769 #define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
davidr99 0:ab4e012489ef 770
davidr99 0:ab4e012489ef 771 #endif
davidr99 0:ab4e012489ef 772
davidr99 0:ab4e012489ef 773 #elif (RH_PLATFORM == RH_PLATFORM_UNO32)
davidr99 0:ab4e012489ef 774 #define digitalPinToInterrupt(p) ((p) == 38 ? 0 : ((p) == 2 ? 1 : ((p) == 7 ? 2 : ((p) == 8 ? 3 : ((p) == 735 ? 4 : NOT_AN_INTERRUPT)))))
davidr99 0:ab4e012489ef 775
davidr99 0:ab4e012489ef 776 #else
davidr99 0:ab4e012489ef 777 // Everything else (including Due and Teensy) interrupt number the same as the interrupt pin number
davidr99 0:ab4e012489ef 778 #define digitalPinToInterrupt(p) (p)
davidr99 0:ab4e012489ef 779 #endif
davidr99 0:ab4e012489ef 780 #endif
davidr99 0:ab4e012489ef 781
davidr99 0:ab4e012489ef 782 // Slave select pin, some platforms such as ATTiny do not define it.
davidr99 0:ab4e012489ef 783 #ifndef SS
davidr99 0:ab4e012489ef 784 #define SS 10
davidr99 0:ab4e012489ef 785 #endif
davidr99 0:ab4e012489ef 786
davidr99 0:ab4e012489ef 787 // These defs cause trouble on some versions of Arduino
davidr99 0:ab4e012489ef 788 #undef abs
davidr99 0:ab4e012489ef 789 #undef round
davidr99 0:ab4e012489ef 790 #undef double
davidr99 0:ab4e012489ef 791
davidr99 0:ab4e012489ef 792 // This is the address that indicates a broadcast
davidr99 0:ab4e012489ef 793 #define RH_BROADCAST_ADDRESS 0xff
davidr99 0:ab4e012489ef 794
davidr99 0:ab4e012489ef 795 #endif