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