RF69
RF69.h
1 // RF69.h
2 // Author: Mike McCauley (mikem@airspayce.com)
3 // Copyright (C) 2014 Mike McCauley
4 // $Id: RF69.h,v 1.3 2014/04/04 05:45:58 mikem Exp mikem $
5 //
6 /// \mainpage RF69 library for Arduino
7 ///
8 /// \par END OF LIFE NOTICE
9 ///
10 /// This RF69 library has now been superceded by the RadioHead
11 /// library http://www.airspayce.com/mikem/arduino/RadioHead
12 /// RadioHead and its RH_RF69 driver provides all the features supported by RF69, and much more
13 /// besides, including Reliable Datagrams, Addressing, Routing and Meshes. All the platforms that
14 /// RF69 supported are also supported by RadioHead.
15 ///
16 /// This library will no longer be maintained or updated, but we will continue to publish
17 /// it for the benefit of the the community, and you may continue to use it within the terms of
18 /// the license. Nevertheless we recommend upgrading to RadioHead where
19 /// possible.
20 ///
21 /// This is the Arduino RF69 library.
22 /// It provides an object-oriented interface for sending and receiving data messages with Hope-RF
23 /// RF69B based radio modules, such as the RFM69 module, (as used on the excellent Moteino and Moteino-USB
24 /// boards from LowPowerLab http://lowpowerlab.com/moteino/ )
25 /// and compatible chips and modules such as RFM69W, RFM69HW, RFM69CW, RFM69HCW (Semtech SX1231, SX1231H)
26 /// The RFM69 device is described in http://www.hoperf.cn/upload/rf/RFM69-V1.3.pdf
27 /// and http://www.hoperf.com/upload/rfchip/RF69-V1.2.pdf
28 ///
29 /// The Hope-RF (http://www.hoperf.com) RF69 is a low-cost ISM transceiver
30 /// chip. It supports FSK, GFSK, OOK over a wide range of frequencies and
31 /// programmable data rates. It also suports AES encryption of up to 64 octets
32 /// of payload It is available prepackaged on modules such as the RFM69W. And
33 /// such modules can be prepacked on processor boards such as the Moteino from
34 /// LowPowerLabs (which is what we used to develop the RF69 library)
35 ///
36 /// This library provides functions for sending and receiving messages of up
37 /// to 60 octets on any frequency supported by the RF69, in a range of
38 /// predefined data rates and frequency deviations. Frequency can be set with
39 /// 61Hz precision to any frequency from 240.0MHz to 960.0MHz.
40 ///
41 /// Up to 2 RF69B modules can be connected to an Arduino (3 on a Mega),
42 /// permitting the construction of translators and frequency changers, etc.
43 ///
44 /// This library provides classes for
45 /// - RF69: unaddressed, unreliable messages
46 ///
47 /// Coming soon: classes for datagrams, reliable datagrams, routers and meshes
48 ///
49 /// The following modulation types are suppported with a range of modem configurations for
50 /// common data rates and frequency deviations:
51 /// - GFSK Gaussian Frequency Shift Keying
52 /// - FSK Frequency Shift Keying
53 ///
54 /// Support for other RF69 features such as on-chip temperature measurement,
55 /// transmitter power control etc is also provided.
56 ///
57 /// The latest version of this documentation can be downloaded from
58 /// http://www.airspayce.com/mikem/arduino/RF69
59 ///
60 /// Example Arduino programs are included to show the main modes of use.
61 ///
62 /// The version of the package that this documentation refers to can be downloaded
63 /// from http://www.airspayce.com/mikem/arduino/RF69/RF69-1.3.zip
64 /// You can find the latest version at http://www.airspayce.com/mikem/arduino/RF69
65 ///
66 /// Tested on USB-Moteino with arduino-1.0.5
67 /// on OpenSuSE 13.1
68 ///
69 /// \par Packet Format
70 ///
71 /// All messages sent and received by this RF69 library must conform to this packet format:
72 ///
73 /// - 4 octets PREAMBLE
74 /// - 2 octets SYNC 0x2d, 0xd4 (configurable, so you can use this as a network filter)
75 /// - 1 octet RF69 payload length
76 /// - 4 octets HEADER: (TO, FROM, ID, FLAGS)
77 /// - 0 to 60 octets DATA
78 /// - 2 octets CRC computed with CRC16(IBM), computed on HEADER and DATA
79 ///
80 /// For technical reasons, the message format is not compatible with the
81 /// 'HopeRF Radio Transceiver Message Library for Arduino'
82 /// http://www.airspayce.com/mikem/arduino/HopeRF from the same author. Nor is
83 /// it compatible with messages sent by 'Virtual Wire'
84 /// http://www.airspayce.com/mikem/arduino/VirtualWire.pdf also from the same
85 /// author. Nor is it compatible with messages sent by 'RF22'
86 /// http://www.airspayce.com/mikem/arduino/RF22 also from the same author.
87 ///
88 /// \par Connecting RFM-69 to Arduino
89 ///
90 /// We tested with Moteino, which is an Arduino Uno compatible with the RFM69W
91 /// module on-board. Therefore it needs no connections other than the USB
92 /// programming connection and an antenna to make it work.
93 ///
94 /// If you have a bare RFM69W that you want to connect to an Arduino, you
95 /// might use these connections (untested): CAUTION: you must use a 3.3V type
96 /// Arduino, otherwise you will also need voltage level shifters between the
97 /// Arduino and the RFM69. CAUTION, you must also ensure you connect an
98 /// antenna
99 ///
100 /// \code
101 /// Arduino RFM69W
102 /// GND----------GND (ground in)
103 /// 3V3----------3.3V (3.3V in)
104 /// interrupt 0 pin D2-----------DIO0 (interrupt request out)
105 /// SS pin D10----------NSS (chip select in)
106 /// SCK pin D13----------SCK (SPI clock in)
107 /// MOSI pin D11----------MOSI (SPI Data in)
108 /// MISO pin D12----------MISO (SPI Data out)
109 /// \endcode
110 ///
111 /// With these connections, you can then use the default constructor RF69().
112 /// You can override the default settings for the SS pin and the interrupt in
113 /// the RF69 constructor if you wish to connect the slave select SS to other
114 /// than the normal one for your Arduino (D10 for Diecimila, Uno etc and D53
115 /// for Mega) or the interrupt request to other than pin D2 (Caution,
116 /// different processors have different constraints as to the pins available
117 /// for interrupts).
118 ///
119 /// It is possible to have 2 or more radios connected to one Arduino, provided
120 /// each radio has its own SS and interrupt line (SCK, SDI and SDO are common
121 /// to all radios)
122 ///
123 /// Caution: on some Arduinos such as the Mega 2560, if you set the slave
124 /// select pin to be other than the usual SS pin (D53 on Mega 2560), you may
125 /// need to set the usual SS pin to be an output to force the Arduino into SPI
126 /// master mode.
127 ///
128 /// Caution: Power supply requirements of the RF69 module may be relevant in some circumstances:
129 /// RF69 modules are capable of pulling 45mA+ at full power, where Arduino's 3.3V line can
130 /// give 50mA. You may need to make provision for alternate power supply for
131 /// the RF69, especially if you wish to use full transmit power, and/or you have
132 /// other shields demanding power. Inadequate power for the RF69 is likely to cause symptoms such as:
133 /// -reset's/bootups terminate with "init failed" messages
134 /// -random termination of communication after 5-30 packets sent/received
135 /// -"fake ok" state, where initialization passes fluently, but communication doesn't happen
136 /// -shields hang Arduino boards, especially during the flashing
137 /// \par Interrupts
138 ///
139 /// The RF69 library uses interrupts to react to events in the RF69 module,
140 /// such as the reception of a new packet, or the completion of transmission
141 /// of a packet. The RF69 library interrupt service routine reads status from
142 /// and writes data to the the RF69 module via the SPI interface. It is very
143 /// important therefore, that if you are using the RF69 library with another
144 /// SPI based deviced, that you disable interrupts while you transfer data to
145 /// and from that other device. Use cli() to disable interrupts and sei() to
146 /// reenable them.
147 ///
148 /// \par Memory
149 ///
150 /// The RF69 library requires non-trivial amounts of memory. The sample
151 /// programs above all compile to about 8kbytes each, which will fit in the
152 /// flash proram memory of most Arduinos. However, the RAM requirements are
153 /// more critical. Therefore, you should be vary sparing with RAM use in
154 /// programs that use the RF69 library.
155 ///
156 /// It is often hard to accurately identify when you are hitting RAM limits on Arduino.
157 /// The symptoms can include:
158 /// - Mysterious crashes and restarts
159 /// - Changes in behaviour when seemingly unrelated changes are made (such as adding print() statements)
160 /// - Hanging
161 /// - Output from Serial.print() not appearing
162 ///
163 /// \par Automatic Frequency Control (AFC)
164 ///
165 /// The RF69 module is configured by the RF69 library to always use AFC.
166 ///
167 /// \par Performance
168 ///
169 /// Some simple speed performance tests have been conducted.
170 /// In general packet transmission rate will be limited by the modulation scheme.
171 /// Also, if your code does any slow operations like Serial printing it will also limit performance.
172 /// We disabled any printing in the tests below.
173 /// We tested with RF69::GFSK_Rb250Fd250, which is probably the fastest scheme available.
174 /// We tested with a 13 octet message length, over a very short distance of 10cm.
175 ///
176 /// Transmission (no reply) tests with modulation RF69::GFSK_Rb250Fd250 and a
177 /// 13 octet message show about 152 messages per second transmitted and received.
178 ///
179 /// Transmit-and-wait-for-a-reply tests with modulation RF69::GFSK_Rb250Fd250 and a
180 /// 13 octet message (send and receive) show about 68 round trips per second.
181 ///
182 /// \par Installation
183 ///
184 /// Install in the usual way: unzip the distribution zip file to the libraries
185 /// sub-folder of your sketchbook.
186 ///
187 /// This software is Copyright (C) 2011 Mike McCauley. Use is subject to license
188 /// conditions. The main licensing options available are GPL V2 or Commercial:
189 ///
190 /// \par Donations
191 ///
192 /// This library is offered under a free GPL license for those who want to use it that way.
193 /// We try hard to keep it up to date, fix bugs
194 /// and to provide free support. If this library has helped you save time or money, please consider donating at
195 /// http://www.airspayce.com or here:
196 ///
197 /// \htmlonly <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_donations" /> <input type="hidden" name="business" value="mikem@airspayce.com" /> <input type="hidden" name="lc" value="AU" /> <input type="hidden" name="item_name" value="Airspayce" /> <input type="hidden" name="item_number" value="RF69" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" /> <input type="image" alt="PayPal — The safer, easier way to pay online." name="submit" src="https://www.paypalobjects.com/en_AU/i/btn/btn_donateCC_LG.gif" /> <img alt="" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1" border="0" /></form> \endhtmlonly
198 ///
199 /// \par Open Source Licensing GPL V2
200 ///
201 /// This is the appropriate option if you want to share the source code of your
202 /// application with everyone you distribute it to, and you also want to give them
203 /// the right to share who uses it. If you wish to use this software under Open
204 /// Source Licensing, you must contribute all your source code to the open source
205 /// community in accordance with the GPL Version 2 when your application is
206 /// distributed. See http://www.gnu.org/copyleft/gpl.html
207 ///
208 /// \par Commercial Licensing
209 ///
210 /// This is the appropriate option if you are creating proprietary applications
211 /// and you are not prepared to distribute and share the source code of your
212 /// application. Contact info@airspayce.com for details.
213 ///
214 /// \par Revision History
215 ///
216 /// \version 1.0 Initial release
217 /// \version 1.1 Fixed some typos with assistance of shorted neuron.
218 /// \version 1.2 Example programs were omitted
219 /// \version 1.3 Added End Of Life notice. This library will no longer be maintained
220 /// and updated: use RadioHead instead.
221 ///
222 /// \author Mike McCauley (mikem@airspayce.com)
223 
224 
225 
226 #ifndef RF69_h
227 #define RF69_h
228 
229 #if ARDUINO >= 100
230 #include <Arduino.h>
231 #else
232 #include <wiring.h>
233 #include "pins_arduino.h"
234 #endif
235 
236 // These defs cause trouble on some versions of Arduino
237 #undef round
238 #undef double
239 
240 // The crystal oscillator frequency of the RF69 module
241 #define RF69_FXOSC 32000000.0
242 
243 // The Frequency Synthesizer step = RF69_FXOSC / 2^^19
244 #define RF69_FSTEP (RF69_FXOSC / 524288)
245 
246 // This is the maximum number of interrupts the library can support
247 // Most Arduinos can handle 2, Megas can handle more
248 #define RF69_NUM_INTERRUPTS 3
249 
250 // This is the bit in the SPI address that marks it as a write
251 #define RF69_SPI_WRITE_MASK 0x80
252 
253 // Max number of octets the RF69 Rx and Tx FIFOs can hold
254 #define RF69_FIFO_SIZE 66
255 
256 // Maximum encryptable payload length the RF69 can support
257 #define RF69_MAX_ENCRYPTABLE_PAYLOAD_LEN 64
258 
259 // The length of the headers we add.
260 // The headers are inside the RF69's payload and are therefore encrypted if encryption is enabled
261 #define RF69_HEADER_LEN 4
262 
263 // This is the maximum message length that can be supported by this library. Limited by
264 // the size of the FIFO, since we are unable to support on-the-fly filling and emptying
265 // of the FIFO.
266 // Can be pre-defined to a smaller size (to save SRAM) prior to including this header
267 // Here we allow for 4 bytes of address and header and payload to be included in the 64 byte encryption limit.
268 // the one byte payload length is not encrpyted
269 #ifndef RF69_MAX_MESSAGE_LEN
270 #define RF69_MAX_MESSAGE_LEN (RF69_MAX_ENCRYPTABLE_PAYLOAD_LEN - RF69_HEADER_LEN)
271 #endif
272 
273 // Keep track of the mode the RF69 is in
274 #define RF69_MODE_IDLE 0
275 #define RF69_MODE_RX 1
276 #define RF69_MODE_TX 2
277 
278 // This is the default node address,
279 #define RF69_DEFAULT_NODE_ADDRESS 0
280 
281 // This address in the TO addreess signifies a broadcast
282 #define RF69_BROADCAST_ADDRESS 0xff
283 
284 // Register names
285 #define RF69_REG_00_FIFO 0x00
286 #define RF69_REG_01_OPMODE 0x01
287 #define RF69_REG_02_DATAMODUL 0x02
288 #define RF69_REG_03_BITRATEMSB 0x03
289 #define RF69_REG_04_BITRATELSB 0x04
290 #define RF69_REG_05_FDEVMSB 0x05
291 #define RF69_REG_06_FDEVLSB 0x06
292 #define RF69_REG_07_FRFMSB 0x07
293 #define RF69_REG_08_FRFMID 0x08
294 #define RF69_REG_09_FRFLSB 0x09
295 #define RF69_REG_0A_OSC1 0x0a
296 #define RF69_REG_0B_AFCCTRL 0x0b
297 #define RF69_REG_0C_RESERVED 0x0c
298 #define RF69_REG_0D_LISTEN1 0x0d
299 #define RF69_REG_0E_LISTEN2 0x0e
300 #define RF69_REG_0F_LISTEN3 0x0f
301 #define RF69_REG_10_VERSION 0x10
302 #define RF69_REG_11_PALEVEL 0x11
303 #define RF69_REG_12_PARAMP 0x12
304 #define RF69_REG_13_OCP 0x13
305 #define RF69_REG_14_RESERVED 0x14
306 #define RF69_REG_15_RESERVED 0x15
307 #define RF69_REG_16_RESERVED 0x16
308 #define RF69_REG_17_RESERVED 0x17
309 #define RF69_REG_18_LNA 0x18
310 #define RF69_REG_19_RXBW 0x19
311 #define RF69_REG_1A_AFCBW 0x1a
312 #define RF69_REG_1B_OOKPEAK 0x1b
313 #define RF69_REG_1C_OOKAVG 0x1c
314 #define RF69_REG_1D_OOKFIX 0x1d
315 #define RF69_REG_1E_AFCFEI 0x1e
316 #define RF69_REG_1F_AFCMSB 0x1f
317 #define RF69_REG_20_AFCLSB 0x20
318 #define RF69_REG_21_FEIMSB 0x21
319 #define RF69_REG_22_FEILSB 0x22
320 #define RF69_REG_23_RSSICONFIG 0x23
321 #define RF69_REG_24_RSSIVALUE 0x24
322 #define RF69_REG_25_DIOMAPPING1 0x25
323 #define RF69_REG_26_DIOMAPPING2 0x26
324 #define RF69_REG_27_IRQFLAGS1 0x27
325 #define RF69_REG_28_IRQFLAGS2 0x28
326 #define RF69_REG_29_RSSITHRESH 0x29
327 #define RF69_REG_2A_RXTIMEOUT1 0x2a
328 #define RF69_REG_2B_RXTIMEOUT2 0x2b
329 #define RF69_REG_2C_PREAMBLEMSB 0x2c
330 #define RF69_REG_2D_PREAMBLELSB 0x2d
331 #define RF69_REG_2E_SYNCCONFIG 0x2e
332 #define RF69_REG_2F_SYNCVALUE1 0x2f
333 // another 7 sync word bytes follow, 30 through 36 inclusive
334 #define RF69_REG_37_PACKETCONFIG1 0x37
335 #define RF69_REG_38_PAYLOADLENGTH 0x38
336 #define RF69_REG_39_NODEADRS 0x39
337 #define RF69_REG_3A_BROADCASTADRS 0x3a
338 #define RF69_REG_3B_AUTOMODES 0x3b
339 #define RF69_REG_3C_FIFOTHRESH 0x3c
340 #define RF69_REG_3D_PACKETCONFIG2 0x3d
341 #define RF69_REG_3E_AESKEY1 0x3e
342 // Another 15 AES key bytes follow
343 #define RF69_REG_4E_TEMP1 0x4e
344 #define RF69_REG_4F_TEMP2 0x4f
345 #define RF69_REG_58_TESTLNA 0x58
346 #define RF69_REG_5A_TESTPA1 0x5a
347 #define RF69_REG_5C_TSETPA2 0x5c
348 #define RF69_REG_6F_TESTDAGC 0x6f
349 #define RF69_REG_71_TESTAFC 0x71
350 
351 // These register masks etc are named wherever possible
352 // corresponding to the bit and field names in the RFM69 Manual
353 
354 // RF69_REG_01_OPMODE
355 #define RF69_OPMODE_SEQUENCEROFF 0x80
356 #define RF69_OPMODE_LISTENON 0x40
357 #define RF69_OPMODE_LISTENABORT 0x20
358 #define RF69_OPMODE_MODE 0x1c
359 #define RF69_OPMODE_MODE_SLEEP 0x00
360 #define RF69_OPMODE_MODE_STDBY 0x04
361 #define RF69_OPMODE_MODE_FS 0x08
362 #define RF69_OPMODE_MODE_TX 0x0c
363 #define RF69_OPMODE_MODE_RX 0x10
364 
365 // RF69_REG_02_DATAMODUL
366 #define RF69_DATAMODUL_DATAMODE 0x60
367 #define RF69_DATAMODUL_DATAMODE_PACKET 0x00
368 #define RF69_DATAMODUL_DATAMODE_CONT_WITH_SYNC 0x40
369 #define RF69_DATAMODUL_DATAMODE_CONT_WITHOUT_SYNC 0x60
370 #define RF69_DATAMODUL_MODULATIONTYPE 0x18
371 #define RF69_DATAMODUL_MODULATIONTYPE_FSK 0x00
372 #define RF69_DATAMODUL_MODULATIONTYPE_OOK 0x08
373 #define RF69_DATAMODUL_MODULATIONSHAPING 0x03
374 #define RF69_DATAMODUL_MODULATIONSHAPING_FSK_NONE 0x00
375 #define RF69_DATAMODUL_MODULATIONSHAPING_FSK_BT1_0 0x01
376 #define RF69_DATAMODUL_MODULATIONSHAPING_FSK_BT0_5 0x02
377 #define RF69_DATAMODUL_MODULATIONSHAPING_FSK_BT0_3 0x03
378 #define RF69_DATAMODUL_MODULATIONSHAPING_OOK_NONE 0x00
379 #define RF69_DATAMODUL_MODULATIONSHAPING_OOK_BR 0x01
380 #define RF69_DATAMODUL_MODULATIONSHAPING_OOK_2BR 0x02
381 
382 // RF69_REG_11_PALEVEL
383 #define RF69_PALEVEL_PA0ON 0x80
384 #define RF69_PALEVEL_PA1ON 0x40
385 #define RF69_PALEVEL_PA2ON 0x20
386 #define RF69_PALEVEL_OUTPUTPOWER 0x1f
387 
388 // RF69_REG_23_RSSICONFIG
389 #define RF69_RSSICONFIG_RSSIDONE 0x02
390 #define RF69_RSSICONFIG_RSSISTART 0x01
391 
392 // RF69_REG_25_DIOMAPPING1
393 #define RF69_DIOMAPPING1_DIO0MAPPING 0xc0
394 #define RF69_DIOMAPPING1_DIO0MAPPING_00 0x00
395 #define RF69_DIOMAPPING1_DIO0MAPPING_01 0x40
396 #define RF69_DIOMAPPING1_DIO0MAPPING_10 0x80
397 #define RF69_DIOMAPPING1_DIO0MAPPING_11 0xc0
398 
399 #define RF69_DIOMAPPING1_DIO1MAPPING 0x30
400 #define RF69_DIOMAPPING1_DIO1MAPPING_00 0x00
401 #define RF69_DIOMAPPING1_DIO1MAPPING_01 0x10
402 #define RF69_DIOMAPPING1_DIO1MAPPING_10 0x20
403 #define RF69_DIOMAPPING1_DIO1MAPPING_11 0x30
404 
405 #define RF69_DIOMAPPING1_DIO2MAPPING 0x0c
406 #define RF69_DIOMAPPING1_DIO2MAPPING_00 0x00
407 #define RF69_DIOMAPPING1_DIO2MAPPING_01 0x04
408 #define RF69_DIOMAPPING1_DIO2MAPPING_10 0x08
409 #define RF69_DIOMAPPING1_DIO2MAPPING_11 0x0c
410 
411 #define RF69_DIOMAPPING1_DIO3MAPPING 0x03
412 #define RF69_DIOMAPPING1_DIO3MAPPING_00 0x00
413 #define RF69_DIOMAPPING1_DIO3MAPPING_01 0x01
414 #define RF69_DIOMAPPING1_DIO3MAPPING_10 0x02
415 #define RF69_DIOMAPPING1_DIO3MAPPING_11 0x03
416 
417 // RF69_REG_26_DIOMAPPING2
418 #define RF69_DIOMAPPING2_DIO4MAPPING 0xc0
419 #define RF69_DIOMAPPING2_DIO4MAPPING_00 0x00
420 #define RF69_DIOMAPPING2_DIO4MAPPING_01 0x40
421 #define RF69_DIOMAPPING2_DIO4MAPPING_10 0x80
422 #define RF69_DIOMAPPING2_DIO4MAPPING_11 0xc0
423 
424 #define RF69_DIOMAPPING2_DIO5MAPPING 0x30
425 #define RF69_DIOMAPPING2_DIO5MAPPING_00 0x00
426 #define RF69_DIOMAPPING2_DIO5MAPPING_01 0x10
427 #define RF69_DIOMAPPING2_DIO5MAPPING_10 0x20
428 #define RF69_DIOMAPPING2_DIO5MAPPING_11 0x30
429 
430 #define RF69_DIOMAPPING2_CLKOUT 0x07
431 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_ 0x00
432 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_2 0x01
433 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_4 0x02
434 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_8 0x03
435 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_16 0x04
436 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_32 0x05
437 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_RC 0x06
438 #define RF69_DIOMAPPING2_CLKOUT_FXOSC_OFF 0x07
439 
440 // RF69_REG_27_IRQFLAGS1
441 #define RF69_IRQFLAGS1_MODEREADY 0x80
442 #define RF69_IRQFLAGS1_RXREADY 0x40
443 #define RF69_IRQFLAGS1_TXREADY 0x20
444 #define RF69_IRQFLAGS1_PLLLOCK 0x10
445 #define RF69_IRQFLAGS1_RSSI 0x08
446 #define RF69_IRQFLAGS1_TIMEOUT 0x04
447 #define RF69_IRQFLAGS1_AUTOMODE 0x02
448 #define RF69_IRQFLAGS1_SYNADDRESSMATCH 0x01
449 
450 // RF69_REG_28_IRQFLAGS2
451 #define RF69_IRQFLAGS2_FIFOFULL 0x80
452 #define RF69_IRQFLAGS2_FIFONOTEMPTY 0x40
453 #define RF69_IRQFLAGS2_FIFOLEVEL 0x20
454 #define RF69_IRQFLAGS2_FIFOOVERRUN 0x10
455 #define RF69_IRQFLAGS2_PACKETSENT 0x08
456 #define RF69_IRQFLAGS2_PAYLOADREADY 0x04
457 #define RF69_IRQFLAGS2_CRCOK 0x02
458 
459 // RF69_REG_2E_SYNCCONFIG
460 #define RF69_SYNCCONFIG_SYNCON 0x80
461 #define RF69_SYNCCONFIG_FIFOFILLCONDITION_MANUAL 0x40
462 #define RF69_SYNCCONFIG_SYNCSIZE 0x38
463 #define RF69_SYNCCONFIG_SYNCSIZE_1 0x00
464 #define RF69_SYNCCONFIG_SYNCSIZE_2 0x08
465 #define RF69_SYNCCONFIG_SYNCSIZE_3 0x10
466 #define RF69_SYNCCONFIG_SYNCSIZE_4 0x18
467 #define RF69_SYNCCONFIG_SYNCSIZE_5 0x20
468 #define RF69_SYNCCONFIG_SYNCSIZE_6 0x28
469 #define RF69_SYNCCONFIG_SYNCSIZE_7 0x30
470 #define RF69_SYNCCONFIG_SYNCSIZE_8 0x38
471 #define RF69_SYNCCONFIG_SYNCSIZE_SYNCTOL 0x07
472 
473 // RF69_REG_37_PACKETCONFIG1
474 #define RF69_PACKETCONFIG1_PACKETFORMAT_VARIABLE 0x80
475 #define RF69_PACKETCONFIG1_DCFREE 0x60
476 #define RF69_PACKETCONFIG1_DCFREE_NONE 0x00
477 #define RF69_PACKETCONFIG1_DCFREE_MANCHESTER 0x20
478 #define RF69_PACKETCONFIG1_DCFREE_WHITENING 0x40
479 #define RF69_PACKETCONFIG1_DCFREE_RESERVED 0x60
480 #define RF69_PACKETCONFIG1_CRC_ON 0x10
481 #define RF69_PACKETCONFIG1_CRCAUTOCLEAROFF 0x08
482 #define RF69_PACKETCONFIG1_ADDRESSFILTERING 0x06
483 #define RF69_PACKETCONFIG1_ADDRESSFILTERING_NONE 0x00
484 #define RF69_PACKETCONFIG1_ADDRESSFILTERING_NODE 0x02
485 #define RF69_PACKETCONFIG1_ADDRESSFILTERING_NODE_BC 0x04
486 #define RF69_PACKETCONFIG1_ADDRESSFILTERING_RESERVED 0x06
487 
488 // RF69_REG_3C_FIFOTHRESH
489 #define RF69_FIFOTHRESH_TXSTARTCONDITION_NOTEMPTY 0x80
490 #define RF69_FIFOTHRESH_FIFOTHRESHOLD 0x7f
491 
492 // RF69_REG_3D_PACKETCONFIG2
493 #define RF69_PACKETCONFIG2_INTERPACKETRXDELAY 0xf0
494 #define RF69_PACKETCONFIG2_RESTARTRX 0x04
495 #define RF69_PACKETCONFIG2_AUTORXRESTARTON 0x02
496 #define RF69_PACKETCONFIG2_AESON 0x01
497 
498 // RF69_REG_4E_TEMP1
499 #define RF69_TEMP1_TEMPMEASSTART 0x08
500 #define RF69_TEMP1_TEMPMEASRUNNING 0x04
501 
502 // RF69_REG_6F_TESTDAGC
503 #define RF69_TESTDAGC_CONTINUOUSDAGC_NORMAL 0x00
504 #define RF69_TESTDAGC_CONTINUOUSDAGC_IMPROVED_LOWBETAON 0x20
505 #define RF69_TESTDAGC_CONTINUOUSDAGC_IMPROVED_LOWBETAOFF 0x30
506 
507 // Define this to include Serial printing in diagnostic routines
508 #define RF69_HAVE_SERIAL
509 
510 #include <GenericSPI.h>
511 #include <HardwareSPI.h>
512 
513 /////////////////////////////////////////////////////////////////////
514 /// \class RF69 RF69.h <RF69.h>
515 /// \brief Send and receive unaddressed, unreliable datagrams.
516 ///
517 /// This base class provides basic functions for sending and receiving unaddressed,
518 /// unreliable datagrams of arbitrary length to 64 octets per packet.
519 ///
520 /// Subclasses may use this class to implement reliable, addressed datagrams and streams,
521 /// mesh routers, repeaters, translators etc.
522 ///
523 /// Naturally, for any 2 radios to communicate that must be configured to use the same frequency and
524 /// modulation scheme.
525 class RF69
526 {
527 public:
528 
529  /// \brief Defines register values for a set of modem configuration registers
530  ///
531  /// Defines register values for a set of modem configuration registers
532  /// that can be passed to setModemRegisters() if none of the choices in
533  /// ModemConfigChoice suit your need setModemRegisters() writes the
534  /// register values from this structure to the appropriate RF69 registers
535  /// to set the desired modulation type, data rate and deviation/bandwidth.
536  typedef struct
537  {
538  uint8_t reg_02; ///< Value for register RF69_REG_02_DATAMODUL
539  uint8_t reg_03; ///< Value for register RF69_REG_03_BITRATEMSB
540  uint8_t reg_04; ///< Value for register RF69_REG_04_BITRATELSB
541  uint8_t reg_05; ///< Value for register RF69_REG_05_FDEVMSB
542  uint8_t reg_06; ///< Value for register RF69_REG_06_FDEVLSB
543  uint8_t reg_19; ///< Value for register RF69_REG_19_RXBW
544  uint8_t reg_37; ///< Value for register RF69_REG_37_PACKETCONFIG1
545  } ModemConfig;
546 
547  /// Choices for setModemConfig() for a selected subset of common
548  /// modulation types, and data rates. If you need another configuration,
549  /// use the register calculator. and call setModemRegisters() with your
550  /// desired settings.
551  /// These are indexes into MODEM_CONFIG_TABLE
552  typedef enum
553  {
554  FSK_Rb2Fd5 = 0, ///< FSK, No Manchester, Rb = 2kbs, Fd = 5kHz
555  FSK_Rb2_4Fd2_4, ///< FSK, No Manchester, Rb = 2.4kbs, Fd = 2.4kHz
556  FSK_Rb4_8Fd4_8, ///< FSK, No Manchester, Rb = 4.8kbs, Fd = 4.8kHz
557  FSK_Rb9_6Fd9_6, ///< FSK, No Manchester, Rb = 9.6kbs, Fd = 9.6kHz
558  FSK_Rb19_2Fd19_2, ///< FSK, No Manchester, Rb = 19.2kbs, Fd = 19.2kHz
559  FSK_Rb38_4Fd38_4, ///< FSK, No Manchester, Rb = 38.4kbs, Fd = 38.4kHz
560  FSK_Rb57_6Fd120, ///< FSK, No Manchester, Rb = 57.6kbs, Fd = 120kHz
561  FSK_Rb125Fd125, ///< FSK, No Manchester, Rb = 125kbs, Fd = 125kHz
562  FSK_Rb250Fd250, ///< FSK, No Manchester, Rb = 250kbs, Fd = 250kHz
563  FSK_Rb55555Fd50, ///< FSK, No Manchester, Rb = 55555kbs,Fd = 50kHz for RFM69 lib compatibility
564  FSK_Rb_512Fd2_5, ///< FSK, No Manchester, Rb = 512bs, Fd = 2.5kHz for POCSAG compatibility
565 
566  GFSK_Rb2Fd5, ///< GFSK, No Manchester, Rb = 2kbs, Fd = 5kHz
567  GFSK_Rb2_4Fd2_4, ///< GFSK, No Manchester, Rb = 2.4kbs, Fd = 2.4kHz
568  GFSK_Rb4_8Fd4_8, ///< GFSK, No Manchester, Rb = 4.8kbs, Fd = 4.8kHz
569  GFSK_Rb9_6Fd9_6, ///< GFSK, No Manchester, Rb = 9.6kbs, Fd = 9.6kHz
570  GFSK_Rb19_2Fd19_2, ///< GFSK, No Manchester, Rb = 19.2kbs, Fd = 19.2kHz
571  GFSK_Rb38_4Fd38_4, ///< GFSK, No Manchester, Rb = 38.4kbs, Fd = 38.4kHz
572  GFSK_Rb57_6Fd120, ///< GFSK, No Manchester, Rb = 57.6kbs, Fd = 120kHz
573  GFSK_Rb125Fd125, ///< GFSK, No Manchester, Rb = 125kbs, Fd = 125kHz
574  GFSK_Rb250Fd250, ///< GFSK, No Manchester, Rb = 250kbs, Fd = 250kHz
575  GFSK_Rb55555Fd50, ///< GFSK, No Manchester, Rb = 55555kbs,Fd = 50kHz
576 
577 // OOK_Rb1_2Bw75, ///< OOK, No Manchester, Rb = 1.2kbs, Rx Bandwidth = 75kHz. Not reliable: do not use
578 
580 
581  /// Constructor. You can have multiple instances, but each instance must have its own
582  /// interrupt and slave select pin. After constructing, you must call init() to initialise the interface
583  /// and the radio module
584  /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RF69 before
585  /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega)
586  /// \param[in] interrupt The interrupt number to use. 0 - 2. Default is interrupt 0 (Usually Arduino input pin 2)
587  /// \param[in] spi Pointer to the SPI interface object to use.
588  /// Defaults to the standard Arduino hardware SPI interface
589  RF69(uint8_t slaveSelectPin = SS, uint8_t interrupt = 0, GenericSPIClass *spi = &Hardware_spi);
590 
591  /// Initialises this instance and the radio module connected to it.
592  /// The following steps are taken:
593  /// - Initialise the slave select pin and the SPI interface library
594  /// - Software reset the RF69 module
595  /// - Checks the connected RF69 module can be communicated
596  /// - Attaches an interrupt handler
597  /// - Configures the RF69 module
598  /// - Sets the frequency to 434.0 MHz
599  /// - Sets the modem data rate to FSK_Rb2Fd5
600  /// \return true if everything was successful
601  boolean init();
602 
603  /// Issues a software reset to the
604  /// RF69 module. Blocks for 1ms to ensure the reset is complete.
605  void reset();
606 
607  /// Reads a single register from the RF69
608  /// \param[in] reg Register number, one of RF69_REG_*
609  /// \return The value of the register
610  uint8_t spiRead(uint8_t reg);
611 
612  /// Writes a single byte to the RF69
613  /// \param[in] reg Register number, one of RF69_REG_*
614  /// \param[in] val The value to write
615  void spiWrite(uint8_t reg, uint8_t val);
616 
617  /// Reads a number of consecutive registers from the RF69 using burst read mode
618  /// \param[in] reg Register number of the first register, one of RF69_REG_*
619  /// \param[in] dest Array to write the register values to. Must be at least len bytes
620  /// \param[in] len Number of bytes to read
621  void spiBurstRead(uint8_t reg, uint8_t* dest, uint8_t len);
622 
623  /// Write a number of consecutive registers using burst write mode
624  /// \param[in] reg Register number of the first register, one of RF69_REG_*
625  /// \param[in] src Array of new register values to write. Must be at least len bytes
626  /// \param[in] len Number of bytes to write
627  void spiBurstWrite(uint8_t reg, const uint8_t* src, uint8_t len);
628 
629  /// Reads the on-chip temperature sensor.
630  /// The RF69 must be in Idle mode (= RF69 Standby) to measure temperature.
631  /// The measurement is uncalibrated and without calibration, you can expectit to be far from
632  /// correct.
633  /// \return The measured temperature, in degrees C from -40 to 85 (uncalibrated)
634  int8_t temperatureRead();
635 
636  /// Sets the transmitter and receiver
637  /// centre frequency
638  /// \param[in] centre Frequency in MHz. 240.0 to 960.0. Caution, RF69 comes in several
639  /// different frequency ranges, and setting a frequency outside that range of your radio will probably not work
640  /// \param[in] afcPullInRange Not used
641  /// \return true if the selected frquency centre is within range
642  boolean setFrequency(float centre, float afcPullInRange = 0.05);
643 
644  /// Reads and returns the current RSSI value.
645  /// Causes the current signal strength to be measured and returned
646  /// If you want to find the RSSI
647  /// of the last received message, use lastRssi() instead.
648  /// \return The current RSSI value on units of 0.5dB.
649  int8_t rssiRead();
650 
651  /// Sets the parameters for the RF69 OPMODE.
652  /// This is a low level device access funciton, and should not normally ned to be used by user code.
653  /// Instead can use stModeRx(), setModeTx(), setModeIdle()
654  /// \param[in] mode RF69 OPMODE to set, one of RF69_OPMODE_MODE_*.
655  void setMode(uint8_t mode);
656 
657  /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running,
658  /// disables them.
659  void setModeIdle();
660 
661  /// If current mode is Tx or Idle, changes it to Rx.
662  /// Starts the receiver in the RF69.
663  void setModeRx();
664 
665  /// If current mode is Rx or Idle, changes it to Rx. F
666  /// Starts the transmitter in the RF69.
667  void setModeTx();
668 
669  /// Returns the operating mode of the library.
670  /// \return the current mode, one of RF69_MODE_*
671  uint8_t mode();
672 
673  /// Sets the transmitter power output level.
674  /// Be a good neighbour and set the lowest power level you need.
675  /// Caution: legal power limits may apply in certain countries.
676  /// After init(), the power will be set to 13dBm.
677  /// \param[in] power Transmitter power level in dBm from -18dBm to +13dB (higher powers may
678  /// be available depending on which version of RF69 radio you have).
679  void setTxPower(int8_t power);
680 
681  /// Sets all the registered required to configure the data modem in the RF69, including the data rate,
682  /// bandwidths etc. You cas use this to configure the modem with custom configurations if none of the
683  /// canned configurations in ModemConfigChoice suit you.
684  /// \param[in] config A ModemConfig structure containing values for the modem configuration registers.
685  void setModemRegisters(const ModemConfig* config);
686 
687  /// Select one of the predefined modem configurations. If you need a modem configuration not provided
688  /// here, use setModemRegisters() with your own ModemConfig.
689  /// \param[in] index The configuration choice.
690  /// \return true if index is a valid choice.
691  boolean setModemConfig(ModemConfigChoice index);
692 
693  /// Starts the receiver and checks whether a received message is available.
694  /// This can be called multiple times in a timeout loop
695  /// \return true if a complete, valid message has been received and is able to be retrieved by
696  /// recv()
697  boolean available();
698 
699  /// Starts the receiver and blocks until a valid received
700  /// message is available.
701  void waitAvailable();
702 
703  /// Starts the receiver and blocks until a received message is available or a timeout
704  /// \param[in] timeout Maximum time to wait in milliseconds.
705  /// \return true if a message is available
706  bool waitAvailableTimeout(uint16_t timeout);
707 
708  /// Sets the address of this node. Defaults to 0xFF. Subclasses or the user may want to change this.
709  /// This will be used to test the adddress in incoming messages. In non-promiscuous mode,
710  /// only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted.
711  /// In promiscuous mode, all messages will be accepted regardless of the TO header.
712  /// In a conventional multinode system, all nodes will have a unique address
713  /// (which you could store in EEPROM).
714  /// You would normally set the header FROM address to be the same as thisAddress (though you dont have to,
715  /// allowing the possibilty of address spoofing).
716  /// \param[in] thisAddress The address of this node.
717  void setThisAddress(uint8_t thisAddress);
718 
719  /// Turns the receiver on if it not already on.
720  /// If there is a valid message available, copy it to buf and return true
721  /// else return false.
722  /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
723  /// You should be sure to call this function frequently enough to not miss any messages
724  /// It is recommended that you call it in your main loop.
725  /// \param[in] buf Location to copy the received message
726  /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
727  /// \return true if a valid message was copied to buf
728  boolean recv(uint8_t* buf, uint8_t* len);
729 
730  /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
731  /// Then loads a message into the transmitter and starts the transmitter. Note that a message length
732  /// of 0 is NOT permitted.
733  /// \param[in] data Array of data to be sent
734  /// \param[in] len Number of bytes of data to send (> 0)
735  /// \return true if the message length was valid and it was correctly queued for transmit
736  boolean send(const uint8_t* data, uint8_t len);
737 
738  /// Blocks until the RF69 is not in mode RF69_MODE_TX (ie until the RF69 is not transmitting).
739  /// This effectively waits until any previous transmit packet is finished being transmitted.
740  void waitPacketSent();
741 
742  /// Blocks until the RF69 is not in mode RF69_MODE_TX (ie until the RF69 is not transmitting)
743  /// or until the timeout occuers, whichever happens first
744  /// \param[in] timeout Maximum time to wait in milliseconds.
745  /// \return true if the RF69 is not transmitting any more
746  bool waitPacketSent(uint16_t timeout);
747 
748  /// Tells the receiver to accept messages with any TO address, not just messages
749  /// addressed to thisAddress or the broadcast address
750  /// \param[in] promiscuous true if you wish to receive messages with any TO address
751  void setPromiscuous(boolean promiscuous);
752 
753  /// Returns the TO header of the last received message
754  /// \return The TO header
755  uint8_t headerTo();
756 
757  /// Returns the FROM header of the last received message
758  /// \return The FROM header
759  uint8_t headerFrom();
760 
761  /// Returns the ID header of the last received message
762  /// \return The ID header
763  uint8_t headerId();
764 
765  /// Returns the FLAGS header of the last received message
766  /// \return The FLAGS header
767  uint8_t headerFlags();
768 
769  /// Returns the most recent RSSI (Receiver Signal Strength Indicator).
770  /// Usually it is the RSSI of the last received message, which is measured when the preamble is received.
771  /// If you called readRssi() more recently, it will return that more recent value.
772  /// \return The most recent RSSI measurement in dBm.
773  int8_t lastRssi();
774 
775  /// Prints a data buffer in HEX.
776  /// For diagnostic use
777  /// \param[in] prompt string to preface the print
778  /// \param[in] buf Location of the buffer to print
779  /// \param[in] len Length of the buffer in octets.
780  static void printBuffer(const char* prompt, const uint8_t* buf, uint8_t len);
781 
782  /// Sets the length of the preamble
783  /// in bytes.
784  /// Caution: this should be set to the same
785  /// value on all nodes in your network. Default is 4.
786  /// Sets the message preamble length in REG_0?_PREAMBLE?SB
787  /// \param[in] bytes Preamble length in bytes.
788  void setPreambleLength(uint16_t bytes);
789 
790  /// Sets the sync words for transmit and receive
791  /// Caution: SyncWords should be set to the same
792  /// value on all nodes in your network. Nodes with different SyncWords set will never receive
793  /// each others messages, so different SyncWords can be used to isolate different
794  /// networks from each other. Default is { 0x2d, 0xd4 }.
795  /// \param[in] syncWords Array of sync words, 1 to 4 octets long. NULL if no sync words to be used.
796  /// \param[in] len Number of sync words to set, 1 to 4. 0 if no sync words to be used.
797  void setSyncWords(const uint8_t* syncWords = NULL, uint8_t len = 0);
798 
799  /// Enables AES encryption and sets the AES encryption key, used
800  /// to encrypt and decrypt all messages. The default is disabled.
801  /// \param[in] key The key to use. Must be 16 bytes long. The same key must be installed
802  /// in other instances of RF69, otherwise communications will not work correctly. If key is NULL,
803  /// encryption is disabled.
804  void setEncryptionKey(uint8_t* key = NULL);
805 
806 protected:
807  /// This is a low level function to handle the interrupts for one instance of RF69.
808  /// Called automatically by isr*()
809  /// Should not need to be called by user code.
810  void handleInterrupt();
811 
812  /// Low level function to read the FIFO and put the received data into the receive buffer
813  /// Should not need to be called by user code.
814  void readFifo();
815 
816  /// Sets the TO header to be sent in all subsequent messages
817  /// \param[in] to The new TO header value
818  void setHeaderTo(uint8_t to);
819 
820  /// Sets the FROM header to be sent in all subsequent messages
821  /// \param[in] from The new FROM header value
822  void setHeaderFrom(uint8_t from);
823 
824  /// Sets the ID header to be sent in all subsequent messages
825  /// \param[in] id The new ID header value
826  void setHeaderId(uint8_t id);
827 
828  /// Sets the FLAGS header to be sent in all subsequent messages
829  /// \param[in] flags The new FLAGS header value
830  void setHeaderFlags(uint8_t flags);
831 
832 protected:
833  GenericSPIClass* _spi;
834 
835  /// Low level interrupt service routine for RF69 connected to interrupt 0
836  static void isr0();
837 
838  /// Low level interrupt service routine for RF69 connected to interrupt 1
839  static void isr1();
840 
841  /// Low level interrupt service routine for RF69 connected to interrupt 1
842  static void isr2();
843 
844  /// Array of instances connected to interrupts 0 and 1
846 
847  volatile uint8_t _mode; // One of RF69_MODE_*
848 
849  uint8_t _idleMode; // The radio mode to use when mode is RF69_MODE_IDLE
850  uint8_t _slaveSelectPin;
851  uint8_t _interrupt;
852  uint8_t _deviceType;
853 
854  // These volatile members may get changed in the interrupt service routine
855  volatile uint8_t _bufLen;
856  uint8_t _buf[RF69_MAX_MESSAGE_LEN];
857 
858  // This node id
859  uint8_t _thisAddress;
860  boolean _promiscuous;
861 
862  // Headers of last received message
863  uint8_t _rxHeaderTo;
864  uint8_t _rxHeaderFrom;
865  uint8_t _rxHeaderId;
866  uint8_t _rxHeaderFlags;
867 
868  // Headers of next to transmit message
869  uint8_t _txHeaderTo;
870  uint8_t _txHeaderFrom;
871  uint8_t _txHeaderId;
872  uint8_t _txHeaderFlags;
873 
874  volatile boolean _rxBufValid;
875 
876  volatile boolean _txPacketSent;
877 
878  volatile uint16_t _rxBad;
879  volatile uint16_t _rxGood;
880  volatile uint16_t _txGood;
881 
882  volatile int8_t _lastRssi;
883 };
884 
885 /// @example rf69_client.ino
886 /// Example sketch showing how to create a simple messageing client
887 /// with the RF69 class. RF69 class does not provide for addressing or reliability.
888 /// It is designed to work with the example rf69_server.
889 /// Demonstrates the use of AES encrpyion.
890 
891 /// @example rf69_server.ino
892 /// Example sketch showing how to create a simple messageing server
893 /// with the RF69 class. RF69 class does not provide for addressing or reliability.
894 /// It is designed to work with the example rf69_client
895 /// Demonstrates the use of AES encrpyion.
896 
897 
898 #endif
uint8_t mode()
Definition: RF69.cpp:376
void setHeaderFlags(uint8_t flags)
Definition: RF69.cpp:584
void setPromiscuous(boolean promiscuous)
Definition: RF69.cpp:609
boolean init()
Definition: RF69.cpp:84
void setMode(uint8_t mode)
Definition: RF69.cpp:335
FSK, No Manchester, Rb = 19.2kbs, Fd = 19.2kHz.
Definition: RF69.h:558
void readFifo()
Definition: RF69.cpp:202
void setHeaderFrom(uint8_t from)
Definition: RF69.cpp:574
void waitAvailable()
Definition: RF69.cpp:473
boolean setModemConfig(ModemConfigChoice index)
Definition: RF69.cpp:420
void setSyncWords(const uint8_t *syncWords=NULL, uint8_t len=0)
Definition: RF69.cpp:438
boolean send(const uint8_t *data, uint8_t len)
Definition: RF69.cpp:542
FSK, No Manchester, Rb = 250kbs, Fd = 250kHz.
Definition: RF69.h:562
Defines register values for a set of modem configuration registers.
Definition: RF69.h:536
uint8_t reg_19
Value for register RF69_REG_19_RXBW.
Definition: RF69.h:543
uint8_t reg_03
Value for register RF69_REG_03_BITRATEMSB.
Definition: RF69.h:539
static void isr1()
Low level interrupt service routine for RF69 connected to interrupt 1.
Definition: RF69.cpp:240
void setThisAddress(uint8_t thisAddress)
static void printBuffer(const char *prompt, const uint8_t *buf, uint8_t len)
Definition: RF69.cpp:507
void spiBurstRead(uint8_t reg, uint8_t *dest, uint8_t len)
Definition: RF69.cpp:279
GFSK, No Manchester, Rb = 38.4kbs, Fd = 38.4kHz.
Definition: RF69.h:571
GFSK, No Manchester, Rb = 55555kbs,Fd = 50kHz.
Definition: RF69.h:575
boolean recv(uint8_t *buf, uint8_t *len)
Definition: RF69.cpp:527
void setModeRx()
Definition: RF69.cpp:356
uint8_t headerFlags()
Definition: RF69.cpp:604
void waitPacketSent()
Definition: RF69.cpp:491
uint8_t reg_05
Value for register RF69_REG_05_FDEVMSB.
Definition: RF69.h:541
void setModeIdle()
Definition: RF69.cpp:347
FSK, No Manchester, Rb = 125kbs, Fd = 125kHz.
Definition: RF69.h:561
RF69(uint8_t slaveSelectPin=SS, uint8_t interrupt=0, GenericSPIClass *spi=&Hardware_spi)
Definition: RF69.cpp:67
void spiWrite(uint8_t reg, uint8_t val)
Definition: RF69.cpp:269
static void isr2()
Low level interrupt service routine for RF69 connected to interrupt 1.
Definition: RF69.cpp:245
GFSK, No Manchester, Rb = 2.4kbs, Fd = 2.4kHz.
Definition: RF69.h:567
boolean setFrequency(float centre, float afcPullInRange=0.05)
Definition: RF69.cpp:311
FSK, No Manchester, Rb = 57.6kbs, Fd = 120kHz.
Definition: RF69.h:560
uint8_t spiRead(uint8_t reg)
Definition: RF69.cpp:256
Base class for SPI interfaces.
Definition: GenericSPI.h:28
void setHeaderId(uint8_t id)
Definition: RF69.cpp:579
void setModeTx()
Definition: RF69.cpp:366
uint8_t headerId()
Definition: RF69.cpp:599
uint8_t reg_37
Value for register RF69_REG_37_PACKETCONFIG1.
Definition: RF69.h:544
FSK, No Manchester, Rb = 4.8kbs, Fd = 4.8kHz.
Definition: RF69.h:556
static void isr0()
Low level interrupt service routine for RF69 connected to interrupt 0.
Definition: RF69.cpp:235
GFSK, No Manchester, Rb = 19.2kbs, Fd = 19.2kHz.
Definition: RF69.h:570
FSK, No Manchester, Rb = 512bs, Fd = 2.5kHz for POCSAG compatibility.
Definition: RF69.h:564
uint8_t reg_04
Value for register RF69_REG_04_BITRATELSB.
Definition: RF69.h:540
void setModemRegisters(const ModemConfig *config)
Definition: RF69.cpp:411
int8_t lastRssi()
Definition: RF69.cpp:614
FSK, No Manchester, Rb = 55555kbs,Fd = 50kHz for RFM69 lib compatibility.
Definition: RF69.h:563
GFSK, No Manchester, Rb = 9.6kbs, Fd = 9.6kHz.
Definition: RF69.h:569
void setEncryptionKey(uint8_t *key=NULL)
Definition: RF69.cpp:453
int8_t rssiRead()
Definition: RF69.cpp:323
GFSK, No Manchester, Rb = 125kbs, Fd = 125kHz.
Definition: RF69.h:573
boolean available()
Definition: RF69.cpp:466
bool waitAvailableTimeout(uint16_t timeout)
Definition: RF69.cpp:482
void reset()
Definition: RF69.cpp:251
uint8_t headerTo()
Definition: RF69.cpp:589
static RF69 * _RF69ForInterrupt[]
Array of instances connected to interrupts 0 and 1.
Definition: RF69.h:845
GFSK, No Manchester, Rb = 250kbs, Fd = 250kHz.
Definition: RF69.h:574
FSK, No Manchester, Rb = 2kbs, Fd = 5kHz.
Definition: RF69.h:554
void setTxPower(int8_t power)
Definition: RF69.cpp:381
FSK, No Manchester, Rb = 2.4kbs, Fd = 2.4kHz.
Definition: RF69.h:555
void setPreambleLength(uint16_t bytes)
Definition: RF69.cpp:432
GFSK, No Manchester, Rb = 2kbs, Fd = 5kHz.
Definition: RF69.h:566
FSK, No Manchester, Rb = 9.6kbs, Fd = 9.6kHz.
Definition: RF69.h:557
ModemConfigChoice
Definition: RF69.h:552
uint8_t reg_02
Value for register RF69_REG_02_DATAMODUL.
Definition: RF69.h:538
uint8_t headerFrom()
Definition: RF69.cpp:594
uint8_t reg_06
Value for register RF69_REG_06_FDEVLSB.
Definition: RF69.h:542
Send and receive unaddressed, unreliable datagrams.
Definition: RF69.h:525
GFSK, No Manchester, Rb = 57.6kbs, Fd = 120kHz.
Definition: RF69.h:572
GFSK, No Manchester, Rb = 4.8kbs, Fd = 4.8kHz.
Definition: RF69.h:568
void spiBurstWrite(uint8_t reg, const uint8_t *src, uint8_t len)
Definition: RF69.cpp:290
FSK, No Manchester, Rb = 38.4kbs, Fd = 38.4kHz.
Definition: RF69.h:559
void handleInterrupt()
Definition: RF69.cpp:174
void setHeaderTo(uint8_t to)
Definition: RF69.cpp:569
int8_t temperatureRead()
Definition: RF69.cpp:301