Library for HopeRF RFM22 transceiver module ported to mbed. Original Software from Mike McCauley (mikem@open.com.au) . See http://www.open.com.au/mikem/arduino/RF22/
Fork of RF22 by
RF22.h@9:46fb41f4259d, 2013-08-29 (annotated)
- Committer:
- floha
- Date:
- Thu Aug 29 21:57:14 2013 +0000
- Revision:
- 9:46fb41f4259d
- Parent:
- 7:b86825b9d74b
changed the LED default numbers in the RF22 constructor as the former values interfered with pins used on an KL25Z board. The library didn't work with those.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charly | 0:79c6d0071c4c | 1 | // RF22.h |
charly | 0:79c6d0071c4c | 2 | // Author: Mike McCauley (mikem@open.com.au) |
charly | 0:79c6d0071c4c | 3 | // Copyright (C) 2011 Mike McCauley |
charly | 5:0386600f3408 | 4 | // $Id: RF22.h,v 1.23 2013/02/06 21:33:56 mikem Exp mikem $ |
charly | 5:0386600f3408 | 5 | // |
charly | 0:79c6d0071c4c | 6 | // ported to mbed by Karl Zweimueller |
charly | 0:79c6d0071c4c | 7 | /// \mainpage RF22 library for Arduino |
charly | 0:79c6d0071c4c | 8 | /// |
charly | 0:79c6d0071c4c | 9 | /// This is the Arduino RF22 library. |
charly | 0:79c6d0071c4c | 10 | /// It provides an object-oriented interface for sending and receiving data messages with Hope-RF |
charly | 5:0386600f3408 | 11 | /// RF22B based radio modules, and compatible chips and modules, |
charly | 5:0386600f3408 | 12 | /// including the RFM22B transceiver module such as |
charly | 5:0386600f3408 | 13 | /// this bare module: http://www.sparkfun.com/products/10153 |
charly | 5:0386600f3408 | 14 | /// and this shield: https://www.sparkfun.com/products/11018 |
charly | 0:79c6d0071c4c | 15 | /// |
charly | 0:79c6d0071c4c | 16 | /// RF22 also supports some of the features of ZigBee and XBee, |
charly | 0:79c6d0071c4c | 17 | /// (such as mesh routing and automatic route discovery), |
charly | 0:79c6d0071c4c | 18 | /// but with a much less complicated system and less expensive radios. |
charly | 0:79c6d0071c4c | 19 | /// |
charly | 0:79c6d0071c4c | 20 | /// The Hope-RF (http://www.hoperf.com) RFM22B (http://www.hoperf.com/rf_fsk/fsk/RFM22B.htm) |
charly | 0:79c6d0071c4c | 21 | /// is a low-cost ISM transceiver module. It supports FSK, GFSK, OOK over a wide |
charly | 0:79c6d0071c4c | 22 | /// range of frequencies and programmable data rates. |
charly | 0:79c6d0071c4c | 23 | /// |
charly | 0:79c6d0071c4c | 24 | /// This library provides functions for sending and receiving messages of up to 255 octets on any |
charly | 0:79c6d0071c4c | 25 | /// frequency supported by the RF22B, in a range of predefined data rates and frequency deviations. |
charly | 0:79c6d0071c4c | 26 | /// Frequency can be set with 312Hz precision to any frequency from 240.0MHz to 960.0MHz. |
charly | 0:79c6d0071c4c | 27 | /// |
charly | 0:79c6d0071c4c | 28 | /// Up to 2 RF22B modules can be connected to an Arduino, permitting the construction of translators |
charly | 0:79c6d0071c4c | 29 | /// and frequency changers, etc. |
charly | 0:79c6d0071c4c | 30 | /// |
charly | 0:79c6d0071c4c | 31 | /// This library provides classes for |
charly | 0:79c6d0071c4c | 32 | /// - RF22: unaddressed, unreliable messages |
charly | 0:79c6d0071c4c | 33 | /// - RF22Datagram: addressed, unreliable messages |
charly | 0:79c6d0071c4c | 34 | /// - RF22ReliableDatagram: addressed, reliable, retransmitted, acknowledged messages. |
charly | 0:79c6d0071c4c | 35 | /// - RF22Router: multi hop delivery from source node to destination node via 0 or more intermediate nodes |
charly | 0:79c6d0071c4c | 36 | /// - RF22Mesh: multi hop delivery with automatic route discovery and rediscovery. |
charly | 0:79c6d0071c4c | 37 | /// |
charly | 0:79c6d0071c4c | 38 | /// The following modulation types are suppported with a range of modem configurations for |
charly | 0:79c6d0071c4c | 39 | /// common data rates and frequency deviations: |
charly | 0:79c6d0071c4c | 40 | /// - GFSK Gaussian Frequency Shift Keying |
charly | 0:79c6d0071c4c | 41 | /// - FSK Frequency Shift Keying |
charly | 0:79c6d0071c4c | 42 | /// - OOK On-Off Keying |
charly | 0:79c6d0071c4c | 43 | /// |
charly | 0:79c6d0071c4c | 44 | /// Support for other RF22B features such as on-chip temperature measurement, analog-digital |
charly | 0:79c6d0071c4c | 45 | /// converter, transmitter power control etc is also provided. |
charly | 0:79c6d0071c4c | 46 | /// |
charly | 0:79c6d0071c4c | 47 | /// The latest version of this documentation can be downloaded from |
charly | 0:79c6d0071c4c | 48 | /// http://www.open.com.au/mikem/arduino/RF22 |
charly | 0:79c6d0071c4c | 49 | /// |
charly | 0:79c6d0071c4c | 50 | /// Example Arduino programs are included to show the main modes of use. |
charly | 0:79c6d0071c4c | 51 | /// |
charly | 0:79c6d0071c4c | 52 | /// The version of the package that this documentation refers to can be downloaded |
charly | 5:0386600f3408 | 53 | /// from http://www.open.com.au/mikem/arduino/RF22/RF22-1.25.zip |
charly | 0:79c6d0071c4c | 54 | /// You can find the latest version at http://www.open.com.au/mikem/arduino/RF22 |
charly | 0:79c6d0071c4c | 55 | /// |
charly | 5:0386600f3408 | 56 | /// You can also find online help and disussion at http://groups.google.com/group/rf22-arduino |
charly | 5:0386600f3408 | 57 | /// Please use that group for all questions and discussions on this topic. |
charly | 5:0386600f3408 | 58 | /// Do not contact the author directly, unless it is to discuss commercial licensing. |
charly | 5:0386600f3408 | 59 | /// |
charly | 0:79c6d0071c4c | 60 | /// Tested on Arduino Diecimila and Mega with arduino-0021 |
charly | 0:79c6d0071c4c | 61 | /// on OpenSuSE 11.1 and avr-libc-1.6.1-1.15, |
charly | 0:79c6d0071c4c | 62 | /// cross-avr-binutils-2.19-9.1, cross-avr-gcc-4.1.3_20080612-26.5. |
charly | 0:79c6d0071c4c | 63 | /// With HopeRF RFM22 modules that appear to have RF22B chips on board: |
charly | 0:79c6d0071c4c | 64 | /// - Device Type Code = 0x08 (RX/TRX) |
charly | 0:79c6d0071c4c | 65 | /// - Version Code = 0x06 |
charly | 0:79c6d0071c4c | 66 | /// It is known not to work on Diecimila. Dont bother trying. |
charly | 0:79c6d0071c4c | 67 | /// |
charly | 0:79c6d0071c4c | 68 | /// \par Packet Format |
charly | 0:79c6d0071c4c | 69 | /// |
charly | 0:79c6d0071c4c | 70 | /// All messages sent and received by this RF22 library must conform to this packet format: |
charly | 0:79c6d0071c4c | 71 | /// |
charly | 0:79c6d0071c4c | 72 | /// - 8 nibbles (4 octets) PREAMBLE |
charly | 0:79c6d0071c4c | 73 | /// - 2 octets SYNC 0x2d, 0xd4 |
charly | 0:79c6d0071c4c | 74 | /// - 4 octets HEADER: (TO, FROM, ID, FLAGS) |
charly | 0:79c6d0071c4c | 75 | /// - 1 octet LENGTH (0 to 255), number of octets in DATA |
charly | 0:79c6d0071c4c | 76 | /// - 0 to 255 octets DATA |
charly | 0:79c6d0071c4c | 77 | /// - 2 octets CRC computed with CRC16(IBM), computed on HEADER, LENGTH and DATA |
charly | 0:79c6d0071c4c | 78 | /// |
charly | 0:79c6d0071c4c | 79 | /// For technical reasons, the message format is not compatible with the |
charly | 0:79c6d0071c4c | 80 | /// 'HopeRF Radio Transceiver Message Library for Arduino' http://www.open.com.au/mikem/arduino/HopeRF from the same author. Nor is it compatible with |
charly | 0:79c6d0071c4c | 81 | /// 'Virtual Wire' http://www.open.com.au/mikem/arduino/VirtualWire.pdf also from the same author. |
charly | 0:79c6d0071c4c | 82 | /// |
charly | 0:79c6d0071c4c | 83 | /// \par Connecting RFM-22 to Arduino |
charly | 5:0386600f3408 | 84 | /// |
charly | 5:0386600f3408 | 85 | /// If you have the Sparkfun RFM22 Shield (https://www.sparkfun.com/products/11018) |
charly | 5:0386600f3408 | 86 | /// the connections described below are done for you on the shield, no changes required, |
charly | 5:0386600f3408 | 87 | /// just add headers and plug it in to an Arduino (but not and Arduino Mega, see below) |
charly | 5:0386600f3408 | 88 | /// |
charly | 0:79c6d0071c4c | 89 | /// The physical connection between the RF22B and the Arduino require 3.3V, the 3 x SPI pins (SCK, SDI, SDO), |
charly | 0:79c6d0071c4c | 90 | /// a Slave Select pin and an interrupt pin. |
charly | 0:79c6d0071c4c | 91 | /// Note also that on the RFF22B, it is required to control the TX_ANT and X_ANT pins of the RFM22 in order to enable the |
charly | 0:79c6d0071c4c | 92 | /// antenna connection. The RF22 library is configured so that GPIO0 and GPIO1 outputs can control TX_ANT and RX_ANT input pins |
charly | 0:79c6d0071c4c | 93 | /// automatically. You must connect GPIO0 to TX_ANT and GPIO1 to RX_ANT for this automatic antenna switching to occur. |
charly | 0:79c6d0071c4c | 94 | /// |
charly | 0:79c6d0071c4c | 95 | /// Connect the RFM-22 to most Arduino's like this (Caution, Arduino Mega has different pins for SPI, |
charly | 0:79c6d0071c4c | 96 | /// see below): |
charly | 0:79c6d0071c4c | 97 | /// \code |
charly | 0:79c6d0071c4c | 98 | /// Arduino RFM-22B |
charly | 0:79c6d0071c4c | 99 | /// GND----------GND-\ (ground in) |
charly | 0:79c6d0071c4c | 100 | /// SDN-/ (shutdown in) |
charly | 0:79c6d0071c4c | 101 | /// 3V3----------VCC (3.3V in) |
charly | 0:79c6d0071c4c | 102 | /// interrupt 0 pin D2-----------NIRQ (interrupt request out) |
charly | 0:79c6d0071c4c | 103 | /// SS pin D10----------NSEL (chip select in) |
charly | 0:79c6d0071c4c | 104 | /// SCK pin D13----------SCK (SPI clock in) |
charly | 0:79c6d0071c4c | 105 | /// MOSI pin D11----------SDI (SPI Data in) |
charly | 0:79c6d0071c4c | 106 | /// MISO pin D12----------SDO (SPI data out) |
charly | 0:79c6d0071c4c | 107 | /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT |
charly | 0:79c6d0071c4c | 108 | /// \--TX_ANT (TX antenna control in) |
charly | 0:79c6d0071c4c | 109 | /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT |
charly | 0:79c6d0071c4c | 110 | /// \--RX_ANT (RX antenna control in) |
charly | 0:79c6d0071c4c | 111 | /// \endcode |
charly | 0:79c6d0071c4c | 112 | /// For an Arduino Mega: |
charly | 0:79c6d0071c4c | 113 | /// \code |
charly | 0:79c6d0071c4c | 114 | /// Mega RFM-22B |
charly | 0:79c6d0071c4c | 115 | /// GND----------GND-\ (ground in) |
charly | 0:79c6d0071c4c | 116 | /// SDN-/ (shutdown in) |
charly | 0:79c6d0071c4c | 117 | /// 3V3----------VCC (3.3V in) |
charly | 0:79c6d0071c4c | 118 | /// interrupt 0 pin D2-----------NIRQ (interrupt request out) |
charly | 5:0386600f3408 | 119 | /// SS pin D53----------NSEL (chip select in) |
charly | 0:79c6d0071c4c | 120 | /// SCK pin D52----------SCK (SPI clock in) |
charly | 0:79c6d0071c4c | 121 | /// MOSI pin D51----------SDI (SPI Data in) |
charly | 0:79c6d0071c4c | 122 | /// MISO pin D50----------SDO (SPI data out) |
charly | 0:79c6d0071c4c | 123 | /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT |
charly | 0:79c6d0071c4c | 124 | /// \--TX_ANT (TX antenna control in) |
charly | 0:79c6d0071c4c | 125 | /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT |
charly | 0:79c6d0071c4c | 126 | /// \--RX_ANT (RX antenna control in) |
charly | 0:79c6d0071c4c | 127 | /// \endcode |
charly | 0:79c6d0071c4c | 128 | /// and you can then use the default constructor RF22(). |
charly | 0:79c6d0071c4c | 129 | /// You can override the default settings for the SS pin and the interrupt |
charly | 5:0386600f3408 | 130 | /// in the RF22 constructor if you wish to connect the slave select SS to other than the normal one for your |
charly | 5:0386600f3408 | 131 | /// Arduino (D10 for Diecimila, Uno etc and D53 for Mega) |
charly | 0:79c6d0071c4c | 132 | /// or the interrupt request to other than pin D2. |
charly | 5:0386600f3408 | 133 | /// |
charly | 0:79c6d0071c4c | 134 | /// It is possible to have 2 radios conected to one arduino, provided each radio has its own |
charly | 0:79c6d0071c4c | 135 | /// SS and interrupt line (SCK, SDI and SDO are common to both radios) |
charly | 0:79c6d0071c4c | 136 | /// |
charly | 5:0386600f3408 | 137 | /// Caution: on some Arduinos such as the Mega 2560, if you set the slave select pin to be other than the usual SS |
charly | 5:0386600f3408 | 138 | /// pin (D53 on Mega 2560), you may need to set the usual SS pin to be an output to force the Arduino into SPI |
charly | 5:0386600f3408 | 139 | /// master mode. |
charly | 0:79c6d0071c4c | 140 | /// |
charly | 5:0386600f3408 | 141 | /// Caution: Power supply requirements of the RF22 module may be relevant in some circumstances: |
charly | 5:0386600f3408 | 142 | /// RF22 modules are capable of pulling 80mA+ at full power, where Arduino's 3.3V line can |
charly | 5:0386600f3408 | 143 | /// give 50mA. You may need to make provision for alternate power supply for |
charly | 5:0386600f3408 | 144 | /// the RF22, especially if you wish to use full transmit power, and/or you have |
charly | 5:0386600f3408 | 145 | /// other shields demanding power. Inadequate power for the RF22 is reported to cause symptoms such as: |
charly | 5:0386600f3408 | 146 | /// - reset's/bootups terminate with "init failed" messages |
charly | 5:0386600f3408 | 147 | /// -random termination of communication after 5-30 packets sent/received |
charly | 5:0386600f3408 | 148 | /// -"fake ok" state, where initialization passes fluently, but communication doesn't happen |
charly | 5:0386600f3408 | 149 | /// -shields hang Arduino boards, especially during the flashing |
charly | 5:0386600f3408 | 150 | /// |
charly | 5:0386600f3408 | 151 | /// |
charly | 5:0386600f3408 | 152 | /// \par Interrupts |
charly | 5:0386600f3408 | 153 | /// |
charly | 5:0386600f3408 | 154 | /// The RF22 library uses interrupts to react to events in the RF22 module, |
charly | 5:0386600f3408 | 155 | /// such as the reception of a new packet, or the completion of transmission of a packet. |
charly | 5:0386600f3408 | 156 | /// The RF22 library interrupt service routine reads status from and writes data |
charly | 5:0386600f3408 | 157 | /// to the the RF22 module via the SPI interface. It is very important therefore, |
charly | 5:0386600f3408 | 158 | /// that if you are using the RF22 library with another SPI based deviced, that you |
charly | 5:0386600f3408 | 159 | /// disable interrupts while you transfer data to and from that other device. |
charly | 5:0386600f3408 | 160 | /// Use cli() to disable interrupts and sei() to reenable them. |
charly | 0:79c6d0071c4c | 161 | /// |
charly | 0:79c6d0071c4c | 162 | /// \par Memory |
charly | 0:79c6d0071c4c | 163 | /// |
charly | 0:79c6d0071c4c | 164 | /// The RF22 library requires non-trivial amounts of memory. The sample programs above all compile to |
charly | 0:79c6d0071c4c | 165 | /// about 9 to 14kbytes each, which will fit in the flash proram memory of most Arduinos. However, |
charly | 0:79c6d0071c4c | 166 | /// the RAM requirements are more critical. Most sample programs above will run on Duemilanova, |
charly | 0:79c6d0071c4c | 167 | /// but not on Diecimila. Even on Duemilanova, the RAM requirements are very close to the |
charly | 0:79c6d0071c4c | 168 | /// available memory of 2kbytes. Therefore, you should be vary sparing with RAM use in programs that use |
charly | 0:79c6d0071c4c | 169 | /// the RF22 library on Duemilanova. |
charly | 0:79c6d0071c4c | 170 | /// |
charly | 0:79c6d0071c4c | 171 | /// The sample RF22Router and RF22Mesh programs compile to about 14kbytes, |
charly | 0:79c6d0071c4c | 172 | /// and require more RAM than the others. |
charly | 0:79c6d0071c4c | 173 | /// They will not run on Duemilanova or Diecimila, but will run on Arduino Mega. |
charly | 0:79c6d0071c4c | 174 | /// |
charly | 0:79c6d0071c4c | 175 | /// It is often hard to accurately identify when you are hitting RAM limits on Arduino. |
charly | 0:79c6d0071c4c | 176 | /// The symptoms can include: |
charly | 0:79c6d0071c4c | 177 | /// - Mysterious crashes and restarts |
charly | 0:79c6d0071c4c | 178 | /// - Changes in behaviour when seemingly unrelated changes are made (such as adding print() statements) |
charly | 0:79c6d0071c4c | 179 | /// - Hanging |
charly | 0:79c6d0071c4c | 180 | /// - Output from Serial.print() not appearing |
charly | 0:79c6d0071c4c | 181 | /// |
charly | 0:79c6d0071c4c | 182 | /// With an Arduino Mega, with 8 kbytes of SRAM, there is much more RAM headroom for |
charly | 0:79c6d0071c4c | 183 | /// your own elaborate programs. |
charly | 5:0386600f3408 | 184 | /// This library is reported to work with Arduino Pro Mini, but that has not been tested by me. |
charly | 5:0386600f3408 | 185 | /// |
charly | 5:0386600f3408 | 186 | /// The Arduino UNO is now known to work with RF22. |
charly | 5:0386600f3408 | 187 | /// |
charly | 5:0386600f3408 | 188 | /// \par Automatic Frequency Control (AFC) |
charly | 5:0386600f3408 | 189 | /// |
charly | 5:0386600f3408 | 190 | /// The RF22M modules use an inexpensive crystal to control the frequency synthesizer, and therfore you can expect |
charly | 5:0386600f3408 | 191 | /// the transmitter and receiver frequencies to be subject to the usual inaccuracies of such crystals. The RF22 |
charly | 5:0386600f3408 | 192 | /// contains an AFC circuit to compensate for differences in transmitter and receiver frequencies. |
charly | 5:0386600f3408 | 193 | /// It does this by altering the receiver frequency during reception by up to the pull-in frequency range. |
charly | 5:0386600f3408 | 194 | /// This RF22 library enables the AFC and by default sets the pull-in frequency range to |
charly | 5:0386600f3408 | 195 | /// 0.05MHz, which should be sufficient to handle most situations. However, if you observe unexplained packet losses |
charly | 5:0386600f3408 | 196 | /// or failure to operate correctly all the time it may be because your modules have a wider frequency difference, and |
charly | 5:0386600f3408 | 197 | /// you may need to set the afcPullInRange to a differentvalue, using setFrequency(); |
charly | 5:0386600f3408 | 198 | /// |
charly | 5:0386600f3408 | 199 | /// \par Performance |
charly | 5:0386600f3408 | 200 | /// |
charly | 5:0386600f3408 | 201 | /// Some simple speed performance tests have been conducted. |
charly | 5:0386600f3408 | 202 | /// In general packet transmission rate will be limited by the modulation scheme. |
charly | 5:0386600f3408 | 203 | /// Also, if your code does any slow operations like Serial printing it will also limit performance. |
charly | 5:0386600f3408 | 204 | /// We disabled any printing in the tests below. |
charly | 5:0386600f3408 | 205 | /// We tested with RF22::GFSK_Rb125Fd125, which is probably the fastest scheme available. |
charly | 5:0386600f3408 | 206 | /// We tested with a 13 octet message length, over a very short distance of 10cm. |
charly | 5:0386600f3408 | 207 | /// |
charly | 5:0386600f3408 | 208 | /// Transmission (no reply) tests with modulation RF22::GFSK_Rb125Fd125 and a |
charly | 5:0386600f3408 | 209 | /// 13 octet message show about 330 messages per second transmitted. |
charly | 5:0386600f3408 | 210 | /// |
charly | 5:0386600f3408 | 211 | /// Transmit-and-wait-for-a-reply tests with modulation RF22::GFSK_Rb125Fd125 and a |
charly | 5:0386600f3408 | 212 | /// 13 octet message (send and receive) show about 160 round trips per second. |
charly | 0:79c6d0071c4c | 213 | /// |
charly | 0:79c6d0071c4c | 214 | /// \par Installation |
charly | 0:79c6d0071c4c | 215 | /// |
charly | 0:79c6d0071c4c | 216 | /// Install in the usual way: unzip the distribution zip file to the libraries |
charly | 0:79c6d0071c4c | 217 | /// sub-folder of your sketchbook. |
charly | 0:79c6d0071c4c | 218 | /// |
charly | 0:79c6d0071c4c | 219 | /// This software is Copyright (C) 2011 Mike McCauley. Use is subject to license |
charly | 0:79c6d0071c4c | 220 | /// conditions. The main licensing options available are GPL V2 or Commercial: |
charly | 0:79c6d0071c4c | 221 | /// |
charly | 0:79c6d0071c4c | 222 | /// \par Open Source Licensing GPL V2 |
charly | 0:79c6d0071c4c | 223 | /// |
charly | 0:79c6d0071c4c | 224 | /// This is the appropriate option if you want to share the source code of your |
charly | 0:79c6d0071c4c | 225 | /// application with everyone you distribute it to, and you also want to give them |
charly | 0:79c6d0071c4c | 226 | /// the right to share who uses it. If you wish to use this software under Open |
charly | 0:79c6d0071c4c | 227 | /// Source Licensing, you must contribute all your source code to the open source |
charly | 0:79c6d0071c4c | 228 | /// community in accordance with the GPL Version 2 when your application is |
charly | 0:79c6d0071c4c | 229 | /// distributed. See http://www.gnu.org/copyleft/gpl.html |
charly | 0:79c6d0071c4c | 230 | /// |
charly | 0:79c6d0071c4c | 231 | /// \par Commercial Licensing |
charly | 0:79c6d0071c4c | 232 | /// |
charly | 0:79c6d0071c4c | 233 | /// This is the appropriate option if you are creating proprietary applications |
charly | 0:79c6d0071c4c | 234 | /// and you are not prepared to distribute and share the source code of your |
charly | 0:79c6d0071c4c | 235 | /// application. Contact info@open.com.au for details. |
charly | 0:79c6d0071c4c | 236 | /// |
charly | 0:79c6d0071c4c | 237 | /// \par Revision History |
charly | 0:79c6d0071c4c | 238 | /// |
charly | 0:79c6d0071c4c | 239 | /// \version 1.0 Initial release |
charly | 0:79c6d0071c4c | 240 | /// |
charly | 0:79c6d0071c4c | 241 | /// \version 1.1 Added rf22_snoop and rf22_specan examples |
charly | 0:79c6d0071c4c | 242 | /// |
charly | 0:79c6d0071c4c | 243 | /// \version 1.2 Changed default modulation to FSK_Rb2_4Fd36 |
charly | 0:79c6d0071c4c | 244 | /// Some internal reorganisation. |
charly | 0:79c6d0071c4c | 245 | /// Added RF22Router and RF22Mesh classes plus sample programs to support multi-hop and |
charly | 0:79c6d0071c4c | 246 | /// automatic route discovery. |
charly | 0:79c6d0071c4c | 247 | /// \version 1.3 Removed some unnecessary debug messages. Added virtual doArp and isPhysicalAddress |
charly | 0:79c6d0071c4c | 248 | /// functions to RF22Mesh to support other physical address interpretation schemes (IPV4/IPV6?) |
charly | 0:79c6d0071c4c | 249 | /// \version 1.4 RF22Router and RF22Mesh were inadvertently left out of the distro. |
charly | 0:79c6d0071c4c | 250 | /// \version 1.5 Improvements contributed by Peter Mousley: Modem config table is now in flash rather than SRAM, |
charly | 0:79c6d0071c4c | 251 | /// saving 400 bytes of SRAM. Allow a user-defined buffer size. Thanks Peter. |
charly | 0:79c6d0071c4c | 252 | /// \version 1.6 Fixed some minor typos on doc and clarified that this code is for the RF22B. Fixed errors in the |
charly | 0:79c6d0071c4c | 253 | /// definition of the power output constants which were incorrectly set to the values for the RF22. |
charly | 0:79c6d0071c4c | 254 | /// Reported by Fred Slamen. If you were using a previous version of RF22, you probably were not getting the output |
charly | 0:79c6d0071c4c | 255 | /// power you thought. |
charly | 0:79c6d0071c4c | 256 | /// \version 1.7 Added code to initialise GPIO0 and GPIO1 so they can automatically control the TX_ANT and RX_ANT |
charly | 0:79c6d0071c4c | 257 | /// antenna switching inputs. You must connect GPIO0 to TX_ANT and GPIO1 to RX_ANT for this automatic |
charly | 0:79c6d0071c4c | 258 | /// antenna switching to occur. Updated doc to reflect this new connection requirement |
charly | 0:79c6d0071c4c | 259 | /// \version 1.8 Changed the name of RF22_ENLBD in RF22_REG_06_INTERRUPT_ENABLE2 to RF22_ENLBDI because it collided |
charly | 0:79c6d0071c4c | 260 | /// with a define of the same name in RF22_REG_07_OPERATING_MODE. RF22_REG_05_INTERRUPT_ENABLE1 enable mask |
charly | 0:79c6d0071c4c | 261 | /// incorrectly used RF22_IFFERROR instead of RF22_ENFFERR. Reported by Steffan Woltjer. |
charly | 0:79c6d0071c4c | 262 | /// \version 1.9 Fixed typos in RF22_REG_21_CLOCk*. Reported by Steffan Woltjer. |
charly | 0:79c6d0071c4c | 263 | /// \version 1.10 Fixed a problem where a IFFERR during transmission could cause an infinite loop and a hang. |
charly | 0:79c6d0071c4c | 264 | /// Reported by Raymond Gilbert. |
charly | 5:0386600f3408 | 265 | /// \version 1.11 Fixed an innocuous typo in RF22::handleInterrupt. Reported by Zhentao. |
charly | 0:79c6d0071c4c | 266 | /// |
charly | 5:0386600f3408 | 267 | /// \version 1.12 Improvements to RF22::init from Guy Molinari to improve compatibility with some |
charly | 5:0386600f3408 | 268 | /// Arduinos. Now reported to be working with official Mega 2560 and Uno. |
charly | 5:0386600f3408 | 269 | /// Updated so compiles on Arduino 1.0. |
charly | 0:79c6d0071c4c | 270 | /// |
charly | 5:0386600f3408 | 271 | /// \version 1.13 Announce google support group |
charly | 5:0386600f3408 | 272 | /// |
charly | 5:0386600f3408 | 273 | /// \version 1.14 Added definitions for bits and masks in RF22_REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE |
charly | 5:0386600f3408 | 274 | /// and RF22_REG_1E_AFC_TIMING_CONTROL |
charly | 5:0386600f3408 | 275 | /// |
charly | 5:0386600f3408 | 276 | /// \version 1.15 Small alterations to initialisation code so that SS pin is not set to output: may cause |
charly | 5:0386600f3408 | 277 | /// interference with other devices connected to the Arduino. Testing with Uno: OK. |
charly | 5:0386600f3408 | 278 | /// |
charly | 5:0386600f3408 | 279 | /// \version 1.16 Fixed a problem that prevented building with arduino 0021 |
charly | 5:0386600f3408 | 280 | /// |
charly | 5:0386600f3408 | 281 | /// \version 1.17 Added optional AFC pull-in frequency range argument to setFrequency(). |
charly | 5:0386600f3408 | 282 | /// Default AFC pull-in range set to 0.05MHz |
charly | 5:0386600f3408 | 283 | /// |
charly | 5:0386600f3408 | 284 | /// \version 1.18 Changed default value for slave slect pin in constructor to be SS, ie the normal one for |
charly | 5:0386600f3408 | 285 | /// the compiled Arduino (D10 for Diecimila, Uno etc and D53 for Mega). This is because some Arduinos such as Mega 2560 |
charly | 5:0386600f3408 | 286 | /// reportedly use the type of the SS pin to determine whether to run in slave or master mode. Therfore it |
charly | 5:0386600f3408 | 287 | /// is preferred that the slave select pin actually be the normal SS pin. |
charly | 5:0386600f3408 | 288 | /// |
charly | 5:0386600f3408 | 289 | /// \version 1.19 Added new mode() function. |
charly | 5:0386600f3408 | 290 | /// Fixed a potential race condition in RF22Datagram::recvfrom which might cause corrupt from, to, id or flags |
charly | 5:0386600f3408 | 291 | /// under extreme circumstances. Improvements to interrupt hygeine by adding cli()_/sei() around all |
charly | 5:0386600f3408 | 292 | /// RF22 register acceses. Found that 0 length transmit packets confuses the RF22, so they are now forbidden. |
charly | 5:0386600f3408 | 293 | /// Added IPGateway example, which routes UDP messages from an internet connection using an |
charly | 5:0386600f3408 | 294 | /// Ethernet Shield and sends them |
charly | 5:0386600f3408 | 295 | /// to a radio whose ID is based on the UDP port. Replies are sent back to the originating UDP |
charly | 5:0386600f3408 | 296 | /// address and port. |
charly | 5:0386600f3408 | 297 | /// |
charly | 5:0386600f3408 | 298 | /// \version 1.20 _mode is now volatile. |
charly | 5:0386600f3408 | 299 | /// RF22::send() now waits until any previous transmission is complete before sending. |
charly | 5:0386600f3408 | 300 | /// RF22::waitPacketSent() now waits for the RF22 to not be in _mode == RF22_MODE_TX |
charly | 5:0386600f3408 | 301 | /// _txPacketSent member is now redundant and removed. |
charly | 5:0386600f3408 | 302 | /// Improvements to interrupt handling and blocking. Now use ATOMIC_BLOCK(ATOMIC_RESTORESTATE) |
charly | 5:0386600f3408 | 303 | /// to prevent reenabling interrupts too soon. Thanks to Roland Mieslinger for this suggestion. |
charly | 5:0386600f3408 | 304 | /// Added some performance measurements to documentation. |
charly | 5:0386600f3408 | 305 | /// |
charly | 5:0386600f3408 | 306 | /// \version 1.21 Fixed a case where a receiver buffer overflow could occur. Reported by Joe Tuttle. |
charly | 5:0386600f3408 | 307 | /// |
charly | 5:0386600f3408 | 308 | /// \version 1.22 Added documentation after testing with Sparkfun RFM22 Shield DEV-11018. |
charly | 5:0386600f3408 | 309 | /// Fixed incorrect link to register calculator excel file, reported by Joey Morin. |
charly | 5:0386600f3408 | 310 | /// |
charly | 5:0386600f3408 | 311 | /// \version 1.23 Added support for alternative SPI interfaces, with default implementation for the standard |
charly | 5:0386600f3408 | 312 | /// Arduino hardware SPI interface. Contributed by Joanna Rutkowska. |
charly | 5:0386600f3408 | 313 | /// |
charly | 5:0386600f3408 | 314 | /// \version 1.24 Fixed a problem that could cause corrupted receive messages if a transmit interrupted |
charly | 5:0386600f3408 | 315 | /// a partial receive (as was common with eg ReliableDatagram with poor reception. |
charly | 5:0386600f3408 | 316 | /// Also fixed possible receive buffer overrun. |
charly | 5:0386600f3408 | 317 | /// \version 1.25 More rigorous use of const, additional register defines (RF22_CRCHDRS RF22_VARPKLEN) |
charly | 5:0386600f3408 | 318 | /// and two methods (setPreambleLength() |
charly | 5:0386600f3408 | 319 | /// and setSyncWords())made public. Patch provided by |
charly | 5:0386600f3408 | 320 | /// Matthijs Kooijman. |
charly | 0:79c6d0071c4c | 321 | /// \author Mike McCauley (mikem@open.com.au) |
charly | 0:79c6d0071c4c | 322 | |
charly | 0:79c6d0071c4c | 323 | #ifndef RF22_h |
charly | 0:79c6d0071c4c | 324 | #define RF22_h |
charly | 0:79c6d0071c4c | 325 | #include "mbed.h" |
charly | 0:79c6d0071c4c | 326 | |
charly | 0:79c6d0071c4c | 327 | #define boolean bool |
charly | 0:79c6d0071c4c | 328 | |
charly | 0:79c6d0071c4c | 329 | //#include <wiring.h> |
charly | 0:79c6d0071c4c | 330 | // These defs cause trouble on some versions of Arduino |
charly | 0:79c6d0071c4c | 331 | #undef round |
charly | 0:79c6d0071c4c | 332 | #undef double |
charly | 0:79c6d0071c4c | 333 | |
charly | 0:79c6d0071c4c | 334 | // This is the bit in the SPI address that marks it as a write |
charly | 0:79c6d0071c4c | 335 | #define RF22_SPI_WRITE_MASK 0x80 |
charly | 0:79c6d0071c4c | 336 | |
charly | 0:79c6d0071c4c | 337 | // This is the maximum message length that can be supported by this library. Limited by |
charly | 5:0386600f3408 | 338 | // the single message length octet in the header. |
charly | 5:0386600f3408 | 339 | // Yes, 255 is correct even though the FIFO size in the RF22 is only |
charly | 5:0386600f3408 | 340 | // 64 octets. We use interrupts to refill the Tx FIFO during transmission and to empty the |
charly | 5:0386600f3408 | 341 | // Rx FIFO during reception |
charly | 0:79c6d0071c4c | 342 | // Can be pre-defined to a smaller size (to save SRAM) prior to including this header |
charly | 0:79c6d0071c4c | 343 | #ifndef RF22_MAX_MESSAGE_LEN |
charly | 6:468dc5b3942f | 344 | #define RF22_MAX_MESSAGE_LEN 255 |
charly | 6:468dc5b3942f | 345 | //#define RF22_MAX_MESSAGE_LEN 50 |
charly | 0:79c6d0071c4c | 346 | #endif |
charly | 0:79c6d0071c4c | 347 | |
charly | 0:79c6d0071c4c | 348 | // Max number of octets the RF22 Rx and Tx FIFOs can hold |
charly | 0:79c6d0071c4c | 349 | #define RF22_FIFO_SIZE 64 |
charly | 0:79c6d0071c4c | 350 | |
charly | 0:79c6d0071c4c | 351 | // Keep track of the mode the RF22 is in |
charly | 0:79c6d0071c4c | 352 | #define RF22_MODE_IDLE 0 |
charly | 0:79c6d0071c4c | 353 | #define RF22_MODE_RX 1 |
charly | 0:79c6d0071c4c | 354 | #define RF22_MODE_TX 2 |
charly | 0:79c6d0071c4c | 355 | |
charly | 0:79c6d0071c4c | 356 | // These values we set for FIFO thresholds are actually the same as the POR values |
charly | 0:79c6d0071c4c | 357 | #define RF22_TXFFAEM_THRESHOLD 4 |
charly | 0:79c6d0071c4c | 358 | #define RF22_RXFFAFULL_THRESHOLD 55 |
charly | 0:79c6d0071c4c | 359 | |
charly | 0:79c6d0071c4c | 360 | // This is the default node address, |
charly | 0:79c6d0071c4c | 361 | #define RF22_DEFAULT_NODE_ADDRESS 0 |
charly | 0:79c6d0071c4c | 362 | |
charly | 0:79c6d0071c4c | 363 | // This address in the TO addreess signifies a broadcast |
charly | 0:79c6d0071c4c | 364 | #define RF22_BROADCAST_ADDRESS 0xff |
charly | 0:79c6d0071c4c | 365 | |
charly | 0:79c6d0071c4c | 366 | // Number of registers to be passed to setModemConfig() |
charly | 0:79c6d0071c4c | 367 | #define RF22_NUM_MODEM_CONFIG_REGS 18 |
charly | 0:79c6d0071c4c | 368 | |
charly | 0:79c6d0071c4c | 369 | // Register names |
charly | 0:79c6d0071c4c | 370 | #define RF22_REG_00_DEVICE_TYPE 0x00 |
charly | 0:79c6d0071c4c | 371 | #define RF22_REG_01_VERSION_CODE 0x01 |
charly | 0:79c6d0071c4c | 372 | #define RF22_REG_02_DEVICE_STATUS 0x02 |
charly | 0:79c6d0071c4c | 373 | #define RF22_REG_03_INTERRUPT_STATUS1 0x03 |
charly | 0:79c6d0071c4c | 374 | #define RF22_REG_04_INTERRUPT_STATUS2 0x04 |
charly | 0:79c6d0071c4c | 375 | #define RF22_REG_05_INTERRUPT_ENABLE1 0x05 |
charly | 0:79c6d0071c4c | 376 | #define RF22_REG_06_INTERRUPT_ENABLE2 0x06 |
charly | 0:79c6d0071c4c | 377 | #define RF22_REG_07_OPERATING_MODE1 0x07 |
charly | 0:79c6d0071c4c | 378 | #define RF22_REG_08_OPERATING_MODE2 0x08 |
charly | 0:79c6d0071c4c | 379 | #define RF22_REG_09_OSCILLATOR_LOAD_CAPACITANCE 0x09 |
charly | 0:79c6d0071c4c | 380 | #define RF22_REG_0A_UC_OUTPUT_CLOCK 0x0a |
charly | 0:79c6d0071c4c | 381 | #define RF22_REG_0B_GPIO_CONFIGURATION0 0x0b |
charly | 0:79c6d0071c4c | 382 | #define RF22_REG_0C_GPIO_CONFIGURATION1 0x0c |
charly | 0:79c6d0071c4c | 383 | #define RF22_REG_0D_GPIO_CONFIGURATION2 0x0d |
charly | 0:79c6d0071c4c | 384 | #define RF22_REG_0E_IO_PORT_CONFIGURATION 0x0e |
charly | 0:79c6d0071c4c | 385 | #define RF22_REG_0F_ADC_CONFIGURATION 0x0f |
charly | 0:79c6d0071c4c | 386 | #define RF22_REG_10_ADC_SENSOR_AMP_OFFSET 0x10 |
charly | 0:79c6d0071c4c | 387 | #define RF22_REG_11_ADC_VALUE 0x11 |
charly | 0:79c6d0071c4c | 388 | #define RF22_REG_12_TEMPERATURE_SENSOR_CALIBRATION 0x12 |
charly | 0:79c6d0071c4c | 389 | #define RF22_REG_13_TEMPERATURE_VALUE_OFFSET 0x13 |
charly | 0:79c6d0071c4c | 390 | #define RF22_REG_14_WAKEUP_TIMER_PERIOD1 0x14 |
charly | 0:79c6d0071c4c | 391 | #define RF22_REG_15_WAKEUP_TIMER_PERIOD2 0x15 |
charly | 0:79c6d0071c4c | 392 | #define RF22_REG_16_WAKEUP_TIMER_PERIOD3 0x16 |
charly | 0:79c6d0071c4c | 393 | #define RF22_REG_17_WAKEUP_TIMER_VALUE1 0x17 |
charly | 0:79c6d0071c4c | 394 | #define RF22_REG_18_WAKEUP_TIMER_VALUE2 0x18 |
charly | 0:79c6d0071c4c | 395 | #define RF22_REG_19_LDC_MODE_DURATION 0x19 |
charly | 0:79c6d0071c4c | 396 | #define RF22_REG_1A_LOW_BATTERY_DETECTOR_THRESHOLD 0x1a |
charly | 0:79c6d0071c4c | 397 | #define RF22_REG_1B_BATTERY_VOLTAGE_LEVEL 0x1b |
charly | 0:79c6d0071c4c | 398 | #define RF22_REG_1C_IF_FILTER_BANDWIDTH 0x1c |
charly | 0:79c6d0071c4c | 399 | #define RF22_REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE 0x1d |
charly | 0:79c6d0071c4c | 400 | #define RF22_REG_1E_AFC_TIMING_CONTROL 0x1e |
charly | 0:79c6d0071c4c | 401 | #define RF22_REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE 0x1f |
charly | 0:79c6d0071c4c | 402 | #define RF22_REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE 0x20 |
charly | 0:79c6d0071c4c | 403 | #define RF22_REG_21_CLOCK_RECOVERY_OFFSET2 0x21 |
charly | 0:79c6d0071c4c | 404 | #define RF22_REG_22_CLOCK_RECOVERY_OFFSET1 0x22 |
charly | 0:79c6d0071c4c | 405 | #define RF22_REG_23_CLOCK_RECOVERY_OFFSET0 0x23 |
charly | 0:79c6d0071c4c | 406 | #define RF22_REG_24_CLOCK_RECOVERY_TIMING_LOOP_GAIN1 0x24 |
charly | 0:79c6d0071c4c | 407 | #define RF22_REG_25_CLOCK_RECOVERY_TIMING_LOOP_GAIN0 0x25 |
charly | 0:79c6d0071c4c | 408 | #define RF22_REG_26_RSSI 0x26 |
charly | 0:79c6d0071c4c | 409 | #define RF22_REG_27_RSSI_THRESHOLD 0x27 |
charly | 0:79c6d0071c4c | 410 | #define RF22_REG_28_ANTENNA_DIVERSITY1 0x28 |
charly | 0:79c6d0071c4c | 411 | #define RF22_REG_29_ANTENNA_DIVERSITY2 0x29 |
charly | 0:79c6d0071c4c | 412 | #define RF22_REG_2A_AFC_LIMITER 0x2a |
charly | 0:79c6d0071c4c | 413 | #define RF22_REG_2B_AFC_CORRECTION_READ 0x2b |
charly | 0:79c6d0071c4c | 414 | #define RF22_REG_2C_OOK_COUNTER_VALUE_1 0x2c |
charly | 0:79c6d0071c4c | 415 | #define RF22_REG_2D_OOK_COUNTER_VALUE_2 0x2d |
charly | 0:79c6d0071c4c | 416 | #define RF22_REG_2E_SLICER_PEAK_HOLD 0x2e |
charly | 0:79c6d0071c4c | 417 | #define RF22_REG_30_DATA_ACCESS_CONTROL 0x30 |
charly | 0:79c6d0071c4c | 418 | #define RF22_REG_31_EZMAC_STATUS 0x31 |
charly | 0:79c6d0071c4c | 419 | #define RF22_REG_32_HEADER_CONTROL1 0x32 |
charly | 0:79c6d0071c4c | 420 | #define RF22_REG_33_HEADER_CONTROL2 0x33 |
charly | 0:79c6d0071c4c | 421 | #define RF22_REG_34_PREAMBLE_LENGTH 0x34 |
charly | 0:79c6d0071c4c | 422 | #define RF22_REG_35_PREAMBLE_DETECTION_CONTROL1 0x35 |
charly | 0:79c6d0071c4c | 423 | #define RF22_REG_36_SYNC_WORD3 0x36 |
charly | 0:79c6d0071c4c | 424 | #define RF22_REG_37_SYNC_WORD2 0x37 |
charly | 0:79c6d0071c4c | 425 | #define RF22_REG_38_SYNC_WORD1 0x38 |
charly | 0:79c6d0071c4c | 426 | #define RF22_REG_39_SYNC_WORD0 0x39 |
charly | 0:79c6d0071c4c | 427 | #define RF22_REG_3A_TRANSMIT_HEADER3 0x3a |
charly | 0:79c6d0071c4c | 428 | #define RF22_REG_3B_TRANSMIT_HEADER2 0x3b |
charly | 0:79c6d0071c4c | 429 | #define RF22_REG_3C_TRANSMIT_HEADER1 0x3c |
charly | 0:79c6d0071c4c | 430 | #define RF22_REG_3D_TRANSMIT_HEADER0 0x3d |
charly | 0:79c6d0071c4c | 431 | #define RF22_REG_3E_PACKET_LENGTH 0x3e |
charly | 0:79c6d0071c4c | 432 | #define RF22_REG_3F_CHECK_HEADER3 0x3f |
charly | 0:79c6d0071c4c | 433 | #define RF22_REG_40_CHECK_HEADER2 0x40 |
charly | 0:79c6d0071c4c | 434 | #define RF22_REG_41_CHECK_HEADER1 0x41 |
charly | 0:79c6d0071c4c | 435 | #define RF22_REG_42_CHECK_HEADER0 0x42 |
charly | 0:79c6d0071c4c | 436 | #define RF22_REG_43_HEADER_ENABLE3 0x43 |
charly | 0:79c6d0071c4c | 437 | #define RF22_REG_44_HEADER_ENABLE2 0x44 |
charly | 0:79c6d0071c4c | 438 | #define RF22_REG_45_HEADER_ENABLE1 0x45 |
charly | 0:79c6d0071c4c | 439 | #define RF22_REG_46_HEADER_ENABLE0 0x46 |
charly | 0:79c6d0071c4c | 440 | #define RF22_REG_47_RECEIVED_HEADER3 0x47 |
charly | 0:79c6d0071c4c | 441 | #define RF22_REG_48_RECEIVED_HEADER2 0x48 |
charly | 0:79c6d0071c4c | 442 | #define RF22_REG_49_RECEIVED_HEADER1 0x49 |
charly | 0:79c6d0071c4c | 443 | #define RF22_REG_4A_RECEIVED_HEADER0 0x4a |
charly | 0:79c6d0071c4c | 444 | #define RF22_REG_4B_RECEIVED_PACKET_LENGTH 0x4b |
charly | 0:79c6d0071c4c | 445 | #define RF22_REG_50_ANALOG_TEST_BUS_SELECT 0x50 |
charly | 0:79c6d0071c4c | 446 | #define RF22_REG_51_DIGITAL_TEST_BUS_SELECT 0x51 |
charly | 0:79c6d0071c4c | 447 | #define RF22_REG_52_TX_RAMP_CONTROL 0x52 |
charly | 0:79c6d0071c4c | 448 | #define RF22_REG_53_PLL_TUNE_TIME 0x53 |
charly | 0:79c6d0071c4c | 449 | #define RF22_REG_55_CALIBRATION_CONTROL 0x55 |
charly | 0:79c6d0071c4c | 450 | #define RF22_REG_56_MODEM_TEST 0x56 |
charly | 0:79c6d0071c4c | 451 | #define RF22_REG_57_CHARGE_PUMP_TEST 0x57 |
charly | 0:79c6d0071c4c | 452 | #define RF22_REG_58_CHARGE_PUMP_CURRENT_TRIMMING 0x58 |
charly | 0:79c6d0071c4c | 453 | #define RF22_REG_59_DIVIDER_CURRENT_TRIMMING 0x59 |
charly | 0:79c6d0071c4c | 454 | #define RF22_REG_5A_VCO_CURRENT_TRIMMING 0x5a |
charly | 0:79c6d0071c4c | 455 | #define RF22_REG_5B_VCO_CALIBRATION 0x5b |
charly | 0:79c6d0071c4c | 456 | #define RF22_REG_5C_SYNTHESIZER_TEST 0x5c |
charly | 0:79c6d0071c4c | 457 | #define RF22_REG_5D_BLOCK_ENABLE_OVERRIDE1 0x5d |
charly | 0:79c6d0071c4c | 458 | #define RF22_REG_5E_BLOCK_ENABLE_OVERRIDE2 0x5e |
charly | 0:79c6d0071c4c | 459 | #define RF22_REG_5F_BLOCK_ENABLE_OVERRIDE3 0x5f |
charly | 0:79c6d0071c4c | 460 | #define RF22_REG_60_CHANNEL_FILTER_COEFFICIENT_ADDRESS 0x60 |
charly | 0:79c6d0071c4c | 461 | #define RF22_REG_61_CHANNEL_FILTER_COEFFICIENT_VALUE 0x61 |
charly | 0:79c6d0071c4c | 462 | #define RF22_REG_62_CRYSTAL_OSCILLATOR_POR_CONTROL 0x62 |
charly | 0:79c6d0071c4c | 463 | #define RF22_REG_63_RC_OSCILLATOR_COARSE_CALIBRATION 0x63 |
charly | 0:79c6d0071c4c | 464 | #define RF22_REG_64_RC_OSCILLATOR_FINE_CALIBRATION 0x64 |
charly | 0:79c6d0071c4c | 465 | #define RF22_REG_65_LDO_CONTROL_OVERRIDE 0x65 |
charly | 0:79c6d0071c4c | 466 | #define RF22_REG_66_LDO_LEVEL_SETTINGS 0x66 |
charly | 0:79c6d0071c4c | 467 | #define RF22_REG_67_DELTA_SIGMA_ADC_TUNING1 0x67 |
charly | 0:79c6d0071c4c | 468 | #define RF22_REG_68_DELTA_SIGMA_ADC_TUNING2 0x68 |
charly | 0:79c6d0071c4c | 469 | #define RF22_REG_69_AGC_OVERRIDE1 0x69 |
charly | 0:79c6d0071c4c | 470 | #define RF22_REG_6A_AGC_OVERRIDE2 0x6a |
charly | 0:79c6d0071c4c | 471 | #define RF22_REG_6B_GFSK_FIR_FILTER_COEFFICIENT_ADDRESS 0x6b |
charly | 0:79c6d0071c4c | 472 | #define RF22_REG_6C_GFSK_FIR_FILTER_COEFFICIENT_VALUE 0x6c |
charly | 0:79c6d0071c4c | 473 | #define RF22_REG_6D_TX_POWER 0x6d |
charly | 0:79c6d0071c4c | 474 | #define RF22_REG_6E_TX_DATA_RATE1 0x6e |
charly | 0:79c6d0071c4c | 475 | #define RF22_REG_6F_TX_DATA_RATE0 0x6f |
charly | 0:79c6d0071c4c | 476 | #define RF22_REG_70_MODULATION_CONTROL1 0x70 |
charly | 0:79c6d0071c4c | 477 | #define RF22_REG_71_MODULATION_CONTROL2 0x71 |
charly | 0:79c6d0071c4c | 478 | #define RF22_REG_72_FREQUENCY_DEVIATION 0x72 |
charly | 0:79c6d0071c4c | 479 | #define RF22_REG_73_FREQUENCY_OFFSET1 0x73 |
charly | 0:79c6d0071c4c | 480 | #define RF22_REG_74_FREQUENCY_OFFSET2 0x74 |
charly | 0:79c6d0071c4c | 481 | #define RF22_REG_75_FREQUENCY_BAND_SELECT 0x75 |
charly | 0:79c6d0071c4c | 482 | #define RF22_REG_76_NOMINAL_CARRIER_FREQUENCY1 0x76 |
charly | 0:79c6d0071c4c | 483 | #define RF22_REG_77_NOMINAL_CARRIER_FREQUENCY0 0x77 |
charly | 0:79c6d0071c4c | 484 | #define RF22_REG_79_FREQUENCY_HOPPING_CHANNEL_SELECT 0x79 |
charly | 0:79c6d0071c4c | 485 | #define RF22_REG_7A_FREQUENCY_HOPPING_STEP_SIZE 0x7a |
charly | 0:79c6d0071c4c | 486 | #define RF22_REG_7C_TX_FIFO_CONTROL1 0x7c |
charly | 0:79c6d0071c4c | 487 | #define RF22_REG_7D_TX_FIFO_CONTROL2 0x7d |
charly | 0:79c6d0071c4c | 488 | #define RF22_REG_7E_RX_FIFO_CONTROL 0x7e |
charly | 0:79c6d0071c4c | 489 | #define RF22_REG_7F_FIFO_ACCESS 0x7f |
charly | 0:79c6d0071c4c | 490 | |
charly | 0:79c6d0071c4c | 491 | // These register masks etc are named wherever possible |
charly | 0:79c6d0071c4c | 492 | // corresponding to the bit and field names in the RF-22 Manual |
charly | 0:79c6d0071c4c | 493 | // RF22_REG_00_DEVICE_TYPE 0x00 |
charly | 0:79c6d0071c4c | 494 | #define RF22_DEVICE_TYPE_RX_TRX 0x08 |
charly | 0:79c6d0071c4c | 495 | #define RF22_DEVICE_TYPE_TX 0x07 |
charly | 0:79c6d0071c4c | 496 | |
charly | 0:79c6d0071c4c | 497 | // RF22_REG_02_DEVICE_STATUS 0x02 |
charly | 0:79c6d0071c4c | 498 | #define RF22_FFOVL 0x80 |
charly | 0:79c6d0071c4c | 499 | #define RF22_FFUNFL 0x40 |
charly | 0:79c6d0071c4c | 500 | #define RF22_RXFFEM 0x20 |
charly | 0:79c6d0071c4c | 501 | #define RF22_HEADERR 0x10 |
charly | 0:79c6d0071c4c | 502 | #define RF22_FREQERR 0x08 |
charly | 0:79c6d0071c4c | 503 | #define RF22_LOCKDET 0x04 |
charly | 0:79c6d0071c4c | 504 | #define RF22_CPS 0x03 |
charly | 0:79c6d0071c4c | 505 | #define RF22_CPS_IDLE 0x00 |
charly | 0:79c6d0071c4c | 506 | #define RF22_CPS_RX 0x01 |
charly | 0:79c6d0071c4c | 507 | #define RF22_CPS_TX 0x10 |
charly | 0:79c6d0071c4c | 508 | |
charly | 0:79c6d0071c4c | 509 | // RF22_REG_03_INTERRUPT_STATUS1 0x03 |
charly | 0:79c6d0071c4c | 510 | #define RF22_IFFERROR 0x80 |
charly | 0:79c6d0071c4c | 511 | #define RF22_ITXFFAFULL 0x40 |
charly | 0:79c6d0071c4c | 512 | #define RF22_ITXFFAEM 0x20 |
charly | 0:79c6d0071c4c | 513 | #define RF22_IRXFFAFULL 0x10 |
charly | 0:79c6d0071c4c | 514 | #define RF22_IEXT 0x08 |
charly | 0:79c6d0071c4c | 515 | #define RF22_IPKSENT 0x04 |
charly | 0:79c6d0071c4c | 516 | #define RF22_IPKVALID 0x02 |
charly | 0:79c6d0071c4c | 517 | #define RF22_ICRCERROR 0x01 |
charly | 0:79c6d0071c4c | 518 | |
charly | 0:79c6d0071c4c | 519 | // RF22_REG_04_INTERRUPT_STATUS2 0x04 |
charly | 0:79c6d0071c4c | 520 | #define RF22_ISWDET 0x80 |
charly | 0:79c6d0071c4c | 521 | #define RF22_IPREAVAL 0x40 |
charly | 0:79c6d0071c4c | 522 | #define RF22_IPREAINVAL 0x20 |
charly | 0:79c6d0071c4c | 523 | #define RF22_IRSSI 0x10 |
charly | 0:79c6d0071c4c | 524 | #define RF22_IWUT 0x08 |
charly | 0:79c6d0071c4c | 525 | #define RF22_ILBD 0x04 |
charly | 0:79c6d0071c4c | 526 | #define RF22_ICHIPRDY 0x02 |
charly | 0:79c6d0071c4c | 527 | #define RF22_IPOR 0x01 |
charly | 0:79c6d0071c4c | 528 | |
charly | 0:79c6d0071c4c | 529 | // RF22_REG_05_INTERRUPT_ENABLE1 0x05 |
charly | 0:79c6d0071c4c | 530 | #define RF22_ENFFERR 0x80 |
charly | 0:79c6d0071c4c | 531 | #define RF22_ENTXFFAFULL 0x40 |
charly | 0:79c6d0071c4c | 532 | #define RF22_ENTXFFAEM 0x20 |
charly | 0:79c6d0071c4c | 533 | #define RF22_ENRXFFAFULL 0x10 |
charly | 0:79c6d0071c4c | 534 | #define RF22_ENEXT 0x08 |
charly | 0:79c6d0071c4c | 535 | #define RF22_ENPKSENT 0x04 |
charly | 0:79c6d0071c4c | 536 | #define RF22_ENPKVALID 0x02 |
charly | 0:79c6d0071c4c | 537 | #define RF22_ENCRCERROR 0x01 |
charly | 0:79c6d0071c4c | 538 | |
charly | 0:79c6d0071c4c | 539 | // RF22_REG_06_INTERRUPT_ENABLE2 0x06 |
charly | 0:79c6d0071c4c | 540 | #define RF22_ENSWDET 0x80 |
charly | 0:79c6d0071c4c | 541 | #define RF22_ENPREAVAL 0x40 |
charly | 0:79c6d0071c4c | 542 | #define RF22_ENPREAINVAL 0x20 |
charly | 0:79c6d0071c4c | 543 | #define RF22_ENRSSI 0x10 |
charly | 0:79c6d0071c4c | 544 | #define RF22_ENWUT 0x08 |
charly | 0:79c6d0071c4c | 545 | #define RF22_ENLBDI 0x04 |
charly | 0:79c6d0071c4c | 546 | #define RF22_ENCHIPRDY 0x02 |
charly | 0:79c6d0071c4c | 547 | #define RF22_ENPOR 0x01 |
charly | 0:79c6d0071c4c | 548 | |
charly | 0:79c6d0071c4c | 549 | // RF22_REG_07_OPERATING_MODE 0x07 |
charly | 0:79c6d0071c4c | 550 | #define RF22_SWRES 0x80 |
charly | 0:79c6d0071c4c | 551 | #define RF22_ENLBD 0x40 |
charly | 0:79c6d0071c4c | 552 | #define RF22_ENWT 0x20 |
charly | 0:79c6d0071c4c | 553 | #define RF22_X32KSEL 0x10 |
charly | 0:79c6d0071c4c | 554 | #define RF22_TXON 0x08 |
charly | 0:79c6d0071c4c | 555 | #define RF22_RXON 0x04 |
charly | 0:79c6d0071c4c | 556 | #define RF22_PLLON 0x02 |
charly | 0:79c6d0071c4c | 557 | #define RF22_XTON 0x01 |
charly | 0:79c6d0071c4c | 558 | |
charly | 0:79c6d0071c4c | 559 | // RF22_REG_08_OPERATING_MODE2 0x08 |
charly | 0:79c6d0071c4c | 560 | #define RF22_ANTDIV 0xc0 |
charly | 0:79c6d0071c4c | 561 | #define RF22_RXMPK 0x10 |
charly | 0:79c6d0071c4c | 562 | #define RF22_AUTOTX 0x08 |
charly | 0:79c6d0071c4c | 563 | #define RF22_ENLDM 0x04 |
charly | 0:79c6d0071c4c | 564 | #define RF22_FFCLRRX 0x02 |
charly | 0:79c6d0071c4c | 565 | #define RF22_FFCLRTX 0x01 |
charly | 0:79c6d0071c4c | 566 | |
charly | 0:79c6d0071c4c | 567 | // RF22_REG_0F_ADC_CONFIGURATION 0x0f |
charly | 0:79c6d0071c4c | 568 | #define RF22_ADCSTART 0x80 |
charly | 0:79c6d0071c4c | 569 | #define RF22_ADCDONE 0x80 |
charly | 0:79c6d0071c4c | 570 | #define RF22_ADCSEL 0x70 |
charly | 0:79c6d0071c4c | 571 | #define RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR 0x00 |
charly | 0:79c6d0071c4c | 572 | #define RF22_ADCSEL_GPIO0_SINGLE_ENDED 0x10 |
charly | 0:79c6d0071c4c | 573 | #define RF22_ADCSEL_GPIO1_SINGLE_ENDED 0x20 |
charly | 0:79c6d0071c4c | 574 | #define RF22_ADCSEL_GPIO2_SINGLE_ENDED 0x30 |
charly | 0:79c6d0071c4c | 575 | #define RF22_ADCSEL_GPIO0_GPIO1_DIFFERENTIAL 0x40 |
charly | 0:79c6d0071c4c | 576 | #define RF22_ADCSEL_GPIO1_GPIO2_DIFFERENTIAL 0x50 |
charly | 0:79c6d0071c4c | 577 | #define RF22_ADCSEL_GPIO0_GPIO2_DIFFERENTIAL 0x60 |
charly | 0:79c6d0071c4c | 578 | #define RF22_ADCSEL_GND 0x70 |
charly | 0:79c6d0071c4c | 579 | #define RF22_ADCREF 0x0c |
charly | 0:79c6d0071c4c | 580 | #define RF22_ADCREF_BANDGAP_VOLTAGE 0x00 |
charly | 0:79c6d0071c4c | 581 | #define RF22_ADCREF_VDD_ON_3 0x08 |
charly | 0:79c6d0071c4c | 582 | #define RF22_ADCREF_VDD_ON_2 0x0c |
charly | 0:79c6d0071c4c | 583 | #define RF22_ADCGAIN 0x03 |
charly | 0:79c6d0071c4c | 584 | |
charly | 0:79c6d0071c4c | 585 | // RF22_REG_10_ADC_SENSOR_AMP_OFFSET 0x10 |
charly | 0:79c6d0071c4c | 586 | #define RF22_ADCOFFS 0x0f |
charly | 0:79c6d0071c4c | 587 | |
charly | 0:79c6d0071c4c | 588 | // RF22_REG_12_TEMPERATURE_SENSOR_CALIBRATION 0x12 |
charly | 0:79c6d0071c4c | 589 | #define RF22_TSRANGE 0xc0 |
charly | 0:79c6d0071c4c | 590 | #define RF22_TSRANGE_M64_64C 0x00 |
charly | 0:79c6d0071c4c | 591 | #define RF22_TSRANGE_M64_192C 0x40 |
charly | 0:79c6d0071c4c | 592 | #define RF22_TSRANGE_0_128C 0x80 |
charly | 0:79c6d0071c4c | 593 | #define RF22_TSRANGE_M40_216F 0xc0 |
charly | 0:79c6d0071c4c | 594 | #define RF22_ENTSOFFS 0x20 |
charly | 0:79c6d0071c4c | 595 | #define RF22_ENTSTRIM 0x10 |
charly | 0:79c6d0071c4c | 596 | #define RF22_TSTRIM 0x0f |
charly | 0:79c6d0071c4c | 597 | |
charly | 0:79c6d0071c4c | 598 | // RF22_REG_14_WAKEUP_TIMER_PERIOD1 0x14 |
charly | 0:79c6d0071c4c | 599 | #define RF22_WTR 0x3c |
charly | 0:79c6d0071c4c | 600 | #define RF22_WTD 0x03 |
charly | 0:79c6d0071c4c | 601 | |
charly | 0:79c6d0071c4c | 602 | // RF22_REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE 0x1d |
charly | 5:0386600f3408 | 603 | #define RF22_AFBCD 0x80 |
charly | 5:0386600f3408 | 604 | #define RF22_ENAFC 0x40 |
charly | 5:0386600f3408 | 605 | #define RF22_AFCGEARH 0x38 |
charly | 5:0386600f3408 | 606 | #define RF22_AFCGEARL 0x07 |
charly | 0:79c6d0071c4c | 607 | |
charly | 5:0386600f3408 | 608 | // RF22_REG_1E_AFC_TIMING_CONTROL 0x1e |
charly | 5:0386600f3408 | 609 | #define RF22_SWAIT_TIMER 0xc0 |
charly | 5:0386600f3408 | 610 | #define RF22_SHWAIT 0x38 |
charly | 5:0386600f3408 | 611 | #define RF22_ANWAIT 0x07 |
charly | 0:79c6d0071c4c | 612 | |
charly | 0:79c6d0071c4c | 613 | // RF22_REG_30_DATA_ACCESS_CONTROL 0x30 |
charly | 0:79c6d0071c4c | 614 | #define RF22_ENPACRX 0x80 |
charly | 5:0386600f3408 | 615 | #define RF22_MSBFRST 0x00 |
charly | 0:79c6d0071c4c | 616 | #define RF22_LSBFRST 0x40 |
charly | 5:0386600f3408 | 617 | #define RF22_CRCHDRS 0x00 |
charly | 0:79c6d0071c4c | 618 | #define RF22_CRCDONLY 0x20 |
charly | 0:79c6d0071c4c | 619 | #define RF22_ENPACTX 0x08 |
charly | 0:79c6d0071c4c | 620 | #define RF22_ENCRC 0x04 |
charly | 0:79c6d0071c4c | 621 | #define RF22_CRC 0x03 |
charly | 0:79c6d0071c4c | 622 | #define RF22_CRC_CCITT 0x00 |
charly | 0:79c6d0071c4c | 623 | #define RF22_CRC_CRC_16_IBM 0x01 |
charly | 0:79c6d0071c4c | 624 | #define RF22_CRC_IEC_16 0x02 |
charly | 0:79c6d0071c4c | 625 | #define RF22_CRC_BIACHEVA 0x03 |
charly | 0:79c6d0071c4c | 626 | |
charly | 0:79c6d0071c4c | 627 | // RF22_REG_32_HEADER_CONTROL1 0x32 |
charly | 0:79c6d0071c4c | 628 | #define RF22_BCEN 0xf0 |
charly | 0:79c6d0071c4c | 629 | #define RF22_BCEN_NONE 0x00 |
charly | 0:79c6d0071c4c | 630 | #define RF22_BCEN_HEADER0 0x10 |
charly | 0:79c6d0071c4c | 631 | #define RF22_BCEN_HEADER1 0x20 |
charly | 0:79c6d0071c4c | 632 | #define RF22_BCEN_HEADER2 0x40 |
charly | 0:79c6d0071c4c | 633 | #define RF22_BCEN_HEADER3 0x80 |
charly | 0:79c6d0071c4c | 634 | #define RF22_HDCH 0x0f |
charly | 0:79c6d0071c4c | 635 | #define RF22_HDCH_NONE 0x00 |
charly | 0:79c6d0071c4c | 636 | #define RF22_HDCH_HEADER0 0x01 |
charly | 0:79c6d0071c4c | 637 | #define RF22_HDCH_HEADER1 0x02 |
charly | 0:79c6d0071c4c | 638 | #define RF22_HDCH_HEADER2 0x04 |
charly | 0:79c6d0071c4c | 639 | #define RF22_HDCH_HEADER3 0x08 |
charly | 0:79c6d0071c4c | 640 | |
charly | 0:79c6d0071c4c | 641 | // RF22_REG_33_HEADER_CONTROL2 0x33 |
charly | 0:79c6d0071c4c | 642 | #define RF22_HDLEN 0x70 |
charly | 0:79c6d0071c4c | 643 | #define RF22_HDLEN_0 0x00 |
charly | 0:79c6d0071c4c | 644 | #define RF22_HDLEN_1 0x10 |
charly | 0:79c6d0071c4c | 645 | #define RF22_HDLEN_2 0x20 |
charly | 0:79c6d0071c4c | 646 | #define RF22_HDLEN_3 0x30 |
charly | 0:79c6d0071c4c | 647 | #define RF22_HDLEN_4 0x40 |
charly | 5:0386600f3408 | 648 | #define RF22_VARPKLEN 0x00 |
charly | 0:79c6d0071c4c | 649 | #define RF22_FIXPKLEN 0x08 |
charly | 0:79c6d0071c4c | 650 | #define RF22_SYNCLEN 0x06 |
charly | 0:79c6d0071c4c | 651 | #define RF22_SYNCLEN_1 0x00 |
charly | 0:79c6d0071c4c | 652 | #define RF22_SYNCLEN_2 0x02 |
charly | 0:79c6d0071c4c | 653 | #define RF22_SYNCLEN_3 0x04 |
charly | 0:79c6d0071c4c | 654 | #define RF22_SYNCLEN_4 0x06 |
charly | 0:79c6d0071c4c | 655 | #define RF22_PREALEN8 0x01 |
charly | 0:79c6d0071c4c | 656 | |
charly | 0:79c6d0071c4c | 657 | // RF22_REG_6D_TX_POWER 0x6d |
charly | 0:79c6d0071c4c | 658 | #define RF22_TXPOW 0x07 |
charly | 0:79c6d0071c4c | 659 | #define RF22_TXPOW_4X31 0x08 // Not used in RFM22B |
charly | 0:79c6d0071c4c | 660 | #define RF22_TXPOW_1DBM 0x00 |
charly | 0:79c6d0071c4c | 661 | #define RF22_TXPOW_2DBM 0x01 |
charly | 0:79c6d0071c4c | 662 | #define RF22_TXPOW_5DBM 0x02 |
charly | 0:79c6d0071c4c | 663 | #define RF22_TXPOW_8DBM 0x03 |
charly | 0:79c6d0071c4c | 664 | #define RF22_TXPOW_11DBM 0x04 |
charly | 0:79c6d0071c4c | 665 | #define RF22_TXPOW_14DBM 0x05 |
charly | 0:79c6d0071c4c | 666 | #define RF22_TXPOW_17DBM 0x06 |
charly | 0:79c6d0071c4c | 667 | #define RF22_TXPOW_20DBM 0x07 |
charly | 0:79c6d0071c4c | 668 | // IN RFM23B |
charly | 0:79c6d0071c4c | 669 | #define RF22_TXPOW_LNA_SW 0x08 |
charly | 0:79c6d0071c4c | 670 | |
charly | 0:79c6d0071c4c | 671 | // RF22_REG_71_MODULATION_CONTROL2 0x71 |
charly | 0:79c6d0071c4c | 672 | #define RF22_TRCLK 0xc0 |
charly | 0:79c6d0071c4c | 673 | #define RF22_TRCLK_NONE 0x00 |
charly | 0:79c6d0071c4c | 674 | #define RF22_TRCLK_GPIO 0x40 |
charly | 0:79c6d0071c4c | 675 | #define RF22_TRCLK_SDO 0x80 |
charly | 0:79c6d0071c4c | 676 | #define RF22_TRCLK_NIRQ 0xc0 |
charly | 0:79c6d0071c4c | 677 | #define RF22_DTMOD 0x30 |
charly | 0:79c6d0071c4c | 678 | #define RF22_DTMOD_DIRECT_GPIO 0x00 |
charly | 0:79c6d0071c4c | 679 | #define RF22_DTMOD_DIRECT_SDI 0x10 |
charly | 0:79c6d0071c4c | 680 | #define RF22_DTMOD_FIFO 0x20 |
charly | 0:79c6d0071c4c | 681 | #define RF22_DTMOD_PN9 0x30 |
charly | 0:79c6d0071c4c | 682 | #define RF22_ENINV 0x08 |
charly | 0:79c6d0071c4c | 683 | #define RF22_FD8 0x04 |
charly | 0:79c6d0071c4c | 684 | #define RF22_MODTYP 0x30 |
charly | 0:79c6d0071c4c | 685 | #define RF22_MODTYP_UNMODULATED 0x00 |
charly | 0:79c6d0071c4c | 686 | #define RF22_MODTYP_OOK 0x01 |
charly | 0:79c6d0071c4c | 687 | #define RF22_MODTYP_FSK 0x02 |
charly | 0:79c6d0071c4c | 688 | #define RF22_MODTYP_GFSK 0x03 |
charly | 0:79c6d0071c4c | 689 | |
charly | 0:79c6d0071c4c | 690 | // RF22_REG_75_FREQUENCY_BAND_SELECT 0x75 |
charly | 0:79c6d0071c4c | 691 | #define RF22_SBSEL 0x40 |
charly | 0:79c6d0071c4c | 692 | #define RF22_HBSEL 0x20 |
charly | 0:79c6d0071c4c | 693 | #define RF22_FB 0x1f |
charly | 0:79c6d0071c4c | 694 | |
charly | 5:0386600f3408 | 695 | // Define this to include Serial printing in diagnostic routines |
charly | 5:0386600f3408 | 696 | //#define RF22_HAVE_SERIAL |
charly | 5:0386600f3408 | 697 | |
charly | 5:0386600f3408 | 698 | //#include <GenericSPI.h> |
charly | 5:0386600f3408 | 699 | //#include <HardwareSPI.h> |
charly | 0:79c6d0071c4c | 700 | ///////////////////////////////////////////////////////////////////// |
charly | 0:79c6d0071c4c | 701 | /// \class RF22 RF22.h <RF22.h> |
charly | 0:79c6d0071c4c | 702 | /// \brief Send and receive unaddressed, unreliable datagrams. |
charly | 0:79c6d0071c4c | 703 | /// |
charly | 0:79c6d0071c4c | 704 | /// This base class provides basic functions for sending and receiving unaddressed, |
charly | 0:79c6d0071c4c | 705 | /// unreliable datagrams of arbitrary length to 255 octets per packet. |
charly | 0:79c6d0071c4c | 706 | /// |
charly | 0:79c6d0071c4c | 707 | /// Subclasses may use this class to implement reliable, addressed datagrams and streams, |
charly | 0:79c6d0071c4c | 708 | /// mesh routers, repeaters, translators etc. |
charly | 0:79c6d0071c4c | 709 | /// |
charly | 0:79c6d0071c4c | 710 | /// On transmission, the TO and FROM addresses default to 0x00, unless changed by a subclass. |
charly | 0:79c6d0071c4c | 711 | /// On reception the TO addressed is checked against the node address (defaults to 0x00) or the |
charly | 0:79c6d0071c4c | 712 | /// broadcast address (which is 0xff). The ID and FLAGS are set to 0, and not checked by this class. |
charly | 0:79c6d0071c4c | 713 | /// This permits use of the this base RF22 class as an |
charly | 0:79c6d0071c4c | 714 | /// unaddresed, unreliable datagram service. Subclasses are expected to change this behaviour to |
charly | 0:79c6d0071c4c | 715 | /// add node address, ids, retransmission etc |
charly | 0:79c6d0071c4c | 716 | /// |
charly | 0:79c6d0071c4c | 717 | /// Naturally, for any 2 radios to communicate that must be configured to use the same frequence and |
charly | 0:79c6d0071c4c | 718 | /// modulation scheme. |
charly | 0:79c6d0071c4c | 719 | class RF22 |
charly | 0:79c6d0071c4c | 720 | { |
charly | 0:79c6d0071c4c | 721 | public: |
charly | 0:79c6d0071c4c | 722 | |
charly | 0:79c6d0071c4c | 723 | /// \brief Defines register values for a set of modem configuration registers |
charly | 0:79c6d0071c4c | 724 | /// |
charly | 0:79c6d0071c4c | 725 | /// Defines register values for a set of modem configuration registers |
charly | 0:79c6d0071c4c | 726 | /// that can be passed to setModemConfig() |
charly | 0:79c6d0071c4c | 727 | /// if none of the choices in ModemConfigChoice suit your need |
charly | 0:79c6d0071c4c | 728 | /// setModemConfig() writes the register values to the appropriate RF22 registers |
charly | 0:79c6d0071c4c | 729 | /// to set the desired modulation type, data rate and deviation/bandwidth. |
charly | 0:79c6d0071c4c | 730 | /// Suitable values for these registers can be computed using the register calculator at |
charly | 5:0386600f3408 | 731 | /// http://www.hoperf.com/upload/rf/RF22B%2023B%2031B%2042B%2043B%20Register%20Settings_RevB1-v5.xls |
charly | 0:79c6d0071c4c | 732 | typedef struct |
charly | 0:79c6d0071c4c | 733 | { |
charly | 0:79c6d0071c4c | 734 | uint8_t reg_1c; ///< Value for register RF22_REG_1C_IF_FILTER_BANDWIDTH |
charly | 0:79c6d0071c4c | 735 | uint8_t reg_1f; ///< Value for register RF22_REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE |
charly | 0:79c6d0071c4c | 736 | uint8_t reg_20; ///< Value for register RF22_REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE |
charly | 0:79c6d0071c4c | 737 | uint8_t reg_21; ///< Value for register RF22_REG_21_CLOCK_RECOVERY_OFFSET2 |
charly | 0:79c6d0071c4c | 738 | uint8_t reg_22; ///< Value for register RF22_REG_22_CLOCK_RECOVERY_OFFSET1 |
charly | 0:79c6d0071c4c | 739 | uint8_t reg_23; ///< Value for register RF22_REG_23_CLOCK_RECOVERY_OFFSET0 |
charly | 0:79c6d0071c4c | 740 | uint8_t reg_24; ///< Value for register RF22_REG_24_CLOCK_RECOVERY_TIMING_LOOP_GAIN1 |
charly | 0:79c6d0071c4c | 741 | uint8_t reg_25; ///< Value for register RF22_REG_25_CLOCK_RECOVERY_TIMING_LOOP_GAIN0 |
charly | 0:79c6d0071c4c | 742 | uint8_t reg_2c; ///< Value for register RF22_REG_2C_OOK_COUNTER_VALUE_1 |
charly | 0:79c6d0071c4c | 743 | uint8_t reg_2d; ///< Value for register RF22_REG_2D_OOK_COUNTER_VALUE_2 |
charly | 0:79c6d0071c4c | 744 | uint8_t reg_2e; ///< Value for register RF22_REG_2E_SLICER_PEAK_HOLD |
charly | 0:79c6d0071c4c | 745 | uint8_t reg_58; ///< Value for register RF22_REG_58_CHARGE_PUMP_CURRENT_TRIMMING |
charly | 0:79c6d0071c4c | 746 | uint8_t reg_69; ///< Value for register RF22_REG_69_AGC_OVERRIDE1 |
charly | 0:79c6d0071c4c | 747 | uint8_t reg_6e; ///< Value for register RF22_REG_6E_TX_DATA_RATE1 |
charly | 0:79c6d0071c4c | 748 | uint8_t reg_6f; ///< Value for register RF22_REG_6F_TX_DATA_RATE0 |
charly | 0:79c6d0071c4c | 749 | uint8_t reg_70; ///< Value for register RF22_REG_70_MODULATION_CONTROL1 |
charly | 0:79c6d0071c4c | 750 | uint8_t reg_71; ///< Value for register RF22_REG_71_MODULATION_CONTROL2 |
charly | 0:79c6d0071c4c | 751 | uint8_t reg_72; ///< Value for register RF22_REG_72_FREQUENCY_DEVIATION |
charly | 0:79c6d0071c4c | 752 | } ModemConfig; |
charly | 0:79c6d0071c4c | 753 | |
charly | 0:79c6d0071c4c | 754 | /// Choices for setModemConfig() for a selected subset of common modulation types, |
charly | 5:0386600f3408 | 755 | /// and data rates. If you need another configuration, use the register calculator. |
charly | 0:79c6d0071c4c | 756 | /// and call setModemRegisters() with your desired settings |
charly | 0:79c6d0071c4c | 757 | /// These are indexes into _modemConfig |
charly | 0:79c6d0071c4c | 758 | typedef enum |
charly | 0:79c6d0071c4c | 759 | { |
charly | 0:79c6d0071c4c | 760 | UnmodulatedCarrier = 0, ///< Unmodulated carrier for testing |
charly | 0:79c6d0071c4c | 761 | FSK_PN9_Rb2Fd5, ///< FSK, No Manchester, Rb = 2kbs, Fd = 5kHz, PN9 random modulation for testing |
charly | 0:79c6d0071c4c | 762 | |
charly | 0:79c6d0071c4c | 763 | FSK_Rb2Fd5, ///< FSK, No Manchester, Rb = 2kbs, Fd = 5kHz |
charly | 0:79c6d0071c4c | 764 | FSK_Rb2_4Fd36, ///< FSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz |
charly | 0:79c6d0071c4c | 765 | FSK_Rb4_8Fd45, ///< FSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz |
charly | 0:79c6d0071c4c | 766 | FSK_Rb9_6Fd45, ///< FSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz |
charly | 0:79c6d0071c4c | 767 | FSK_Rb19_2Fd9_6, ///< FSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz |
charly | 0:79c6d0071c4c | 768 | FSK_Rb38_4Fd19_6, ///< FSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz |
charly | 0:79c6d0071c4c | 769 | FSK_Rb57_6Fd28_8, ///< FSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz |
charly | 0:79c6d0071c4c | 770 | FSK_Rb125Fd125, ///< FSK, No Manchester, Rb = 125kbs, Fd = 125kHz |
charly | 0:79c6d0071c4c | 771 | |
charly | 0:79c6d0071c4c | 772 | GFSK_Rb2Fd5, ///< GFSK, No Manchester, Rb = 2kbs, Fd = 5kHz |
charly | 0:79c6d0071c4c | 773 | GFSK_Rb2_4Fd36, ///< GFSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz |
charly | 0:79c6d0071c4c | 774 | GFSK_Rb4_8Fd45, ///< GFSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz |
charly | 0:79c6d0071c4c | 775 | GFSK_Rb9_6Fd45, ///< GFSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz |
charly | 0:79c6d0071c4c | 776 | GFSK_Rb19_2Fd9_6, ///< GFSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz |
charly | 0:79c6d0071c4c | 777 | GFSK_Rb38_4Fd19_6, ///< GFSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz |
charly | 0:79c6d0071c4c | 778 | GFSK_Rb57_6Fd28_8, ///< GFSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz |
charly | 0:79c6d0071c4c | 779 | GFSK_Rb125Fd125, ///< GFSK, No Manchester, Rb = 125kbs, Fd = 125kHz |
charly | 0:79c6d0071c4c | 780 | |
charly | 0:79c6d0071c4c | 781 | OOK_Rb1_2Bw75, ///< OOK, No Manchester, Rb = 1.2kbs, Rx Bandwidth = 75kHz |
charly | 0:79c6d0071c4c | 782 | OOK_Rb2_4Bw335, ///< OOK, No Manchester, Rb = 2.4kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 783 | OOK_Rb4_8Bw335, ///< OOK, No Manchester, Rb = 4.8kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 784 | OOK_Rb9_6Bw335, ///< OOK, No Manchester, Rb = 9.6kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 785 | OOK_Rb19_2Bw335, ///< OOK, No Manchester, Rb = 19.2kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 786 | OOK_Rb38_4Bw335, ///< OOK, No Manchester, Rb = 38.4kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 787 | OOK_Rb40Bw335 ///< OOK, No Manchester, Rb = 40kbs, Rx Bandwidth = 335kHz |
charly | 0:79c6d0071c4c | 788 | } ModemConfigChoice; |
charly | 0:79c6d0071c4c | 789 | |
charly | 0:79c6d0071c4c | 790 | /// Constructor. You can have multiple instances, but each instance must have its own |
charly | 0:79c6d0071c4c | 791 | /// interrupt and slave select pin. After constructing, you must call init() to initialise the intnerface |
charly | 0:79c6d0071c4c | 792 | /// and the radio module |
charly | 0:79c6d0071c4c | 793 | /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF22 before |
charly | 5:0386600f3408 | 794 | /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega) |
charly | 0:79c6d0071c4c | 795 | /// \param[in] interrupt The interrupt number to use. Default is interrupt 0 (Arduino input pin 2) |
charly | 0:79c6d0071c4c | 796 | RF22(PinName slaveSelectPin , PinName mosi, PinName miso, PinName sclk, PinName interrupt ); |
charly | 0:79c6d0071c4c | 797 | |
charly | 0:79c6d0071c4c | 798 | /// Initialises this instance and the radio module connected to it. |
charly | 0:79c6d0071c4c | 799 | /// The following steps are taken: |
charly | 0:79c6d0071c4c | 800 | /// - Initialise the slave select pin and the SPI interface library |
charly | 0:79c6d0071c4c | 801 | /// - Software reset the RF22 module |
charly | 0:79c6d0071c4c | 802 | /// - Checks the connected RF22 module is either a RF22_DEVICE_TYPE_RX_TRX or a RF22_DEVICE_TYPE_TX |
charly | 0:79c6d0071c4c | 803 | /// - Attaches an interrupt handler |
charly | 0:79c6d0071c4c | 804 | /// - Configures the RF22 module |
charly | 0:79c6d0071c4c | 805 | /// - Sets the frequncy to 434.0 MHz |
charly | 0:79c6d0071c4c | 806 | /// - Sets the modem data rate to FSK_Rb2_4Fd36 |
charly | 0:79c6d0071c4c | 807 | /// \return true if everything was successful |
charly | 0:79c6d0071c4c | 808 | boolean init(); |
charly | 0:79c6d0071c4c | 809 | |
charly | 0:79c6d0071c4c | 810 | /// Issues a software reset to the |
charly | 0:79c6d0071c4c | 811 | /// RF22 module. Blocks for 1ms to ensure the reset is complete. |
charly | 0:79c6d0071c4c | 812 | void reset(); |
charly | 0:79c6d0071c4c | 813 | |
charly | 0:79c6d0071c4c | 814 | /// Reads a single register from the RF22 |
charly | 0:79c6d0071c4c | 815 | /// \param[in] reg Register number, one of RF22_REG_* |
charly | 0:79c6d0071c4c | 816 | /// \return The value of the register |
charly | 0:79c6d0071c4c | 817 | uint8_t spiRead(uint8_t reg); |
charly | 0:79c6d0071c4c | 818 | |
charly | 0:79c6d0071c4c | 819 | /// Writes a single byte to the RF22 |
charly | 0:79c6d0071c4c | 820 | /// \param[in] reg Register number, one of RF22_REG_* |
charly | 0:79c6d0071c4c | 821 | /// \param[in] val The value to write |
charly | 0:79c6d0071c4c | 822 | void spiWrite(uint8_t reg, uint8_t val); |
charly | 0:79c6d0071c4c | 823 | |
charly | 0:79c6d0071c4c | 824 | /// Reads a number of consecutive registers from the RF22 using burst read mode |
charly | 0:79c6d0071c4c | 825 | /// \param[in] reg Register number of the first register, one of RF22_REG_* |
charly | 0:79c6d0071c4c | 826 | /// \param[in] dest Array to write the register values to. Must be at least len bytes |
charly | 0:79c6d0071c4c | 827 | /// \param[in] len Number of bytes to read |
charly | 0:79c6d0071c4c | 828 | void spiBurstRead(uint8_t reg, uint8_t* dest, uint8_t len); |
charly | 0:79c6d0071c4c | 829 | |
charly | 0:79c6d0071c4c | 830 | /// Write a number of consecutive registers using burst write mode |
charly | 0:79c6d0071c4c | 831 | /// \param[in] reg Register number of the first register, one of RF22_REG_* |
charly | 0:79c6d0071c4c | 832 | /// \param[in] src Array of new register values to write. Must be at least len bytes |
charly | 0:79c6d0071c4c | 833 | /// \param[in] len Number of bytes to write |
charly | 5:0386600f3408 | 834 | void spiBurstWrite(uint8_t reg, const uint8_t* src, uint8_t len); |
charly | 0:79c6d0071c4c | 835 | |
charly | 0:79c6d0071c4c | 836 | /// Reads and returns the device status register RF22_REG_02_DEVICE_STATUS |
charly | 0:79c6d0071c4c | 837 | /// \return The value of the device status register |
charly | 0:79c6d0071c4c | 838 | uint8_t statusRead(); |
charly | 0:79c6d0071c4c | 839 | |
charly | 0:79c6d0071c4c | 840 | /// Reads a value from the on-chip analog-digital converter |
charly | 0:79c6d0071c4c | 841 | /// \param[in] adcsel Selects the ADC input to measure. One of RF22_ADCSEL_*. Defaults to the |
charly | 0:79c6d0071c4c | 842 | /// internal temperature sensor |
charly | 0:79c6d0071c4c | 843 | /// \param[in] adcref Specifies the refernce voltage to use. One of RF22_ADCREF_*. |
charly | 0:79c6d0071c4c | 844 | /// Defaults to the internal bandgap voltage. |
charly | 0:79c6d0071c4c | 845 | /// \param[in] adcgain Amplifier gain selection. |
charly | 0:79c6d0071c4c | 846 | /// \param[in] adcoffs Amplifier offseet (0 to 15). |
charly | 0:79c6d0071c4c | 847 | /// \return The analog value. 0 to 255. |
charly | 0:79c6d0071c4c | 848 | uint8_t adcRead(uint8_t adcsel = RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR, |
charly | 0:79c6d0071c4c | 849 | uint8_t adcref = RF22_ADCREF_BANDGAP_VOLTAGE, |
charly | 0:79c6d0071c4c | 850 | uint8_t adcgain = 0, |
charly | 0:79c6d0071c4c | 851 | uint8_t adcoffs = 0); |
charly | 0:79c6d0071c4c | 852 | |
charly | 0:79c6d0071c4c | 853 | /// Reads the on-chip temperature sensoer |
charly | 0:79c6d0071c4c | 854 | /// \param[in] tsrange Specifies the temperature range to use. One of RF22_TSRANGE_* |
charly | 0:79c6d0071c4c | 855 | /// \param[in] tvoffs Specifies the temperature value offset. This is actually signed value |
charly | 0:79c6d0071c4c | 856 | /// added to the measured temperature value |
charly | 0:79c6d0071c4c | 857 | /// \return The measured temperature. |
charly | 0:79c6d0071c4c | 858 | uint8_t temperatureRead(uint8_t tsrange = RF22_TSRANGE_M64_64C, uint8_t tvoffs = 0); |
charly | 0:79c6d0071c4c | 859 | |
charly | 0:79c6d0071c4c | 860 | /// Reads the wakeup timer value in registers RF22_REG_17_WAKEUP_TIMER_VALUE1 |
charly | 0:79c6d0071c4c | 861 | /// and RF22_REG_18_WAKEUP_TIMER_VALUE2 |
charly | 0:79c6d0071c4c | 862 | /// \return The wakeup timer value |
charly | 0:79c6d0071c4c | 863 | uint16_t wutRead(); |
charly | 0:79c6d0071c4c | 864 | |
charly | 0:79c6d0071c4c | 865 | /// Sets the wakeup timer period registers RF22_REG_14_WAKEUP_TIMER_PERIOD1, |
charly | 5:0386600f3408 | 866 | /// RF22_REG_15_WAKEUP_TIMER_PERIOD2 and RF22_R<EG_16_WAKEUP_TIMER_PERIOD3 |
charly | 0:79c6d0071c4c | 867 | /// \param[in] wtm Wakeup timer mantissa value |
charly | 0:79c6d0071c4c | 868 | /// \param[in] wtr Wakeup timer exponent R value |
charly | 0:79c6d0071c4c | 869 | /// \param[in] wtd Wakeup timer exponent D value |
charly | 0:79c6d0071c4c | 870 | void setWutPeriod(uint16_t wtm, uint8_t wtr = 0, uint8_t wtd = 0); |
charly | 0:79c6d0071c4c | 871 | |
charly | 0:79c6d0071c4c | 872 | /// Sets the transmitter and receiver centre frequency |
charly | 0:79c6d0071c4c | 873 | /// \param[in] centre Frequency in MHz. 240.0 to 960.0. Caution, some versions of RF22 and derivatives |
charly | 0:79c6d0071c4c | 874 | /// implemented more restricted frequency ranges. |
charly | 5:0386600f3408 | 875 | /// \param[in] afcPullInRange Sets the AF Pull In Range in MHz. Defaults to 0.05MHz (50kHz). Range is 0.0 to 0.159375 |
charly | 5:0386600f3408 | 876 | /// for frequencies 240.0 to 480MHz, and 0.0 to 0.318750MHz for frequencies 480.0 to 960MHz, |
charly | 5:0386600f3408 | 877 | /// \return true if the selected frquency centre + (fhch * fhs) is within range and the afcPullInRange is within range |
charly | 5:0386600f3408 | 878 | boolean setFrequency(float centre, float afcPullInRange = 0.05); |
charly | 0:79c6d0071c4c | 879 | |
charly | 0:79c6d0071c4c | 880 | /// Sets the frequency hopping step size. |
charly | 0:79c6d0071c4c | 881 | /// \param[in] fhs Frequency Hopping step size in 10kHz increments |
charly | 0:79c6d0071c4c | 882 | /// \return true if centre + (fhch * fhs) is within limits |
charly | 0:79c6d0071c4c | 883 | boolean setFHStepSize(uint8_t fhs); |
charly | 0:79c6d0071c4c | 884 | |
charly | 0:79c6d0071c4c | 885 | /// Sets the frequncy hopping channel. Adds fhch * fhs to centre frequency |
charly | 0:79c6d0071c4c | 886 | /// \param[in] fhch The channel number |
charly | 0:79c6d0071c4c | 887 | /// \return true if the selected frquency centre + (fhch * fhs) is within range |
charly | 0:79c6d0071c4c | 888 | boolean setFHChannel(uint8_t fhch); |
charly | 0:79c6d0071c4c | 889 | |
charly | 5:0386600f3408 | 890 | /// Reads and returns the current RSSI value from register RF22_REG_26_RSSI. If you want to find the RSSI |
charly | 5:0386600f3408 | 891 | /// of the last received message, use lastRssi() instead. |
charly | 0:79c6d0071c4c | 892 | /// \return The current RSSI value |
charly | 0:79c6d0071c4c | 893 | uint8_t rssiRead(); |
charly | 0:79c6d0071c4c | 894 | |
charly | 0:79c6d0071c4c | 895 | /// Reads and returns the current EZMAC value from register RF22_REG_31_EZMAC_STATUS |
charly | 0:79c6d0071c4c | 896 | /// \return The current EZMAC value |
charly | 0:79c6d0071c4c | 897 | uint8_t ezmacStatusRead(); |
charly | 0:79c6d0071c4c | 898 | |
charly | 0:79c6d0071c4c | 899 | /// Sets the parameters for the RF22 Idle mode in register RF22_REG_07_OPERATING_MODE. |
charly | 5:0386600f3408 | 900 | /// Idle mode is the mode the RF22 will be in when not transmitting or receiving. The default idle mode |
charly | 0:79c6d0071c4c | 901 | /// is RF22_XTON ie READY mode. |
charly | 5:0386600f3408 | 902 | /// \param[in] mode Mask of mode bits, using RF22_SWRES, RF22_ENLBD, RF22_ENWT, |
charly | 0:79c6d0071c4c | 903 | /// RF22_X32KSEL, RF22_PLLON, RF22_XTON. |
charly | 0:79c6d0071c4c | 904 | void setMode(uint8_t mode); |
charly | 0:79c6d0071c4c | 905 | |
charly | 0:79c6d0071c4c | 906 | /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running, |
charly | 0:79c6d0071c4c | 907 | /// disables them. |
charly | 0:79c6d0071c4c | 908 | void setModeIdle(); |
charly | 0:79c6d0071c4c | 909 | |
charly | 0:79c6d0071c4c | 910 | /// If current mode is Tx or Idle, changes it to Rx. |
charly | 0:79c6d0071c4c | 911 | /// Starts the receiver in the RF22. |
charly | 0:79c6d0071c4c | 912 | void setModeRx(); |
charly | 0:79c6d0071c4c | 913 | |
charly | 0:79c6d0071c4c | 914 | /// If current mode is Rx or Idle, changes it to Rx. |
charly | 0:79c6d0071c4c | 915 | /// Starts the transmitter in the RF22. |
charly | 0:79c6d0071c4c | 916 | void setModeTx(); |
charly | 0:79c6d0071c4c | 917 | |
charly | 5:0386600f3408 | 918 | /// Returns the operating mode of the library. |
charly | 5:0386600f3408 | 919 | /// \return the current mode, one of RF22_MODE_* |
charly | 5:0386600f3408 | 920 | uint8_t mode(); |
charly | 5:0386600f3408 | 921 | |
charly | 0:79c6d0071c4c | 922 | /// Sets the transmitter power output level in register RF22_REG_6D_TX_POWER. |
charly | 0:79c6d0071c4c | 923 | /// Be a good neighbour and set the lowest power level you need. |
charly | 0:79c6d0071c4c | 924 | /// After init(), the power wil be set to RF22_TXPOW_8DBM. |
charly | 0:79c6d0071c4c | 925 | /// Caution: In some countries you may only select RF22_TXPOW_17DBM if you |
charly | 0:79c6d0071c4c | 926 | /// are also using frequency hopping. |
charly | 0:79c6d0071c4c | 927 | /// \param[in] power Transmitter power level, one of RF22_TXPOW_* |
charly | 0:79c6d0071c4c | 928 | void setTxPower(uint8_t power); |
charly | 0:79c6d0071c4c | 929 | |
charly | 0:79c6d0071c4c | 930 | /// Sets all the registered required to configure the data modem in the RF22, including the data rate, |
charly | 0:79c6d0071c4c | 931 | /// bandwidths etc. You cas use this to configure the modem with custom configuraitons if none of the |
charly | 0:79c6d0071c4c | 932 | /// canned configurations in ModemConfigChoice suit you. |
charly | 0:79c6d0071c4c | 933 | /// \param[in] config A ModemConfig structure containing values for the modem configuration registers. |
charly | 5:0386600f3408 | 934 | void setModemRegisters(const ModemConfig* config); |
charly | 0:79c6d0071c4c | 935 | |
charly | 0:79c6d0071c4c | 936 | /// Select one of the predefined modem configurations. If you need a modem configuration not provided |
charly | 0:79c6d0071c4c | 937 | /// here, use setModemRegisters() with your own ModemConfig. |
charly | 0:79c6d0071c4c | 938 | /// \param[in] index The configuration choice. |
charly | 0:79c6d0071c4c | 939 | /// \return true if index is a valid choice. |
charly | 0:79c6d0071c4c | 940 | boolean setModemConfig(ModemConfigChoice index); |
charly | 0:79c6d0071c4c | 941 | |
charly | 0:79c6d0071c4c | 942 | /// Starts the receiver and checks whether a received message is available. |
charly | 0:79c6d0071c4c | 943 | /// This can be called multiple times in a timeout loop |
charly | 0:79c6d0071c4c | 944 | /// \return true if a complete, valid message has been received and is able to be retrieved by |
charly | 0:79c6d0071c4c | 945 | /// recv() |
charly | 0:79c6d0071c4c | 946 | boolean available(); |
charly | 0:79c6d0071c4c | 947 | |
charly | 0:79c6d0071c4c | 948 | /// Starts the receiver and blocks until a valid received |
charly | 0:79c6d0071c4c | 949 | /// message is available. |
charly | 0:79c6d0071c4c | 950 | void waitAvailable(); |
charly | 0:79c6d0071c4c | 951 | |
charly | 0:79c6d0071c4c | 952 | /// Starts the receiver and blocks until a received message is available or a timeout |
charly | 0:79c6d0071c4c | 953 | /// \param[in] timeout Maximum time to wait in milliseconds. |
charly | 0:79c6d0071c4c | 954 | /// \return true if a message is available |
charly | 0:79c6d0071c4c | 955 | bool waitAvailableTimeout(uint16_t timeout); |
charly | 0:79c6d0071c4c | 956 | |
charly | 0:79c6d0071c4c | 957 | /// Turns the receiver on if it not already on. |
charly | 0:79c6d0071c4c | 958 | /// If there is a valid message available, copy it to buf and return true |
charly | 0:79c6d0071c4c | 959 | /// else return false. |
charly | 0:79c6d0071c4c | 960 | /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted). |
charly | 0:79c6d0071c4c | 961 | /// You should be sure to call this function frequently enough to not miss any messages |
charly | 0:79c6d0071c4c | 962 | /// It is recommended that you call it in your main loop. |
charly | 0:79c6d0071c4c | 963 | /// \param[in] buf Location to copy the received message |
charly | 0:79c6d0071c4c | 964 | /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied. |
charly | 0:79c6d0071c4c | 965 | /// \return true if a valid message was copied to buf |
charly | 0:79c6d0071c4c | 966 | boolean recv(uint8_t* buf, uint8_t* len); |
charly | 0:79c6d0071c4c | 967 | |
charly | 5:0386600f3408 | 968 | /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent(). |
charly | 5:0386600f3408 | 969 | /// Then loads a message into the transmitter and starts the transmitter. Note that a message length |
charly | 5:0386600f3408 | 970 | /// of 0 is NOT permitted. |
charly | 0:79c6d0071c4c | 971 | /// \param[in] data Array of data to be sent |
charly | 5:0386600f3408 | 972 | /// \param[in] len Number of bytes of data to send (> 0) |
charly | 5:0386600f3408 | 973 | /// \return true if the message length was valid and it was correctly queued for transmit |
charly | 5:0386600f3408 | 974 | boolean send(const uint8_t* data, uint8_t len); |
charly | 0:79c6d0071c4c | 975 | |
charly | 5:0386600f3408 | 976 | /// Blocks until the RF22 is not in mode RF22_MODE_TX (ie until the RF22 is not transmitting). |
charly | 5:0386600f3408 | 977 | /// This effectively waits until any previous transmit packet is finished being transmitted. |
charly | 0:79c6d0071c4c | 978 | void waitPacketSent(); |
charly | 0:79c6d0071c4c | 979 | |
charly | 0:79c6d0071c4c | 980 | /// Tells the receiver to accept messages with any TO address, not just messages |
charly | 0:79c6d0071c4c | 981 | /// addressed to this node or the broadcast address |
charly | 0:79c6d0071c4c | 982 | /// \param[in] promiscuous true if you wish to receive messages with any TO address |
charly | 0:79c6d0071c4c | 983 | void setPromiscuous(boolean promiscuous); |
charly | 0:79c6d0071c4c | 984 | |
charly | 0:79c6d0071c4c | 985 | /// Returns the TO header of the last received message |
charly | 0:79c6d0071c4c | 986 | /// \return The TO header |
charly | 0:79c6d0071c4c | 987 | uint8_t headerTo(); |
charly | 0:79c6d0071c4c | 988 | |
charly | 0:79c6d0071c4c | 989 | /// Returns the FROM header of the last received message |
charly | 0:79c6d0071c4c | 990 | /// \return The FROM header |
charly | 0:79c6d0071c4c | 991 | uint8_t headerFrom(); |
charly | 0:79c6d0071c4c | 992 | |
charly | 0:79c6d0071c4c | 993 | /// Returns the ID header of the last received message |
charly | 0:79c6d0071c4c | 994 | /// \return The ID header |
charly | 0:79c6d0071c4c | 995 | uint8_t headerId(); |
charly | 0:79c6d0071c4c | 996 | |
charly | 0:79c6d0071c4c | 997 | /// Returns the FLAGS header of the last received message |
charly | 0:79c6d0071c4c | 998 | /// \return The FLAGS header |
charly | 0:79c6d0071c4c | 999 | uint8_t headerFlags(); |
charly | 0:79c6d0071c4c | 1000 | |
charly | 0:79c6d0071c4c | 1001 | /// Returns the RSSI (Receiver Signal Strength Indicator) |
charly | 0:79c6d0071c4c | 1002 | /// of the last received message. This measurement is taken when |
charly | 0:79c6d0071c4c | 1003 | /// the preamble has been received. It is a (non-linear) measure of the received signal strength. |
charly | 0:79c6d0071c4c | 1004 | /// \return The RSSI |
charly | 0:79c6d0071c4c | 1005 | uint8_t lastRssi(); |
charly | 0:79c6d0071c4c | 1006 | |
charly | 5:0386600f3408 | 1007 | /// Prints a data buffer in HEX. |
charly | 5:0386600f3408 | 1008 | /// For diagnostic use |
charly | 5:0386600f3408 | 1009 | /// \param[in] prompt string to preface the print |
charly | 5:0386600f3408 | 1010 | /// \param[in] buf Location of the buffer to print |
charly | 5:0386600f3408 | 1011 | /// \param[in] len Length of the buffer in octets. |
charly | 5:0386600f3408 | 1012 | static void printBuffer(const char* prompt, const uint8_t* buf, uint8_t len); |
charly | 5:0386600f3408 | 1013 | |
charly | 5:0386600f3408 | 1014 | /// Sets the length of the preamble |
charly | 5:0386600f3408 | 1015 | /// in 4-bit nibbles. |
charly | 5:0386600f3408 | 1016 | /// Caution: this should be set to the same |
charly | 5:0386600f3408 | 1017 | /// value on all nodes in your network. Default is 8. |
charly | 0:79c6d0071c4c | 1018 | /// Sets the message preamble length in RF22_REG_34_PREAMBLE_LENGTH |
charly | 0:79c6d0071c4c | 1019 | /// \param[in] nibbles Preamble length in nibbles of 4 bits each. |
charly | 0:79c6d0071c4c | 1020 | void setPreambleLength(uint8_t nibbles); |
charly | 0:79c6d0071c4c | 1021 | |
charly | 0:79c6d0071c4c | 1022 | /// Sets the sync words for transmit and receive in registers RF22_REG_36_SYNC_WORD3 |
charly | 0:79c6d0071c4c | 1023 | /// to RF22_REG_39_SYNC_WORD0 |
charly | 5:0386600f3408 | 1024 | /// Caution: this should be set to the same |
charly | 5:0386600f3408 | 1025 | /// value on all nodes in your network. Default is { 0x2d, 0xd4 } |
charly | 0:79c6d0071c4c | 1026 | /// \param[in] syncWords Array of sync words |
charly | 0:79c6d0071c4c | 1027 | /// \param[in] len Number of sync words to set |
charly | 5:0386600f3408 | 1028 | void setSyncWords(const uint8_t* syncWords, uint8_t len); |
charly | 0:79c6d0071c4c | 1029 | |
charly | 5:0386600f3408 | 1030 | protected: |
charly | 0:79c6d0071c4c | 1031 | /// This is a low level function to handle the interrupts for one instance of RF22. |
charly | 0:79c6d0071c4c | 1032 | /// Called automatically by isr0() and isr1() |
charly | 0:79c6d0071c4c | 1033 | /// Should not need to be called. |
charly | 0:79c6d0071c4c | 1034 | void handleInterrupt(); |
charly | 0:79c6d0071c4c | 1035 | |
charly | 0:79c6d0071c4c | 1036 | /// Clears the receiver buffer. |
charly | 0:79c6d0071c4c | 1037 | /// Internal use only |
charly | 0:79c6d0071c4c | 1038 | void clearRxBuf(); |
charly | 0:79c6d0071c4c | 1039 | |
charly | 0:79c6d0071c4c | 1040 | /// Clears the transmitter buffer |
charly | 0:79c6d0071c4c | 1041 | /// Internal use only |
charly | 0:79c6d0071c4c | 1042 | void clearTxBuf(); |
charly | 0:79c6d0071c4c | 1043 | |
charly | 0:79c6d0071c4c | 1044 | /// Fills the transmitter buffer with the data of a mesage to be sent |
charly | 5:0386600f3408 | 1045 | /// \param[in] data Array of data bytes to be sent (1 to 255) |
charly | 5:0386600f3408 | 1046 | /// \param[in] len Number of data bytes in data (> 0) |
charly | 5:0386600f3408 | 1047 | /// \return true if the message length is valid |
charly | 5:0386600f3408 | 1048 | boolean fillTxBuf(const uint8_t* data, uint8_t len); |
charly | 0:79c6d0071c4c | 1049 | |
charly | 0:79c6d0071c4c | 1050 | /// Appends the transmitter buffer with the data of a mesage to be sent |
charly | 0:79c6d0071c4c | 1051 | /// \param[in] data Array of data bytes to be sent (0 to 255) |
charly | 0:79c6d0071c4c | 1052 | /// \param[in] len Number of data bytes in data |
charly | 0:79c6d0071c4c | 1053 | /// \return false if the resulting message would exceed RF22_MAX_MESSAGE_LEN, else true |
charly | 5:0386600f3408 | 1054 | boolean appendTxBuf(const uint8_t* data, uint8_t len); |
charly | 0:79c6d0071c4c | 1055 | |
charly | 0:79c6d0071c4c | 1056 | /// Internal function to load the next fragment of |
charly | 0:79c6d0071c4c | 1057 | /// the current message into the transmitter FIFO |
charly | 0:79c6d0071c4c | 1058 | /// Internal use only |
charly | 0:79c6d0071c4c | 1059 | void sendNextFragment(); |
charly | 0:79c6d0071c4c | 1060 | |
charly | 0:79c6d0071c4c | 1061 | /// function to copy the next fragment from |
charly | 0:79c6d0071c4c | 1062 | /// the receiver FIF) into the receiver buffer |
charly | 0:79c6d0071c4c | 1063 | void readNextFragment(); |
charly | 0:79c6d0071c4c | 1064 | |
charly | 0:79c6d0071c4c | 1065 | /// Clears the RF22 Rx and Tx FIFOs |
charly | 0:79c6d0071c4c | 1066 | /// Internal use only |
charly | 0:79c6d0071c4c | 1067 | void resetFifos(); |
charly | 0:79c6d0071c4c | 1068 | |
charly | 0:79c6d0071c4c | 1069 | /// Clears the RF22 Rx FIFO |
charly | 0:79c6d0071c4c | 1070 | /// Internal use only |
charly | 0:79c6d0071c4c | 1071 | void resetRxFifo(); |
charly | 0:79c6d0071c4c | 1072 | |
charly | 0:79c6d0071c4c | 1073 | /// Clears the RF22 Tx FIFO |
charly | 0:79c6d0071c4c | 1074 | /// Internal use only |
charly | 0:79c6d0071c4c | 1075 | void resetTxFifo(); |
charly | 0:79c6d0071c4c | 1076 | |
charly | 0:79c6d0071c4c | 1077 | /// This function will be called by handleInterrupt() if an RF22 external interrupt occurs. |
charly | 0:79c6d0071c4c | 1078 | /// This can only happen if external interrupts are enabled in the RF22 |
charly | 0:79c6d0071c4c | 1079 | /// (which they are not by default). |
charly | 0:79c6d0071c4c | 1080 | /// Subclasses may override this function to get control when an RF22 external interrupt occurs. |
charly | 0:79c6d0071c4c | 1081 | virtual void handleExternalInterrupt(); |
charly | 0:79c6d0071c4c | 1082 | |
charly | 0:79c6d0071c4c | 1083 | /// This function will be called by handleInterrupt() if an RF22 wakeup timer interrupt occurs. |
charly | 0:79c6d0071c4c | 1084 | /// This can only happen if wakeup timer interrupts are enabled in the RF22 |
charly | 0:79c6d0071c4c | 1085 | /// (which they are not by default). |
charly | 0:79c6d0071c4c | 1086 | /// Subclasses may override this function to get control when an RF22 wakeup timer interrupt occurs. |
charly | 0:79c6d0071c4c | 1087 | virtual void handleWakeupTimerInterrupt(); |
charly | 0:79c6d0071c4c | 1088 | |
charly | 0:79c6d0071c4c | 1089 | /// Sets the TO header to be sent in all subsequent messages |
charly | 0:79c6d0071c4c | 1090 | /// \param[in] to The new TO header value |
charly | 0:79c6d0071c4c | 1091 | void setHeaderTo(uint8_t to); |
charly | 0:79c6d0071c4c | 1092 | |
charly | 0:79c6d0071c4c | 1093 | /// Sets the FROM header to be sent in all subsequent messages |
charly | 0:79c6d0071c4c | 1094 | /// \param[in] from The new FROM header value |
charly | 0:79c6d0071c4c | 1095 | void setHeaderFrom(uint8_t from); |
charly | 0:79c6d0071c4c | 1096 | |
charly | 0:79c6d0071c4c | 1097 | /// Sets the ID header to be sent in all subsequent messages |
charly | 0:79c6d0071c4c | 1098 | /// \param[in] id The new ID header value |
charly | 0:79c6d0071c4c | 1099 | void setHeaderId(uint8_t id); |
charly | 0:79c6d0071c4c | 1100 | |
charly | 0:79c6d0071c4c | 1101 | /// Sets the FLAGS header to be sent in all subsequent messages |
charly | 0:79c6d0071c4c | 1102 | /// \param[in] flags The new FLAGS header value |
charly | 0:79c6d0071c4c | 1103 | void setHeaderFlags(uint8_t flags); |
charly | 0:79c6d0071c4c | 1104 | |
charly | 0:79c6d0071c4c | 1105 | /// Start the transmission of the contents |
charly | 0:79c6d0071c4c | 1106 | /// of the Tx buffer |
charly | 0:79c6d0071c4c | 1107 | void startTransmit(); |
charly | 0:79c6d0071c4c | 1108 | |
charly | 0:79c6d0071c4c | 1109 | /// ReStart the transmission of the contents |
charly | 0:79c6d0071c4c | 1110 | /// of the Tx buffer after a atransmission failure |
charly | 0:79c6d0071c4c | 1111 | void restartTransmit(); |
charly | 0:79c6d0071c4c | 1112 | |
charly | 5:0386600f3408 | 1113 | protected: |
charly | 5:0386600f3408 | 1114 | //GenericSPIClass* _spi; |
charly | 5:0386600f3408 | 1115 | |
charly | 0:79c6d0071c4c | 1116 | /// Low level interrupt service routine for RF22 connected to interrupt 0 |
charly | 0:79c6d0071c4c | 1117 | //static void isr0(); |
charly | 0:79c6d0071c4c | 1118 | void isr0(); |
charly | 0:79c6d0071c4c | 1119 | |
charly | 0:79c6d0071c4c | 1120 | /// Low level interrupt service routine for RF22 connected to interrupt 1 |
charly | 0:79c6d0071c4c | 1121 | //static void isr1(); |
charly | 7:b86825b9d74b | 1122 | private: |
charly | 0:79c6d0071c4c | 1123 | /// Array of instances connected to interrupts 0 and 1 |
charly | 0:79c6d0071c4c | 1124 | //static RF22* _RF22ForInterrupt[]; |
charly | 0:79c6d0071c4c | 1125 | |
charly | 0:79c6d0071c4c | 1126 | |
charly | 5:0386600f3408 | 1127 | volatile uint8_t _mode; // One of RF22_MODE_* |
charly | 0:79c6d0071c4c | 1128 | |
charly | 0:79c6d0071c4c | 1129 | uint8_t _idleMode; |
charly | 0:79c6d0071c4c | 1130 | DigitalOut _slaveSelectPin; |
charly | 0:79c6d0071c4c | 1131 | SPI _spi; |
charly | 0:79c6d0071c4c | 1132 | InterruptIn _interrupt; |
charly | 0:79c6d0071c4c | 1133 | uint8_t _deviceType; |
charly | 0:79c6d0071c4c | 1134 | |
charly | 0:79c6d0071c4c | 1135 | DigitalOut led1; |
charly | 0:79c6d0071c4c | 1136 | DigitalOut led2; |
charly | 0:79c6d0071c4c | 1137 | DigitalOut led3; |
charly | 0:79c6d0071c4c | 1138 | DigitalOut led4; |
charly | 0:79c6d0071c4c | 1139 | |
charly | 0:79c6d0071c4c | 1140 | // These volatile members may get changed in the interrupt service routine |
charly | 5:0386600f3408 | 1141 | volatile uint8_t _bufLen; |
charly | 0:79c6d0071c4c | 1142 | uint8_t _buf[RF22_MAX_MESSAGE_LEN]; |
charly | 0:79c6d0071c4c | 1143 | |
charly | 0:79c6d0071c4c | 1144 | volatile boolean _rxBufValid; |
charly | 0:79c6d0071c4c | 1145 | |
charly | 0:79c6d0071c4c | 1146 | volatile boolean _txPacketSent; |
charly | 0:79c6d0071c4c | 1147 | volatile uint8_t _txBufSentIndex; |
charly | 0:79c6d0071c4c | 1148 | |
charly | 0:79c6d0071c4c | 1149 | volatile uint16_t _rxBad; |
charly | 0:79c6d0071c4c | 1150 | volatile uint16_t _rxGood; |
charly | 0:79c6d0071c4c | 1151 | volatile uint16_t _txGood; |
charly | 0:79c6d0071c4c | 1152 | |
charly | 0:79c6d0071c4c | 1153 | volatile uint8_t _lastRssi; |
charly | 0:79c6d0071c4c | 1154 | }; |
charly | 0:79c6d0071c4c | 1155 | |
charly | 5:0386600f3408 | 1156 | /// @example rf22_client.pde |
charly | 5:0386600f3408 | 1157 | /// Client side of simple client/server pair using RF22 class |
charly | 5:0386600f3408 | 1158 | |
charly | 5:0386600f3408 | 1159 | /// @example rf22_server.pde |
charly | 5:0386600f3408 | 1160 | /// Server side of simple client/server pair using RF22 class |
charly | 5:0386600f3408 | 1161 | |
charly | 5:0386600f3408 | 1162 | /// @example rf22_datagram_client.pde |
charly | 5:0386600f3408 | 1163 | /// Client side of simple client/server pair using RF22Datagram class |
charly | 5:0386600f3408 | 1164 | |
charly | 5:0386600f3408 | 1165 | /// @example rf22_datagram_server.pde |
charly | 5:0386600f3408 | 1166 | /// Server side of simple client/server pair using RF22Datagram class |
charly | 5:0386600f3408 | 1167 | |
charly | 5:0386600f3408 | 1168 | /// @example rf22_reliable_datagram_client.pde |
charly | 5:0386600f3408 | 1169 | /// Client side of simple client/server pair using RF22ReliableDatagram class |
charly | 5:0386600f3408 | 1170 | |
charly | 5:0386600f3408 | 1171 | /// @example rf22_reliable_datagram_server.pde |
charly | 5:0386600f3408 | 1172 | /// Server side of simple client/server pair using RF22ReliableDatagram class |
charly | 5:0386600f3408 | 1173 | |
charly | 5:0386600f3408 | 1174 | /// @example rf22_router_client.pde |
charly | 5:0386600f3408 | 1175 | /// Client side of RF22Router network chain |
charly | 5:0386600f3408 | 1176 | |
charly | 5:0386600f3408 | 1177 | /// @example rf22_router_server1.pde |
charly | 5:0386600f3408 | 1178 | /// Server node for RF22Router network chain |
charly | 5:0386600f3408 | 1179 | |
charly | 5:0386600f3408 | 1180 | /// @example rf22_router_server2.pde |
charly | 5:0386600f3408 | 1181 | /// Server node for RF22Router network chain |
charly | 5:0386600f3408 | 1182 | |
charly | 5:0386600f3408 | 1183 | /// @example rf22_router_server3.pde |
charly | 5:0386600f3408 | 1184 | /// Server node for RF22Router network chain |
charly | 5:0386600f3408 | 1185 | |
charly | 5:0386600f3408 | 1186 | /// @example rf22_mesh_client.pde |
charly | 5:0386600f3408 | 1187 | /// Client side of RF22Mesh network chain |
charly | 5:0386600f3408 | 1188 | |
charly | 5:0386600f3408 | 1189 | /// @example rf22_mesh_server1.pde |
charly | 5:0386600f3408 | 1190 | /// Server node for RF22Mesh network chain |
charly | 5:0386600f3408 | 1191 | |
charly | 5:0386600f3408 | 1192 | /// @example rf22_mesh_server2.pde |
charly | 5:0386600f3408 | 1193 | /// Server node for RF22Mesh network chain |
charly | 5:0386600f3408 | 1194 | |
charly | 5:0386600f3408 | 1195 | /// @example rf22_mesh_server3.pde |
charly | 5:0386600f3408 | 1196 | /// Server node for RF22Mesh network chain |
charly | 5:0386600f3408 | 1197 | |
charly | 5:0386600f3408 | 1198 | /// @example rf22_test.pde |
charly | 5:0386600f3408 | 1199 | /// Test suite for RF22 library |
charly | 5:0386600f3408 | 1200 | |
charly | 5:0386600f3408 | 1201 | /// @example rf22_snoop.pde |
charly | 5:0386600f3408 | 1202 | /// Capture and print RF22 packet from the air |
charly | 5:0386600f3408 | 1203 | |
charly | 5:0386600f3408 | 1204 | /// @example rf22_specan.pde |
charly | 5:0386600f3408 | 1205 | /// Simple spectrum analyser using the RSSI measurements of the RF22 |
charly | 5:0386600f3408 | 1206 | /// (see <a href="specan1.png">Sample output</a> showing a plot from 395.0MHz to 396.0MHz of a |
charly | 5:0386600f3408 | 1207 | /// signal generator at 395.5MHz amplitude modulated at 100% 1kHz) |
charly | 5:0386600f3408 | 1208 | /// |
charly | 5:0386600f3408 | 1209 | |
charly | 5:0386600f3408 | 1210 | /// @example IPGateway.pde |
charly | 5:0386600f3408 | 1211 | /// Sketch to provide an IP gateway for a set of RF22 radios (Datagram, ReliableDatagram, Router or Mesh) |
charly | 5:0386600f3408 | 1212 | /// Routes UDP messages from an internet connection using an Ethernet Shield and sends them |
charly | 5:0386600f3408 | 1213 | /// to a radio whose ID is based on the UDP port. Replies are sent back to the originating UDP |
charly | 5:0386600f3408 | 1214 | /// address and port |
charly | 5:0386600f3408 | 1215 | |
charly | 0:79c6d0071c4c | 1216 | |
charly | 0:79c6d0071c4c | 1217 | #endif |