RadioHead
RH_RF22.h
1 // RH_RF22.h
2 // Author: Mike McCauley (mikem@airspayce.com)
3 // Copyright (C) 2011 Mike McCauley
4 // $Id: RH_RF22.h,v 1.36 2020/01/07 23:35:02 mikem Exp mikem $
5 //
6 
7 #ifndef RH_RF22_h
8 #define RH_RF22_h
9 
10 #include <RHGenericSPI.h>
11 #include <RHSPIDriver.h>
12 
13 // This is the maximum number of interrupts the library can support
14 // Most Arduinos can handle 2, Megas can handle more
15 #define RH_RF22_NUM_INTERRUPTS 3
16 
17 // This is the bit in the SPI address that marks it as a write
18 #define RH_RF22_SPI_WRITE_MASK 0x80
19 
20 // This is the maximum message length that can be supported by this library. Limited by
21 // the single message length octet in the header.
22 // Yes, 255 is correct even though the FIFO size in the RF22 is only
23 // 64 octets. We use interrupts to refill the Tx FIFO during transmission and to empty the
24 // Rx FIFO during reception
25 // Can be pre-defined to a smaller size (to save SRAM) prior to including this header
26 #ifndef RH_RF22_MAX_MESSAGE_LEN
27 //#define RH_RF22_MAX_MESSAGE_LEN 255
28 #define RH_RF22_MAX_MESSAGE_LEN 50
29 #endif
30 
31 // Max number of octets the RF22 Rx and Tx FIFOs can hold
32 #define RH_RF22_FIFO_SIZE 64
33 
34 // These values we set for FIFO thresholds (4, 55) are actually the same as the POR values
35 #define RH_RF22_TXFFAEM_THRESHOLD 4
36 #define RH_RF22_RXFFAFULL_THRESHOLD 55
37 
38 // Number of registers to be passed to setModemConfig(). Obsolete.
39 #define RH_RF22_NUM_MODEM_CONFIG_REGS 18
40 
41 // Register names
42 #define RH_RF22_REG_00_DEVICE_TYPE 0x00
43 #define RH_RF22_REG_01_VERSION_CODE 0x01
44 #define RH_RF22_REG_02_DEVICE_STATUS 0x02
45 #define RH_RF22_REG_03_INTERRUPT_STATUS1 0x03
46 #define RH_RF22_REG_04_INTERRUPT_STATUS2 0x04
47 #define RH_RF22_REG_05_INTERRUPT_ENABLE1 0x05
48 #define RH_RF22_REG_06_INTERRUPT_ENABLE2 0x06
49 #define RH_RF22_REG_07_OPERATING_MODE1 0x07
50 #define RH_RF22_REG_08_OPERATING_MODE2 0x08
51 #define RH_RF22_REG_09_OSCILLATOR_LOAD_CAPACITANCE 0x09
52 #define RH_RF22_REG_0A_UC_OUTPUT_CLOCK 0x0a
53 #define RH_RF22_REG_0B_GPIO_CONFIGURATION0 0x0b
54 #define RH_RF22_REG_0C_GPIO_CONFIGURATION1 0x0c
55 #define RH_RF22_REG_0D_GPIO_CONFIGURATION2 0x0d
56 #define RH_RF22_REG_0E_IO_PORT_CONFIGURATION 0x0e
57 #define RH_RF22_REG_0F_ADC_CONFIGURATION 0x0f
58 #define RH_RF22_REG_10_ADC_SENSOR_AMP_OFFSET 0x10
59 #define RH_RF22_REG_11_ADC_VALUE 0x11
60 #define RH_RF22_REG_12_TEMPERATURE_SENSOR_CALIBRATION 0x12
61 #define RH_RF22_REG_13_TEMPERATURE_VALUE_OFFSET 0x13
62 #define RH_RF22_REG_14_WAKEUP_TIMER_PERIOD1 0x14
63 #define RH_RF22_REG_15_WAKEUP_TIMER_PERIOD2 0x15
64 #define RH_RF22_REG_16_WAKEUP_TIMER_PERIOD3 0x16
65 #define RH_RF22_REG_17_WAKEUP_TIMER_VALUE1 0x17
66 #define RH_RF22_REG_18_WAKEUP_TIMER_VALUE2 0x18
67 #define RH_RF22_REG_19_LDC_MODE_DURATION 0x19
68 #define RH_RF22_REG_1A_LOW_BATTERY_DETECTOR_THRESHOLD 0x1a
69 #define RH_RF22_REG_1B_BATTERY_VOLTAGE_LEVEL 0x1b
70 #define RH_RF22_REG_1C_IF_FILTER_BANDWIDTH 0x1c
71 #define RH_RF22_REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE 0x1d
72 #define RH_RF22_REG_1E_AFC_TIMING_CONTROL 0x1e
73 #define RH_RF22_REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE 0x1f
74 #define RH_RF22_REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE 0x20
75 #define RH_RF22_REG_21_CLOCK_RECOVERY_OFFSET2 0x21
76 #define RH_RF22_REG_22_CLOCK_RECOVERY_OFFSET1 0x22
77 #define RH_RF22_REG_23_CLOCK_RECOVERY_OFFSET0 0x23
78 #define RH_RF22_REG_24_CLOCK_RECOVERY_TIMING_LOOP_GAIN1 0x24
79 #define RH_RF22_REG_25_CLOCK_RECOVERY_TIMING_LOOP_GAIN0 0x25
80 #define RH_RF22_REG_26_RSSI 0x26
81 #define RH_RF22_REG_27_RSSI_THRESHOLD 0x27
82 #define RH_RF22_REG_28_ANTENNA_DIVERSITY1 0x28
83 #define RH_RF22_REG_29_ANTENNA_DIVERSITY2 0x29
84 #define RH_RF22_REG_2A_AFC_LIMITER 0x2a
85 #define RH_RF22_REG_2B_AFC_CORRECTION_READ 0x2b
86 #define RH_RF22_REG_2C_OOK_COUNTER_VALUE_1 0x2c
87 #define RH_RF22_REG_2D_OOK_COUNTER_VALUE_2 0x2d
88 #define RH_RF22_REG_2E_SLICER_PEAK_HOLD 0x2e
89 #define RH_RF22_REG_30_DATA_ACCESS_CONTROL 0x30
90 #define RH_RF22_REG_31_EZMAC_STATUS 0x31
91 #define RH_RF22_REG_32_HEADER_CONTROL1 0x32
92 #define RH_RF22_REG_33_HEADER_CONTROL2 0x33
93 #define RH_RF22_REG_34_PREAMBLE_LENGTH 0x34
94 #define RH_RF22_REG_35_PREAMBLE_DETECTION_CONTROL1 0x35
95 #define RH_RF22_REG_36_SYNC_WORD3 0x36
96 #define RH_RF22_REG_37_SYNC_WORD2 0x37
97 #define RH_RF22_REG_38_SYNC_WORD1 0x38
98 #define RH_RF22_REG_39_SYNC_WORD0 0x39
99 #define RH_RF22_REG_3A_TRANSMIT_HEADER3 0x3a
100 #define RH_RF22_REG_3B_TRANSMIT_HEADER2 0x3b
101 #define RH_RF22_REG_3C_TRANSMIT_HEADER1 0x3c
102 #define RH_RF22_REG_3D_TRANSMIT_HEADER0 0x3d
103 #define RH_RF22_REG_3E_PACKET_LENGTH 0x3e
104 #define RH_RF22_REG_3F_CHECK_HEADER3 0x3f
105 #define RH_RF22_REG_40_CHECK_HEADER2 0x40
106 #define RH_RF22_REG_41_CHECK_HEADER1 0x41
107 #define RH_RF22_REG_42_CHECK_HEADER0 0x42
108 #define RH_RF22_REG_43_HEADER_ENABLE3 0x43
109 #define RH_RF22_REG_44_HEADER_ENABLE2 0x44
110 #define RH_RF22_REG_45_HEADER_ENABLE1 0x45
111 #define RH_RF22_REG_46_HEADER_ENABLE0 0x46
112 #define RH_RF22_REG_47_RECEIVED_HEADER3 0x47
113 #define RH_RF22_REG_48_RECEIVED_HEADER2 0x48
114 #define RH_RF22_REG_49_RECEIVED_HEADER1 0x49
115 #define RH_RF22_REG_4A_RECEIVED_HEADER0 0x4a
116 #define RH_RF22_REG_4B_RECEIVED_PACKET_LENGTH 0x4b
117 #define RH_RF22_REG_50_ANALOG_TEST_BUS_SELECT 0x50
118 #define RH_RF22_REG_51_DIGITAL_TEST_BUS_SELECT 0x51
119 #define RH_RF22_REG_52_TX_RAMP_CONTROL 0x52
120 #define RH_RF22_REG_53_PLL_TUNE_TIME 0x53
121 #define RH_RF22_REG_55_CALIBRATION_CONTROL 0x55
122 #define RH_RF22_REG_56_MODEM_TEST 0x56
123 #define RH_RF22_REG_57_CHARGE_PUMP_TEST 0x57
124 #define RH_RF22_REG_58_CHARGE_PUMP_CURRENT_TRIMMING 0x58
125 #define RH_RF22_REG_59_DIVIDER_CURRENT_TRIMMING 0x59
126 #define RH_RF22_REG_5A_VCO_CURRENT_TRIMMING 0x5a
127 #define RH_RF22_REG_5B_VCO_CALIBRATION 0x5b
128 #define RH_RF22_REG_5C_SYNTHESIZER_TEST 0x5c
129 #define RH_RF22_REG_5D_BLOCK_ENABLE_OVERRIDE1 0x5d
130 #define RH_RF22_REG_5E_BLOCK_ENABLE_OVERRIDE2 0x5e
131 #define RH_RF22_REG_5F_BLOCK_ENABLE_OVERRIDE3 0x5f
132 #define RH_RF22_REG_60_CHANNEL_FILTER_COEFFICIENT_ADDRESS 0x60
133 #define RH_RF22_REG_61_CHANNEL_FILTER_COEFFICIENT_VALUE 0x61
134 #define RH_RF22_REG_62_CRYSTAL_OSCILLATOR_POR_CONTROL 0x62
135 #define RH_RF22_REG_63_RC_OSCILLATOR_COARSE_CALIBRATION 0x63
136 #define RH_RF22_REG_64_RC_OSCILLATOR_FINE_CALIBRATION 0x64
137 #define RH_RF22_REG_65_LDO_CONTROL_OVERRIDE 0x65
138 #define RH_RF22_REG_66_LDO_LEVEL_SETTINGS 0x66
139 #define RH_RF22_REG_67_DELTA_SIGMA_ADC_TUNING1 0x67
140 #define RH_RF22_REG_68_DELTA_SIGMA_ADC_TUNING2 0x68
141 #define RH_RF22_REG_69_AGC_OVERRIDE1 0x69
142 #define RH_RF22_REG_6A_AGC_OVERRIDE2 0x6a
143 #define RH_RF22_REG_6B_GFSK_FIR_FILTER_COEFFICIENT_ADDRESS 0x6b
144 #define RH_RF22_REG_6C_GFSK_FIR_FILTER_COEFFICIENT_VALUE 0x6c
145 #define RH_RF22_REG_6D_TX_POWER 0x6d
146 #define RH_RF22_REG_6E_TX_DATA_RATE1 0x6e
147 #define RH_RF22_REG_6F_TX_DATA_RATE0 0x6f
148 #define RH_RF22_REG_70_MODULATION_CONTROL1 0x70
149 #define RH_RF22_REG_71_MODULATION_CONTROL2 0x71
150 #define RH_RF22_REG_72_FREQUENCY_DEVIATION 0x72
151 #define RH_RF22_REG_73_FREQUENCY_OFFSET1 0x73
152 #define RH_RF22_REG_74_FREQUENCY_OFFSET2 0x74
153 #define RH_RF22_REG_75_FREQUENCY_BAND_SELECT 0x75
154 #define RH_RF22_REG_76_NOMINAL_CARRIER_FREQUENCY1 0x76
155 #define RH_RF22_REG_77_NOMINAL_CARRIER_FREQUENCY0 0x77
156 #define RH_RF22_REG_79_FREQUENCY_HOPPING_CHANNEL_SELECT 0x79
157 #define RH_RF22_REG_7A_FREQUENCY_HOPPING_STEP_SIZE 0x7a
158 #define RH_RF22_REG_7C_TX_FIFO_CONTROL1 0x7c
159 #define RH_RF22_REG_7D_TX_FIFO_CONTROL2 0x7d
160 #define RH_RF22_REG_7E_RX_FIFO_CONTROL 0x7e
161 #define RH_RF22_REG_7F_FIFO_ACCESS 0x7f
162 
163 // These register masks etc are named wherever possible
164 // corresponding to the bit and field names in the RF-22 Manual
165 // RH_RF22_REG_00_DEVICE_TYPE 0x00
166 #define RH_RF22_DEVICE_TYPE_RX_TRX 0x08
167 #define RH_RF22_DEVICE_TYPE_TX 0x07
168 
169 // RH_RF22_REG_02_DEVICE_STATUS 0x02
170 #define RH_RF22_FFOVL 0x80
171 #define RH_RF22_FFUNFL 0x40
172 #define RH_RF22_RXFFEM 0x20
173 #define RH_RF22_HEADERR 0x10
174 #define RH_RF22_FREQERR 0x08
175 #define RH_RF22_LOCKDET 0x04
176 #define RH_RF22_CPS 0x03
177 #define RH_RF22_CPS_IDLE 0x00
178 #define RH_RF22_CPS_RX 0x01
179 #define RH_RF22_CPS_TX 0x10
180 
181 // RH_RF22_REG_03_INTERRUPT_STATUS1 0x03
182 #define RH_RF22_IFFERROR 0x80
183 #define RH_RF22_ITXFFAFULL 0x40
184 #define RH_RF22_ITXFFAEM 0x20
185 #define RH_RF22_IRXFFAFULL 0x10
186 #define RH_RF22_IEXT 0x08
187 #define RH_RF22_IPKSENT 0x04
188 #define RH_RF22_IPKVALID 0x02
189 #define RH_RF22_ICRCERROR 0x01
190 
191 // RH_RF22_REG_04_INTERRUPT_STATUS2 0x04
192 #define RH_RF22_ISWDET 0x80
193 #define RH_RF22_IPREAVAL 0x40
194 #define RH_RF22_IPREAINVAL 0x20
195 #define RH_RF22_IRSSI 0x10
196 #define RH_RF22_IWUT 0x08
197 #define RH_RF22_ILBD 0x04
198 #define RH_RF22_ICHIPRDY 0x02
199 #define RH_RF22_IPOR 0x01
200 
201 // RH_RF22_REG_05_INTERRUPT_ENABLE1 0x05
202 #define RH_RF22_ENFFERR 0x80
203 #define RH_RF22_ENTXFFAFULL 0x40
204 #define RH_RF22_ENTXFFAEM 0x20
205 #define RH_RF22_ENRXFFAFULL 0x10
206 #define RH_RF22_ENEXT 0x08
207 #define RH_RF22_ENPKSENT 0x04
208 #define RH_RF22_ENPKVALID 0x02
209 #define RH_RF22_ENCRCERROR 0x01
210 
211 // RH_RF22_REG_06_INTERRUPT_ENABLE2 0x06
212 #define RH_RF22_ENSWDET 0x80
213 #define RH_RF22_ENPREAVAL 0x40
214 #define RH_RF22_ENPREAINVAL 0x20
215 #define RH_RF22_ENRSSI 0x10
216 #define RH_RF22_ENWUT 0x08
217 #define RH_RF22_ENLBDI 0x04
218 #define RH_RF22_ENCHIPRDY 0x02
219 #define RH_RF22_ENPOR 0x01
220 
221 // RH_RF22_REG_07_OPERATING_MODE 0x07
222 #define RH_RF22_SWRES 0x80
223 #define RH_RF22_ENLBD 0x40
224 #define RH_RF22_ENWT 0x20
225 #define RH_RF22_X32KSEL 0x10
226 #define RH_RF22_TXON 0x08
227 #define RH_RF22_RXON 0x04
228 #define RH_RF22_PLLON 0x02
229 #define RH_RF22_XTON 0x01
230 
231 // RH_RF22_REG_08_OPERATING_MODE2 0x08
232 #define RH_RF22_ANTDIV 0xc0
233 #define RH_RF22_RXMPK 0x10
234 #define RH_RF22_AUTOTX 0x08
235 #define RH_RF22_ENLDM 0x04
236 #define RH_RF22_FFCLRRX 0x02
237 #define RH_RF22_FFCLRTX 0x01
238 
239 // RH_RF22_REG_0F_ADC_CONFIGURATION 0x0f
240 #define RH_RF22_ADCSTART 0x80
241 #define RH_RF22_ADCDONE 0x80
242 #define RH_RF22_ADCSEL 0x70
243 #define RH_RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR 0x00
244 #define RH_RF22_ADCSEL_GPIO0_SINGLE_ENDED 0x10
245 #define RH_RF22_ADCSEL_GPIO1_SINGLE_ENDED 0x20
246 #define RH_RF22_ADCSEL_GPIO2_SINGLE_ENDED 0x30
247 #define RH_RF22_ADCSEL_GPIO0_GPIO1_DIFFERENTIAL 0x40
248 #define RH_RF22_ADCSEL_GPIO1_GPIO2_DIFFERENTIAL 0x50
249 #define RH_RF22_ADCSEL_GPIO0_GPIO2_DIFFERENTIAL 0x60
250 #define RH_RF22_ADCSEL_GND 0x70
251 #define RH_RF22_ADCREF 0x0c
252 #define RH_RF22_ADCREF_BANDGAP_VOLTAGE 0x00
253 #define RH_RF22_ADCREF_VDD_ON_3 0x08
254 #define RH_RF22_ADCREF_VDD_ON_2 0x0c
255 #define RH_RF22_ADCGAIN 0x03
256 
257 // RH_RF22_REG_10_ADC_SENSOR_AMP_OFFSET 0x10
258 #define RH_RF22_ADCOFFS 0x0f
259 
260 // RH_RF22_REG_12_TEMPERATURE_SENSOR_CALIBRATION 0x12
261 #define RH_RF22_TSRANGE 0xc0
262 #define RH_RF22_TSRANGE_M64_64C 0x00
263 #define RH_RF22_TSRANGE_M64_192C 0x40
264 #define RH_RF22_TSRANGE_0_128C 0x80
265 #define RH_RF22_TSRANGE_M40_216F 0xc0
266 #define RH_RF22_ENTSOFFS 0x20
267 #define RH_RF22_ENTSTRIM 0x10
268 #define RH_RF22_TSTRIM 0x0f
269 
270 // RH_RF22_REG_14_WAKEUP_TIMER_PERIOD1 0x14
271 #define RH_RF22_WTR 0x3c
272 #define RH_RF22_WTD 0x03
273 
274 // RH_RF22_REG_1D_AFC_LOOP_GEARSHIFT_OVERRIDE 0x1d
275 #define RH_RF22_AFBCD 0x80
276 #define RH_RF22_ENAFC 0x40
277 #define RH_RF22_AFCGEARH 0x38
278 #define RH_RF22_AFCGEARL 0x07
279 
280 // RH_RF22_REG_1E_AFC_TIMING_CONTROL 0x1e
281 #define RH_RF22_SWAIT_TIMER 0xc0
282 #define RH_RF22_SHWAIT 0x38
283 #define RH_RF22_ANWAIT 0x07
284 
285 // RH_RF22_REG_30_DATA_ACCESS_CONTROL 0x30
286 #define RH_RF22_ENPACRX 0x80
287 #define RH_RF22_MSBFRST 0x00
288 #define RH_RF22_LSBFRST 0x40
289 #define RH_RF22_CRCHDRS 0x00
290 #define RH_RF22_CRCDONLY 0x20
291 #define RH_RF22_SKIP2PH 0x10
292 #define RH_RF22_ENPACTX 0x08
293 #define RH_RF22_ENCRC 0x04
294 #define RH_RF22_CRC 0x03
295 #define RH_RF22_CRC_CCITT 0x00
296 #define RH_RF22_CRC_CRC_16_IBM 0x01
297 #define RH_RF22_CRC_IEC_16 0x02
298 #define RH_RF22_CRC_BIACHEVA 0x03
299 
300 // RH_RF22_REG_32_HEADER_CONTROL1 0x32
301 #define RH_RF22_BCEN 0xf0
302 #define RH_RF22_BCEN_NONE 0x00
303 #define RH_RF22_BCEN_HEADER0 0x10
304 #define RH_RF22_BCEN_HEADER1 0x20
305 #define RH_RF22_BCEN_HEADER2 0x40
306 #define RH_RF22_BCEN_HEADER3 0x80
307 #define RH_RF22_HDCH 0x0f
308 #define RH_RF22_HDCH_NONE 0x00
309 #define RH_RF22_HDCH_HEADER0 0x01
310 #define RH_RF22_HDCH_HEADER1 0x02
311 #define RH_RF22_HDCH_HEADER2 0x04
312 #define RH_RF22_HDCH_HEADER3 0x08
313 
314 // RH_RF22_REG_33_HEADER_CONTROL2 0x33
315 #define RH_RF22_HDLEN 0x70
316 #define RH_RF22_HDLEN_0 0x00
317 #define RH_RF22_HDLEN_1 0x10
318 #define RH_RF22_HDLEN_2 0x20
319 #define RH_RF22_HDLEN_3 0x30
320 #define RH_RF22_HDLEN_4 0x40
321 #define RH_RF22_VARPKLEN 0x00
322 #define RH_RF22_FIXPKLEN 0x08
323 #define RH_RF22_SYNCLEN 0x06
324 #define RH_RF22_SYNCLEN_1 0x00
325 #define RH_RF22_SYNCLEN_2 0x02
326 #define RH_RF22_SYNCLEN_3 0x04
327 #define RH_RF22_SYNCLEN_4 0x06
328 #define RH_RF22_PREALEN8 0x01
329 
330 // RH_RF22_REG_6D_TX_POWER 0x6d
331 // https://www.sparkfun.com/datasheets/Wireless/General/RFM22B.pdf
332 #define RH_RF22_PAPEAKVAL 0x80
333 #define RH_RF22_PAPEAKEN 0x40
334 #define RH_RF22_PAPEAKLVL 0x30
335 #define RH_RF22_PAPEAKLVL6_5 0x00
336 #define RH_RF22_PAPEAKLVL7 0x10
337 #define RH_RF22_PAPEAKLVL7_5 0x20
338 #define RH_RF22_PAPEAKLVL8 0x30
339 #define RH_RF22_LNA_SW 0x08
340 #define RH_RF22_TXPOW 0x07
341 #define RH_RF22_TXPOW_4X31 0x08 // Not used in RFM22B
342 // For RFM22B:
343 #define RH_RF22_TXPOW_1DBM 0x00
344 #define RH_RF22_TXPOW_2DBM 0x01
345 #define RH_RF22_TXPOW_5DBM 0x02
346 #define RH_RF22_TXPOW_8DBM 0x03
347 #define RH_RF22_TXPOW_11DBM 0x04
348 #define RH_RF22_TXPOW_14DBM 0x05
349 #define RH_RF22_TXPOW_17DBM 0x06
350 #define RH_RF22_TXPOW_20DBM 0x07
351 // RFM23B only:
352 #define RH_RF22_RF23B_TXPOW_M8DBM 0x00 // -8dBm
353 #define RH_RF22_RF23B_TXPOW_M5DBM 0x01 // -5dBm
354 #define RH_RF22_RF23B_TXPOW_M2DBM 0x02 // -2dBm
355 #define RH_RF22_RF23B_TXPOW_1DBM 0x03 // 1dBm
356 #define RH_RF22_RF23B_TXPOW_4DBM 0x04 // 4dBm
357 #define RH_RF22_RF23B_TXPOW_7DBM 0x05 // 7dBm
358 #define RH_RF22_RF23B_TXPOW_10DBM 0x06 // 10dBm
359 #define RH_RF22_RF23B_TXPOW_13DBM 0x07 // 13dBm
360 // RFM23BP only:
361 #define RH_RF22_RF23BP_TXPOW_28DBM 0x05 // 28dBm
362 #define RH_RF22_RF23BP_TXPOW_29DBM 0x06 // 29dBm
363 #define RH_RF22_RF23BP_TXPOW_30DBM 0x07 // 30dBm
364 
365 // RH_RF22_REG_71_MODULATION_CONTROL2 0x71
366 #define RH_RF22_TRCLK 0xc0
367 #define RH_RF22_TRCLK_NONE 0x00
368 #define RH_RF22_TRCLK_GPIO 0x40
369 #define RH_RF22_TRCLK_SDO 0x80
370 #define RH_RF22_TRCLK_NIRQ 0xc0
371 #define RH_RF22_DTMOD 0x30
372 #define RH_RF22_DTMOD_DIRECT_GPIO 0x00
373 #define RH_RF22_DTMOD_DIRECT_SDI 0x10
374 #define RH_RF22_DTMOD_FIFO 0x20
375 #define RH_RF22_DTMOD_PN9 0x30
376 #define RH_RF22_ENINV 0x08
377 #define RH_RF22_FD8 0x04
378 #define RH_RF22_MODTYP 0x30
379 #define RH_RF22_MODTYP_UNMODULATED 0x00
380 #define RH_RF22_MODTYP_OOK 0x01
381 #define RH_RF22_MODTYP_FSK 0x02
382 #define RH_RF22_MODTYP_GFSK 0x03
383 
384 
385 // RH_RF22_REG_75_FREQUENCY_BAND_SELECT 0x75
386 #define RH_RF22_SBSEL 0x40
387 #define RH_RF22_HBSEL 0x20
388 #define RH_RF22_FB 0x1f
389 
390 // Define this to include Serial printing in diagnostic routines
391 #define RH_RF22_HAVE_SERIAL
392 
393 /////////////////////////////////////////////////////////////////////
394 /// \class RH_RF22 RH_RF22.h <RH_RF22.h>
395 /// \brief Driver to send and receive unaddressed, unreliable datagrams via an RF22 and compatible radio transceiver.
396 ///
397 /// Works with RF22, RF23 based radio modules, and compatible chips and modules, including:
398 /// - RF22 bare module: http://www.sparkfun.com/products/10153
399 /// (Caution, that is a 3.3V part, and requires a 3.3V CPU such as Teensy etc or level shifters)
400 /// - RF22 shield: http://www.sparkfun.com/products/11018
401 /// - RF22 integrated board http://www.anarduino.com/miniwireless
402 /// - RFM23BP bare module: http://www.anarduino.com/details.jsp?pid=130
403 /// - Silicon Labs Si4430/31/32 based modules. S4432 is equivalent to RF22. Si4431/30 is equivalent to RF23.
404 ///
405 /// Data based on https://www.sparkfun.com/datasheets/Wireless/General/RFM22B.pdf
406 ///
407 /// \par Overview
408 ///
409 /// This base class provides basic functions for sending and receiving unaddressed,
410 /// unreliable datagrams of arbitrary length to 255 octets per packet.
411 ///
412 /// Manager classes may use this class to implement reliable, addressed datagrams and streams,
413 /// mesh routers, repeaters, translators etc.
414 ///
415 /// On transmission, the TO and FROM addresses default to 0x00, unless changed by a subclass.
416 /// On reception the TO addressed is checked against the node address (defaults to 0x00) or the
417 /// broadcast address (which is 0xff). The ID and FLAGS are set to 0, and not checked by this class.
418 /// This permits use of the this base RH_RF22 class as an
419 /// unaddressed, unreliable datagram service without the use of one the RadioHead Manager classes.
420 ///
421 /// Naturally, for any 2 radios to communicate that must be configured to use the same frequency and
422 /// modulation scheme.
423 ///
424 /// \par Details
425 ///
426 /// This Driver provides an object-oriented interface for sending and receiving data messages with Hope-RF
427 /// RF22 and RF23 based radio modules, and compatible chips and modules,
428 /// including the RFM22B transceiver module such as
429 /// this bare module: http://www.sparkfun.com/products/10153
430 /// and this shield: http://www.sparkfun.com/products/11018
431 /// and this module: http://www.hoperfusa.com/details.jsp?pid=131
432 /// and this integrated board: http://www.anarduino.com/miniwireless
433 /// and RF23BP modules such as this http://www.anarduino.com/details.jsp?pid=130
434 ///
435 /// The Hope-RF (http://www.hoperf.com) RFM22B (http://www.hoperf.com/rf_fsk/fsk/RFM22B.htm)
436 /// is a low-cost ISM transceiver module. It supports FSK, GFSK, OOK over a wide
437 /// range of frequencies and programmable data rates.
438 /// Manual can be found at https://www.sparkfun.com/datasheets/Wireless/General/RFM22.PDF
439 ///
440 /// This library provides functions for sending and receiving messages of up to 255 octets on any
441 /// frequency supported by the RF22B, in a range of predefined data rates and frequency deviations.
442 /// Frequency can be set with 312Hz precision to any frequency from 240.0MHz to 960.0MHz.
443 ///
444 /// Up to 3 RF22B modules can be connected to an Arduino, permitting the construction of translators
445 /// and frequency changers, etc.
446 ///
447 /// The following modulation types are suppported with a range of modem configurations for
448 /// common data rates and frequency deviations:
449 /// - GFSK Gaussian Frequency Shift Keying
450 /// - FSK Frequency Shift Keying
451 /// - OOK On-Off Keying
452 ///
453 /// Support for other RF22B features such as on-chip temperature measurement, analog-digital
454 /// converter, transmitter power control etc is also provided.
455 ///
456 /// Tested on Arduino Diecimila, Uno and Mega with arduino-0021, 1.0.5
457 /// on OpenSuSE 13.1 and avr-libc-1.6.1-1.15,
458 /// cross-avr-binutils-2.19-9.1, cross-avr-gcc-4.1.3_20080612-26.5.
459 /// With HopeRF RFM22 modules that appear to have RF22B chips on board:
460 /// - Device Type Code = 0x08 (RX/TRX)
461 /// - Version Code = 0x06
462 /// Works on Duo. Works with Sparkfun RFM22 Wireless shields. Works with RFM22 modules from http://www.hoperfusa.com/
463 /// Works with Arduino 1.0 to at least 1.0.5. Works on Maple, Flymaple, Uno32 (with ChipKIT Core with Arduino IDE).
464 ///
465 /// \par Packet Format
466 ///
467 /// All messages sent and received by this Driver must conform to this packet format:
468 ///
469 /// - 8 nibbles (4 octets) PREAMBLE
470 /// - 2 octets SYNC 0x2d, 0xd4
471 /// - 4 octets HEADER: (TO, FROM, ID, FLAGS)
472 /// - 1 octet LENGTH (0 to 255), number of octets in DATA
473 /// - 0 to 255 octets DATA
474 /// - 2 octets CRC computed with CRC16(IBM), computed on HEADER, LENGTH and DATA
475 ///
476 /// For technical reasons, the message format is not protocol compatible with the
477 /// 'HopeRF Radio Transceiver Message Library for Arduino' http://www.airspayce.com/mikem/arduino/HopeRF from the same author. Nor is it compatible with
478 /// 'Virtual Wire' http://www.airspayce.com/mikem/arduino/VirtualWire.pdf also from the same author.
479 ///
480 /// \par Connecting RFM-22 to Arduino
481 ///
482 /// If you have the Sparkfun RFM22 Shield (https://www.sparkfun.com/products/11018)
483 /// the connections described below are done for you on the shield, no changes required,
484 /// just add headers and plug it in to an Arduino (but not and Arduino Mega, see below)
485 ///
486 /// The physical connection between the RF22B and the Arduino requires 3.3V,
487 /// the 3 x SPI pins (SCK, SDI, SDO), a Slave Select pin and an interrupt pin.
488 ///
489 /// Note: some devices may need a pullup resister on the SDO line.
490 ///
491 /// Note also that on the RFM22B (but not the RFM23B), it is required to control the TX_ANT and
492 /// RX_ANT pins of the RFM22 in order to control the antenna connection properly. The RH_RF22
493 /// driver is configured by default so that GPIO0 and GPIO1 outputs can
494 /// control TX_ANT and RX_ANT input pins respectively automatically. On RFM22,
495 /// you must connect GPIO0
496 /// to TX_ANT and GPIO1 to RX_ANT for this automatic antenna switching to
497 /// occur. See setGpioReversed() for more details. These connections are not required on RFM23B.
498 ///
499 /// If you are using the Sparkfun RF22 shield, it will work with any 5V arduino without modification.
500 /// Connect the RFM-22 module to most Arduino's like this (Caution, Arduino Mega has different pins for SPI,
501 /// see below).
502 /// \code
503 /// Arduino RFM-22B
504 /// GND----------GND-\ (ground in)
505 /// SDN-/ (shutdown in)
506 /// 3V3----------VCC (3.3V in)
507 /// interrupt 0 pin D2-----------NIRQ (interrupt request out)
508 /// SS pin D10----------NSEL (chip select in)
509 /// SCK pin D13----------SCK (SPI clock in)
510 /// MOSI pin D11----------SDI (SPI Data in)
511 /// MISO pin D12----------SDO (SPI data out)
512 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
513 /// \--TX_ANT (TX antenna control in) RFM22B only
514 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
515 /// \--RX_ANT (RX antenna control in) RFM22B only
516 /// \endcode
517 /// For an Arduino Mega:
518 /// \code
519 /// Mega RFM-22B
520 /// GND----------GND-\ (ground in)
521 /// SDN-/ (shutdown in)
522 /// 3V3----------VCC (3.3V in)
523 /// interrupt 0 pin D2-----------NIRQ (interrupt request out)
524 /// SS pin D53----------NSEL (chip select in)
525 /// SCK pin D52----------SCK (SPI clock in)
526 /// MOSI pin D51----------SDI (SPI Data in)
527 /// MISO pin D50----------SDO (SPI data out)
528 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
529 /// \--TX_ANT (TX antenna control in) RFM22B only
530 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
531 /// \--RX_ANT (RX antenna control in) RFM22B only
532 /// \endcode
533 /// For Chipkit Uno32. Caution: you must also ensure jumper JP4 on the Uno32 is set to RD4
534 /// \code
535 /// Arduino RFM-22B
536 /// GND----------GND-\ (ground in)
537 /// SDN-/ (shutdown in)
538 /// 3V3----------VCC (3.3V in)
539 /// interrupt 0 pin D38----------NIRQ (interrupt request out)
540 /// SS pin D10----------NSEL (chip select in)
541 /// SCK pin D13----------SCK (SPI clock in)
542 /// MOSI pin D11----------SDI (SPI Data in)
543 /// MISO pin D12----------SDO (SPI data out)
544 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
545 /// \--TX_ANT (TX antenna control in) RFM22B only
546 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
547 /// \--RX_ANT (RX antenna control in) RFM22B only
548 /// \endcode
549 /// For Teensy 3.1
550 /// \code
551 /// Teensy RFM-22B
552 /// GND----------GND-\ (ground in)
553 /// SDN-/ (shutdown in)
554 /// 3V3----------VCC (3.3V in)
555 /// interrupt 2 pin D2-----------NIRQ (interrupt request out)
556 /// SS pin D10----------NSEL (chip select in)
557 /// SCK pin D13----------SCK (SPI clock in)
558 /// MOSI pin D11----------SDI (SPI Data in)
559 /// MISO pin D12----------SDO (SPI data out)
560 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
561 /// \--TX_ANT (TX antenna control in) RFM22B only
562 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
563 /// \--RX_ANT (RX antenna control in) RFM22B only
564 /// \endcode
565 /// For an Arduino Due (the SPI pins do not come out on the Digital pins as for normal Arduino, but only
566 /// appear on the SPI header)
567 /// \code
568 /// Due RFM-22B
569 /// GND----------GND-\ (ground in)
570 /// SDN-/ (shutdown in)
571 /// 5V-----------VCC (5V in)
572 /// interrupt 0 pin D2-----------NIRQ (interrupt request out)
573 /// SS pin D10----------NSEL (chip select in)
574 /// SCK SPI pin 3----------SCK (SPI clock in)
575 /// MOSI SPI pin 4----------SDI (SPI Data in)
576 /// MISO SPI pin 1----------SDO (SPI data out)
577 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
578 /// \--TX_ANT (TX antenna control in) RFM22B only
579 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
580 /// \--RX_ANT (RX antenna control in) RFM22B only
581 /// \endcode
582 /// and use the default constructor:
583 /// RH_RF22 driver;
584 /// For connecting an Arduino to an RFM23BP module. Note that the antenna control pins are reversed
585 /// compared to the RF22.
586 /// \code
587 /// Arduino RFM-23BP
588 /// GND----------GND-\ (ground in)
589 /// SDN-/ (shutdown in)
590 /// 5V-----------VCC (5V in)
591 /// interrupt 0 pin D2-----------NIRQ (interrupt request out)
592 /// SS pin D10----------NSEL (chip select in)
593 /// SCK pin D13----------SCK (SPI clock in)
594 /// MOSI pin D11----------SDI (SPI Data in)
595 /// MISO pin D12----------SDO (SPI data out)
596 /// /--GPIO0 (GPIO0 out to control receiver antenna RXON)
597 /// \--RXON (RX antenna control in)
598 /// /--GPIO1 (GPIO1 out to control transmitter antenna TXON)
599 /// \--TXON (TX antenna control in)
600 /// \endcode
601 ///
602 /// and you can then use the default constructor RH_RF22().
603 /// You can override the default settings for the SS pin and the interrupt
604 /// in the RH_RF22 constructor if you wish to connect the slave select SS to other than the normal one for your
605 /// Arduino (D10 for Diecimila, Uno etc and D53 for Mega)
606 /// or the interrupt request to other than pin D2 (Caution, different processors have different constraints as to the
607 /// pins available for interrupts).
608 ///
609 /// Caution: some people have had problems with some batches of
610 /// RFM23BP chips burning out their nIRQ outputs for unknown
611 /// reasons when run at 5V. Some users assert that running RFM23BP with voltage
612 /// dividers at 3.3V is to be preferred. We have not tested or verified
613 /// either the cause or the supposed cure.
614 //
615 ///
616 /// If you have an Arduino Zero, you should note that you cannot use Pin 2 for the interrupt line
617 /// (Pin 2 is for the NMI only), instead you can use any other pin (we use Pin 3) and initialise RH_RF69 like this:
618 /// \code
619 /// // Slave Select is pin 10, interrupt is Pin 3
620 /// RH_RF22 driver(10, 3);
621 /// \endcode
622 ///
623 /// If you have an ESP32 (we tested with the Geekworm EASY-KIT ESP32-B1 which has a ESP-WROOM-32 chip)
624 /// \code
625 /// ESP32 RFM-22B
626 /// GND----------GND-\ (ground in)
627 /// SDN-/ (shutdown in)
628 /// 3V3----------VCC (3.3V in)
629 /// interrupt pin GPIO15-------NIRQ (interrupt request out)
630 /// SS pin GPIO13-------NSEL (chip select in)
631 /// SCK pin GPIO18-------SCK (SPI clock in)
632 /// MOSI pin GPIO23-------SDI (SPI Data in)
633 /// MISO pin GPIO19-------SDO (SPI data out)
634 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
635 /// \--TX_ANT (TX antenna control in) RFM22B only
636 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
637 /// \--RX_ANT (RX antenna control in) RFM22B only
638 /// \endcode
639 /// and initialise like this:
640 /// \code
641 /// RH_RF22 driver(13, 15);
642 /// \endcode
643 /// You can of course use other pins for NSEL and NIRQ if you prefer.
644 ///
645 /// To connect an STM32 F4 Discovery board to RF22 using Arduino and Arduino_STM32
646 /// connect the pins like this:
647 /// \code
648 /// STM32 RFM-22B
649 /// GND----------GND-\ (ground in)
650 /// SDN-/ (shutdown in)
651 /// VDD----------VCC (3.3V in)
652 /// interrupt pin PB1----------NIRQ (interrupt request out)
653 /// SS pin PB0----------NSEL (chip select in)
654 /// SCK pin PB3----------SCK (SPI clock in)
655 /// MOSI pin PB5----------SDI (SPI Data in)
656 /// MISO pin PB4----------SDO (SPI data out)
657 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
658 /// \--TX_ANT (TX antenna control in) RFM22B only
659 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
660 /// \--RX_ANT (RX antenna control in) RFM22B only
661 /// \endcode
662 /// and initialise like this:
663 /// \code
664 /// RH_RF22 driver(PB0, PB1);
665 /// \endcode
666 /// You can of use other pins for NSEL and NIRQ if you prefer.
667 ///
668 /// To connect an ATTiny Mega x16 such as AtTiny 3216 etc
669 /// (running at 5V) etc RF22 using Arduino using Spencer Kondes
670 /// megaTinyCore https://github.com/SpenceKonde/megaTinyCore connect the pins like this:
671 /// (pin numbering based on https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x16.md)
672 /// \code
673 /// AtTiny x16 RFM-22B
674 /// GND----------GND-\ (ground in)
675 /// SDN-/ (shutdown in)
676 /// VDD----------VCC (5V in)
677 /// interrupt pin PA6----------NIRQ (interrupt request out)
678 /// SS pin PC0----------NSEL (chip select in)
679 /// SCK pin PA3----------SCK (SPI clock in)
680 /// MOSI pin PA1----------SDI (SPI Data in)
681 /// MISO pin PA2----------SDO (SPI data out)
682 /// /--GPIO0 (GPIO0 out to control transmitter antenna TX_ANT)
683 /// \--TX_ANT (TX antenna control in) RFM22B only
684 /// /--GPIO1 (GPIO1 out to control receiver antenna RX_ANT)
685 /// \--RX_ANT (RX antenna control in) RFM22B only
686 /// \endcode
687 /// and initialise like this:
688 /// \code
689 /// RH_RF22 driver(10, 2);
690 /// \endcode
691 /// You can of use other pins for NSEL and NIRQ if you prefer.
692 ///
693 ///
694 /// Note: It is possible to have 2 radios connected to one Arduino, provided each radio has its own
695 /// SS and interrupt line (SCK, SDI and SDO are common to both radios)
696 ///
697 /// Caution: on some Arduinos such as the Mega 2560, if you set the slave select pin to be other than the usual SS
698 /// pin (D53 on Mega 2560), you may need to set the usual SS pin to be an output to force the Arduino into SPI
699 /// master mode.
700 ///
701 /// Caution: Power supply requirements of the RF22 module may be relevant in some circumstances:
702 /// RF22 modules are capable of pulling 80mA+ at full power, where Arduino's 3.3V line can
703 /// give 50mA. You may need to make provision for alternate power supply for
704 /// the RF22, especially if you wish to use full transmit power, and/or you have
705 /// other shields demanding power. Inadequate power for the RF22 is reported to cause symptoms such as:
706 /// - reset's/bootups terminate with "init failed" messages
707 /// -random termination of communication after 5-30 packets sent/received
708 /// -"fake ok" state, where initialization passes fluently, but communication doesn't happen
709 /// -shields hang Arduino boards, especially during the flashing
710 ///
711 /// Caution: some RF22 breakout boards (such as the HAB-RFM22B-BOA HAB-RFM22B-BO) reportedly
712 /// have the TX_ANT and RX_ANT pre-connected to GPIO0 and GPIO1 round the wrong way. You can work with this
713 /// if you use setGpioReversed().
714 ///
715 /// Caution: If you are using a bare RF22 module without IO level shifters, you may have difficulty connecting
716 /// to a 5V arduino. The RF22 module is 3.3V and its IO pins are 3.3V not 5V. Some Arduinos (Diecimila and
717 /// Uno) seem to work OK with this, and some (Mega) do not always work reliably. Your Mileage May Vary.
718 /// For best result, use level shifters, or use a RF22 shield or board with level shifters built in,
719 /// such as the Sparkfun RFM22 shield http://www.sparkfun.com/products/11018.
720 /// You could also use a 3.3V IO Arduino such as a Pro.
721 /// It is recognised that it is difficult to connect
722 /// the Sparkfun RFM22 shield to a Mega, since the SPI pins on the Mega are different to other Arduinos,
723 /// But it is possible, by bending the SPI pins (D10, D11, D12, D13) on the
724 /// shield out of the way before plugging it in to the Mega and jumpering the shield pins to the Mega like this:
725 /// \code
726 /// RF22 Shield Mega
727 /// D10 D53
728 /// D13 D52
729 /// D11 D51
730 /// D12 D50
731 /// \endcode
732 ///
733 /// \par Interrupts
734 ///
735 /// The Driver uses interrupts to react to events in the RF22 module,
736 /// such as the reception of a new packet, or the completion of transmission of a packet.
737 /// The RH_RF22 interrupt service routine reads status from and writes data
738 /// to the the RF22 module via the SPI interface. It is very important therefore,
739 /// that if you are using the RF22 library with another SPI based deviced, that you
740 /// disable interrupts while you transfer data to and from that other device.
741 /// Use cli() to disable interrupts and sei() to reenable them.
742 ///
743 /// \par SPI Interface
744 ///
745 /// The RF22 module uses the SPI bus to communicate with the Arduino. Arduino
746 /// IDE includes a hardware SPI class to communicate with SPI devices using
747 /// the SPI facilities built into the Atmel chips, over the standard designated
748 /// SPI pins MOSI, MISO, SCK, which are usually on Arduino pins 11, 12 and 13
749 /// respectively (or 51, 50, 52 on a Mega).
750 ///
751 /// By default, the RH_RF22 Driver uses the Hardware SPI interface to
752 /// communicate with the RF22 module. However, if your RF22 SPI is connected to
753 /// the Arduino through non-standard pins, or the standard Hardware SPI
754 /// interface will not work for you, you can instead use a bit-banged Software
755 /// SPI class RHSoftwareSPI, which can be configured to work on any Arduino digital IO pins.
756 /// See the documentation of RHSoftwareSPI for details.
757 ///
758 /// The advantages of the Software SPI interface are that it can be used on
759 /// any Arduino pins, not just the usual dedicated hardware pins. The
760 /// disadvantage is that it is significantly slower then hardware.
761 /// If you observe reliable behaviour with the default hardware SPI RHHardwareSPI, but unreliable behaviour
762 /// with Software SPI RHSoftwareSPI, it may be due to slow CPU performance.
763 ///
764 /// Initialisation example with hardware SPI
765 /// \code
766 /// #include <RH_RF22.h>
767 /// RH_RF22 driver;
768 /// RHReliableDatagram manager(driver, CLIENT_ADDRESS);
769 /// \endcode
770 ///
771 /// Initialisation example with software SPI
772 /// \code
773 /// #include <RH_RF22.h>
774 /// #include <RHSoftwareSPI.h>
775 /// RHSoftwareSPI spi;
776 /// RH_RF22 driver(10, 2, spi);
777 /// RHReliableDatagram manager(driver, CLIENT_ADDRESS);
778 /// \endcode
779 ///
780 /// \par Memory
781 ///
782 /// The RH_RF22 Driver requires non-trivial amounts of memory. The sample programs all compile to
783 /// about 9 to 14kbytes each on Arduino, which will fit in the flash proram memory of most Arduinos. However,
784 /// the RAM requirements are more critical. Most sample programs above will run on Duemilanova,
785 /// but not on Diecimila. Even on Duemilanova, the RAM requirements are very close to the
786 /// available memory of 2kbytes. Therefore, you should be vary sparing with RAM use in programs that use
787 /// the RH_RF22 Driver on Duemilanova.
788 ///
789 /// The sample RHRouter and RHMesh programs compile to about 14kbytes,
790 /// and require more RAM than the others.
791 /// They will not run on Duemilanova or Diecimila, but will run on Arduino Mega.
792 ///
793 /// It is often hard to accurately identify when you are hitting RAM limits on Arduino.
794 /// The symptoms can include:
795 /// - Mysterious crashes and restarts
796 /// - Changes in behaviour when seemingly unrelated changes are made (such as adding print() statements)
797 /// - Hanging
798 /// - Output from Serial.print() not appearing
799 ///
800 /// With an Arduino Mega, with 8 kbytes of SRAM, there is much more RAM headroom for
801 /// your own elaborate programs.
802 /// This library is reported to work with Arduino Pro Mini, but that has not been tested by me.
803 ///
804 /// The RF22M modules use an inexpensive crystal to control the frequency synthesizer, and therfore you can expect
805 /// the transmitter and receiver frequencies to be subject to the usual inaccuracies of such crystals. The RF22
806 /// contains an AFC circuit to compensate for differences in transmitter and receiver frequencies.
807 /// It does this by altering the receiver frequency during reception by up to the pull-in frequency range.
808 /// This RF22 library enables the AFC and by default sets the pull-in frequency range to
809 /// 0.05MHz, which should be sufficient to handle most situations. However, if you observe unexplained packet losses
810 /// or failure to operate correctly all the time it may be because your modules have a wider frequency difference, and
811 /// you may need to set the afcPullInRange to a different value, using setFrequency();
812 ///
813 /// \par Transmitter Power
814 ///
815 /// You can control the transmitter power on the RF22 and RF23 transceivers
816 /// with the RH_RF22::setTxPower() function. The argument can be any of the
817 /// RH_RF22_TXPOW_* (for RFM22) or RH_RF22_RF23B_TXPOW_* (for RFM23) values.
818 /// The default is RH_RF22_TXPOW_8DBM/RH_RF22_RF23B_TXPOW_1DBM . Eg:
819 /// \code
820 /// driver.setTxPower(RH_RF22_TXPOW_2DBM);
821 /// \endcode
822 ///
823 /// The RF23BP has higher power capability, there are
824 /// several power settings that are specific to the RF23BP only:
825 ///
826 /// - RH_RF22_RF23BP_TXPOW_28DBM
827 /// - RH_RF22_RF23BP_TXPOW_29DBM
828 /// - RH_RF22_RF23BP_TXPOW_30DBM
829 ///
830 /// CAUTION: the high power settings available on the RFM23BP require
831 /// significant power supply current. For example at +30dBm, the typical chip
832 /// supply current is 550mA. This will overwhelm some small CPU board power
833 /// regulators and USB supplies. If you use this chip at high power make sure
834 /// you have an adequate supply current providing full 5V to the RFM23BP (and
835 /// the CPU if required), otherwise you can expect strange behaviour like
836 /// hanging, stopping, incorrect power levels, RF power amp overheating etc.
837 /// You must also ensure that the RFM23BP GPIO pins are connected to the
838 /// antenna switch control pins like so:
839 ////
840 /// \code
841 /// GPIO0 <-> RXON
842 /// GPIO1 <-> TXON
843 /// \endcode
844 ///
845 /// The RF output impedance of the RFM22BP module is 50 ohms. In our
846 /// experiments we found that the most critical issue (besides a suitable
847 /// power supply) is to ensure that the antenna impedance is also near 50
848 /// ohms. Connecting a simple 1/4 wavelength (ie a 17.3cm single wire)
849 /// directly to the antenna output <b>will not work at full 30dBm power</b>,
850 /// and will result in the transmitter hanging and/or the power amp
851 /// overheating. Connect a proper 50 ohm impedance transmission line or
852 /// antenna, and prevent RF radiation into the radio and arduino modules,
853 /// in order to get full, reliable power. Our tests show that a 433MHz
854 /// RFM23BP feeding a 50 ohm transmission line with a VHF discone antenna at
855 /// the end results in full power output and the power amp transistor on the
856 /// RFM22BP module runnning slightly warm but not hot. We recommend you use
857 /// the services of a competent RF engineer when trying to use this high power
858 /// module.
859 ///
860 /// Note: with RFM23BP, the reported maximum possible power when operating on 3.3V is 27dBm.
861 ///
862 /// We have made some actual power measurements against
863 /// programmed power for Sparkfun RFM22 wireless module under the following conditions:
864 /// - Sparkfun RFM22 wireless module, Duemilanove, USB power
865 /// - 10cm RG58C/U soldered direct to RFM22 module ANT and GND
866 /// - bnc connecteor
867 /// - 12dB attenuator
868 /// - BNC-SMA adapter
869 /// - MiniKits AD8307 HF/VHF Power Head (calibrated against Rohde&Schwartz 806.2020 test set)
870 /// - Tektronix TDS220 scope to measure the Vout from power head
871 /// \code
872 /// Program power Measured Power
873 /// dBm dBm
874 /// 1 -5.6
875 /// 2 -3.8
876 /// 5 -2.2
877 /// 8 -0.6
878 /// 11 1.2
879 /// 14 11.6
880 /// 17 14.4
881 /// 20 18.0
882 /// \endcode
883 /// (Caution: we dont claim laboratory accuracy for these measurements)
884 /// You would not expect to get anywhere near these powers to air with a simple 1/4 wavelength wire antenna.
885 ///
886 /// \par Performance
887 ///
888 /// Some simple speed performance tests have been conducted.
889 /// In general packet transmission rate will be limited by the modulation scheme.
890 /// Also, if your code does any slow operations like Serial printing it will also limit performance.
891 /// We disabled any printing in the tests below.
892 /// We tested with RH_RF22::GFSK_Rb125Fd125, which is probably the fastest scheme available.
893 /// We tested with a 13 octet message length, over a very short distance of 10cm.
894 ///
895 /// Transmission (no reply) tests with modulation RH_RF22::GFSK_Rb125Fd125 and a
896 /// 13 octet message show about 330 messages per second transmitted.
897 ///
898 /// Transmit-and-wait-for-a-reply tests with modulation RH_RF22::GFSK_Rb125Fd125 and a
899 /// 13 octet message (send and receive) show about 160 round trips per second.
900 ///
901 /// \par Compatibility with RF22 library
902 /// The RH_RF22 driver is based on our earlier RF22 library http://www.airspayce.com/mikem/arduino/RF22
903 /// We have tried hard to be as compatible as possible with the earlier RF22 library, but there are some differences:
904 /// - Different constructor.
905 /// - Indexes for some modem configurations have changed (we recommend you use the symbolic names, not integer indexes).
906 ///
907 /// The major difference is that under RadioHead, you are
908 /// required to create 2 objects (ie RH_RF22 and a manager) instead of just one object under RF22
909 /// (ie RHMesh, RHRouter, RHReliableDatagram or RHDatagram).
910 /// It may be sufficient or you to change for example:
911 /// \code
912 /// RF22ReliableDatagram rf22(CLIENT_ADDRESS);
913 /// \endcode
914 /// to:
915 /// \code
916 /// RH_RF22 driver;
917 /// RHReliableDatagram rf22(driver, CLIENT_ADDRESS);
918 /// \endcode
919 /// and any instance of RF22_MAX_MESSAGE_LEN to RH_RF22_MAX_MESSAGE_LEN
920 ///
921 /// RadioHead version 1.6 changed the way the interrupt pin number is
922 /// specified on Arduino and Uno32 platforms. If your code previously
923 /// specifed a non-default interrupt pin number in the RH_RF22 constructor,
924 /// you may need to review your code to specify the correct interrrupt pin
925 /// (and not the interrupt number as before).
926 class RH_RF22 : public RHSPIDriver
927 {
928 public:
929 
930  /// \brief Defines register values for a set of modem configuration registers
931  ///
932  /// Defines register values for a set of modem configuration registers
933  /// that can be passed to setModemConfig()
934  /// if none of the choices in ModemConfigChoice suit your need
935  /// setModemConfig() writes the register values to the appropriate RH_RF22 registers
936  /// to set the desired modulation type, data rate and deviation/bandwidth.
937  /// Suitable values for these registers can be computed using the register calculator at
938  /// http://www.hoperf.com/upload/rf/RF22B%2023B%2031B%2042B%2043B%20Register%20Settings_RevB1-v5.xls
939  typedef struct
940  {
941  uint8_t reg_1c; ///< Value for register RH_RF22_REG_1C_IF_FILTER_BANDWIDTH
942  uint8_t reg_1f; ///< Value for register RH_RF22_REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE
943  uint8_t reg_20; ///< Value for register RH_RF22_REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE
944  uint8_t reg_21; ///< Value for register RH_RF22_REG_21_CLOCK_RECOVERY_OFFSET2
945  uint8_t reg_22; ///< Value for register RH_RF22_REG_22_CLOCK_RECOVERY_OFFSET1
946  uint8_t reg_23; ///< Value for register RH_RF22_REG_23_CLOCK_RECOVERY_OFFSET0
947  uint8_t reg_24; ///< Value for register RH_RF22_REG_24_CLOCK_RECOVERY_TIMING_LOOP_GAIN1
948  uint8_t reg_25; ///< Value for register RH_RF22_REG_25_CLOCK_RECOVERY_TIMING_LOOP_GAIN0
949  uint8_t reg_2c; ///< Value for register RH_RF22_REG_2C_OOK_COUNTER_VALUE_1
950  uint8_t reg_2d; ///< Value for register RH_RF22_REG_2D_OOK_COUNTER_VALUE_2
951  uint8_t reg_2e; ///< Value for register RH_RF22_REG_2E_SLICER_PEAK_HOLD
952  uint8_t reg_58; ///< Value for register RH_RF22_REG_58_CHARGE_PUMP_CURRENT_TRIMMING
953  uint8_t reg_69; ///< Value for register RH_RF22_REG_69_AGC_OVERRIDE1
954  uint8_t reg_6e; ///< Value for register RH_RF22_REG_6E_TX_DATA_RATE1
955  uint8_t reg_6f; ///< Value for register RH_RF22_REG_6F_TX_DATA_RATE0
956  uint8_t reg_70; ///< Value for register RH_RF22_REG_70_MODULATION_CONTROL1
957  uint8_t reg_71; ///< Value for register RH_RF22_REG_71_MODULATION_CONTROL2
958  uint8_t reg_72; ///< Value for register RH_RF22_REG_72_FREQUENCY_DEVIATION
959  } ModemConfig;
960 
961  /// Choices for setModemConfig() for a selected subset of common modulation types,
962  /// and data rates. If you need another configuration, use the register calculator.
963  /// and call setModemRegisters() with your desired settings.
964  /// These are indexes into MODEM_CONFIG_TABLE. We strongly recommend you use these symbolic
965  /// definitions and not their integer equivalents: its possible that new values will be
966  /// introduced in later versions (though we will try to avoid it).
967  typedef enum
968  {
969  UnmodulatedCarrier = 0, ///< Unmodulated carrier for testing
970  FSK_PN9_Rb2Fd5, ///< FSK, No Manchester, Rb = 2kbs, Fd = 5kHz, PN9 random modulation for testing
971 
972  FSK_Rb2Fd5, ///< FSK, No Manchester, Rb = 2kbs, Fd = 5kHz
973  FSK_Rb2_4Fd36, ///< FSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz
974  FSK_Rb4_8Fd45, ///< FSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz
975  FSK_Rb9_6Fd45, ///< FSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz
976  FSK_Rb19_2Fd9_6, ///< FSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz
977  FSK_Rb38_4Fd19_6, ///< FSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz
978  FSK_Rb57_6Fd28_8, ///< FSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz
979  FSK_Rb125Fd125, ///< FSK, No Manchester, Rb = 125kbs, Fd = 125kHz
980  FSK_Rb_512Fd2_5, ///< FSK, No Manchester, Rb = 512bs, Fd = 2.5kHz, for POCSAG compatibility
981  FSK_Rb_512Fd4_5, ///< FSK, No Manchester, Rb = 512bs, Fd = 4.5kHz, for POCSAG compatibility
982 
983  GFSK_Rb2Fd5, ///< GFSK, No Manchester, Rb = 2kbs, Fd = 5kHz
984  GFSK_Rb2_4Fd36, ///< GFSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz
985  GFSK_Rb4_8Fd45, ///< GFSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz
986  GFSK_Rb9_6Fd45, ///< GFSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz
987  GFSK_Rb19_2Fd9_6, ///< GFSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz
988  GFSK_Rb38_4Fd19_6, ///< GFSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz
989  GFSK_Rb57_6Fd28_8, ///< GFSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz
990  GFSK_Rb125Fd125, ///< GFSK, No Manchester, Rb = 125kbs, Fd = 125kHz
991 
992  OOK_Rb1_2Bw75, ///< OOK, No Manchester, Rb = 1.2kbs, Rx Bandwidth = 75kHz
993  OOK_Rb2_4Bw335, ///< OOK, No Manchester, Rb = 2.4kbs, Rx Bandwidth = 335kHz
994  OOK_Rb4_8Bw335, ///< OOK, No Manchester, Rb = 4.8kbs, Rx Bandwidth = 335kHz
995  OOK_Rb9_6Bw335, ///< OOK, No Manchester, Rb = 9.6kbs, Rx Bandwidth = 335kHz
996  OOK_Rb19_2Bw335, ///< OOK, No Manchester, Rb = 19.2kbs, Rx Bandwidth = 335kHz
997  OOK_Rb38_4Bw335, ///< OOK, No Manchester, Rb = 38.4kbs, Rx Bandwidth = 335kHz
998  OOK_Rb40Bw335 ///< OOK, No Manchester, Rb = 40kbs, Rx Bandwidth = 335kHz
999 
1001 
1002  /// \brief Defines the available choices for CRC
1003  /// Types of permitted CRC polynomials, to be passed to setCRCPolynomial()
1004  /// They deliberately have the same numeric values as the crc[1:0] field of Register
1005  /// RH_RF22_REG_30_DATA_ACCESS_CONTROL
1006  typedef enum
1007  {
1008  CRC_CCITT = 0, ///< CCITT
1009  CRC_16_IBM = 1, ///< CRC-16 (IBM) The default used by RH_RF22 driver
1010  CRC_IEC_16 = 2, ///< IEC-16
1011  CRC_Biacheva = 3 ///< Biacheva
1012  } CRCPolynomial;
1013 
1014  /// Constructor. You can have multiple instances, but each instance must have its own
1015  /// interrupt and slave select pin. After constructing, you must call init() to initialise the interface
1016  /// and the radio module. A maximum of 3 instances can co-exist on one processor, provided there are sufficient
1017  /// distinct interrupt lines, one for each instance.
1018  /// \param[in] slaveSelectPin the Arduino pin number of the output to use to select the RH_RF22 before
1019  /// accessing it. Defaults to the normal SS pin for your Arduino (D10 for Diecimila, Uno etc, D53 for Mega, D10 for Maple)
1020  /// \param[in] interruptPin The interrupt Pin number that is connected to the RF22 NIRQ interrupt line.
1021  /// Defaults to pin 2, as required by sparkfun RFM22 module shields.
1022  /// Caution: You must specify an interrupt capable pin.
1023  /// On many Arduino boards, there are limitations as to which pins may be used as interrupts.
1024  /// On Leonardo pins 0, 1, 2 or 3. On Mega2560 pins 2, 3, 18, 19, 20, 21. On Due and Teensy, any digital pin.
1025  /// On other Arduinos pins 2 or 3.
1026  /// See http://arduino.cc/en/Reference/attachInterrupt for more details.
1027  /// On Chipkit Uno32, pins 38, 2, 7, 8, 35.
1028  /// On other boards, any digital pin may be used.
1029  /// \param[in] spi Pointer to the SPI interface object to use.
1030  /// Defaults to the standard Arduino hardware SPI interface
1031  RH_RF22(uint8_t slaveSelectPin = SS, uint8_t interruptPin = 2, RHGenericSPI& spi = hardware_spi);
1032 
1033  /// Initialises this instance and the radio module connected to it.
1034  /// The following steps are taken:
1035  /// - Initialise the slave select pin and the SPI interface library
1036  /// - Software reset the RH_RF22 module
1037  /// - Checks the connected RH_RF22 module is either a RH_RF22_DEVICE_TYPE_RX_TRX or a RH_RF22_DEVICE_TYPE_TX
1038  /// - Attaches an interrupt handler
1039  /// - Configures the RH_RF22 module
1040  /// - Sets the frequency to 434.0 MHz
1041  /// - Sets the modem data rate to FSK_Rb2_4Fd36
1042  /// \return true if everything was successful
1043  bool init();
1044 
1045  /// Issues a software reset to the
1046  /// RH_RF22 module. Blocks for 1ms to ensure the reset is complete.
1047  void reset();
1048 
1049  /// Reads and returns the device status register RH_RF22_REG_02_DEVICE_STATUS
1050  /// \return The value of the device status register
1051  uint8_t statusRead();
1052 
1053  /// Reads a value from the on-chip analog-digital converter
1054  /// \param[in] adcsel Selects the ADC input to measure. One of RH_RF22_ADCSEL_*. Defaults to the
1055  /// internal temperature sensor
1056  /// \param[in] adcref Specifies the refernce voltage to use. One of RH_RF22_ADCREF_*.
1057  /// Defaults to the internal bandgap voltage.
1058  /// \param[in] adcgain Amplifier gain selection.
1059  /// \param[in] adcoffs Amplifier offseet (0 to 15).
1060  /// \return The analog value. 0 to 255.
1061  uint8_t adcRead(uint8_t adcsel = RH_RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR,
1062  uint8_t adcref = RH_RF22_ADCREF_BANDGAP_VOLTAGE,
1063  uint8_t adcgain = 0,
1064  uint8_t adcoffs = 0);
1065 
1066  /// Reads the on-chip temperature sensor
1067  /// \param[in] tsrange Specifies the temperature range to use. One of RH_RF22_TSRANGE_*
1068  /// \param[in] tvoffs Specifies the temperature value offset. This is actually signed value
1069  /// added to the measured temperature value
1070  /// \return The measured temperature.
1071  uint8_t temperatureRead(uint8_t tsrange = RH_RF22_TSRANGE_M64_64C, uint8_t tvoffs = 0);
1072 
1073  /// Reads the wakeup timer value in registers RH_RF22_REG_17_WAKEUP_TIMER_VALUE1
1074  /// and RH_RF22_REG_18_WAKEUP_TIMER_VALUE2
1075  /// \return The wakeup timer value
1076  uint16_t wutRead();
1077 
1078  /// Sets the wakeup timer period registers RH_RF22_REG_14_WAKEUP_TIMER_PERIOD1,
1079  /// RH_RF22_REG_15_WAKEUP_TIMER_PERIOD2 and RH_RF22_R<EG_16_WAKEUP_TIMER_PERIOD3
1080  /// \param[in] wtm Wakeup timer mantissa value
1081  /// \param[in] wtr Wakeup timer exponent R value
1082  /// \param[in] wtd Wakeup timer exponent D value
1083  void setWutPeriod(uint16_t wtm, uint8_t wtr = 0, uint8_t wtd = 0);
1084 
1085  /// Sets the transmitter and receiver centre frequency
1086  /// \param[in] centre Frequency in MHz. 240.0 to 960.0. Caution, some versions of RH_RF22 and derivatives
1087  /// implemented more restricted frequency ranges.
1088  /// \param[in] afcPullInRange Sets the AF Pull In Range in MHz. Defaults to 0.05MHz (50kHz).
1089  /// Range is 0.0 to 0.159375
1090  /// for frequencies 240.0 to 480MHz, and 0.0 to 0.318750MHz for frequencies 480.0 to 960MHz,
1091  /// \return true if the selected frquency centre + (fhch * fhs) is within range and the afcPullInRange
1092  /// is within range
1093  bool setFrequency(float centre, float afcPullInRange = 0.05);
1094 
1095  /// Sets the frequency hopping step size.
1096  /// \param[in] fhs Frequency Hopping step size in 10kHz increments
1097  /// \return true if centre + (fhch * fhs) is within limits
1098  bool setFHStepSize(uint8_t fhs);
1099 
1100  /// Sets the frequncy hopping channel. Adds fhch * fhs to centre frequency
1101  /// \param[in] fhch The channel number
1102  /// \return true if the selected frquency centre + (fhch * fhs) is within range
1103  bool setFHChannel(uint8_t fhch);
1104 
1105  /// Reads and returns the current RSSI value from register RH_RF22_REG_26_RSSI. Caution: this is
1106  /// in internal units (see figure 31 of RFM22B/23B documentation), not in dBm. If you want to find the RSSI in dBm
1107  /// of the last received message, use lastRssi() instead.
1108  /// \return The current RSSI value
1109  uint8_t rssiRead();
1110 
1111  /// Reads and returns the current EZMAC value from register RH_RF22_REG_31_EZMAC_STATUS
1112  /// \return The current EZMAC value
1113  uint8_t ezmacStatusRead();
1114 
1115  /// Sets the parameters for the RH_RF22 Idle mode in register RH_RF22_REG_07_OPERATING_MODE.
1116  /// Idle mode is the mode the RH_RF22 will be in when not transmitting or receiving. The default idle mode
1117  /// is RH_RF22_XTON ie READY mode.
1118  /// \param[in] mode Mask of mode bits, using RH_RF22_SWRES, RH_RF22_ENLBD, RH_RF22_ENWT,
1119  /// RH_RF22_X32KSEL, RH_RF22_PLLON, RH_RF22_XTON.
1120  void setOpMode(uint8_t mode);
1121 
1122  /// If current mode is Rx or Tx changes it to Idle. If the transmitter or receiver is running,
1123  /// disables them.
1124  void setModeIdle();
1125 
1126  /// If current mode is Tx or Idle, changes it to Rx.
1127  /// Starts the receiver in the RH_RF22.
1128  void setModeRx();
1129 
1130  /// If current mode is Rx or Idle, changes it to Rx.
1131  /// Starts the transmitter in the RH_RF22.
1132  void setModeTx();
1133 
1134  /// Sets the transmitter power output level in register RH_RF22_REG_6D_TX_POWER.
1135  /// Be a good neighbour and set the lowest power level you need.
1136  /// After init(), the power will be set to RH_RF22::RH_RF22_TXPOW_8DBM on RF22B
1137  /// or RH_RF22_RF23B_TXPOW_1DBM on an RF23B.
1138  /// The highest power available on RF22B is RH_RF22::RH_RF22_TXPOW_20DBM (20dBm).
1139  /// The highest power available on RF23B is RH_RF22::RH_RF22_RF23B_TXPOW_13DBM (13dBm).
1140  /// Higher powers are available on RF23BP (using RH_RF22_RF23BP_TXPOW_*),
1141  /// and then only with an adequate power supply. See comments above.
1142  /// Caution: In some countries you may only select certain higher power levels if you
1143  /// are also using frequency hopping. Make sure you are aware of the legal
1144  /// limitations and regulations in your region.
1145  /// \param[in] power Transmitter power level, one of RH_RF22_*TXPOW_*
1146  void setTxPower(uint8_t power);
1147 
1148  /// Sets all the registered required to configure the data modem in the RH_RF22, including the data rate,
1149  /// bandwidths etc. You cas use this to configure the modem with custom configuraitons if none of the
1150  /// canned configurations in ModemConfigChoice suit you.
1151  /// \param[in] config A ModemConfig structure containing values for the modem configuration registers.
1152  void setModemRegisters(const ModemConfig* config);
1153 
1154  /// Select one of the predefined modem configurations. If you need a modem configuration not provided
1155  /// here, use setModemRegisters() with your own ModemConfig.
1156  /// \param[in] index The configuration choice.
1157  /// \return true if index is a valid choice.
1158  bool setModemConfig(ModemConfigChoice index);
1159 
1160  /// Starts the receiver and checks whether a received message is available.
1161  /// This can be called multiple times in a timeout loop
1162  /// \return true if a complete, valid message has been received and is able to be retrieved by
1163  /// recv()
1164  bool available();
1165 
1166  /// Turns the receiver on if it not already on.
1167  /// If there is a valid message available, copy it to buf and return true
1168  /// else return false.
1169  /// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
1170  /// You should be sure to call this function frequently enough to not miss any messages
1171  /// It is recommended that you call it in your main loop.
1172  /// \param[in] buf Location to copy the received message
1173  /// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
1174  /// \return true if a valid message was copied to buf
1175  bool recv(uint8_t* buf, uint8_t* len);
1176 
1177  /// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
1178  /// Then loads a message into the transmitter and starts the transmitter. Note that a message length
1179  /// of 0 is NOT permitted.
1180  /// \param[in] data Array of data to be sent
1181  /// \param[in] len Number of bytes of data to send (> 0)
1182  /// \return true if the message length was valid and it was correctly queued for transmit
1183  bool send(const uint8_t* data, uint8_t len);
1184 
1185  /// Sets the length of the preamble
1186  /// in 4-bit nibbles.
1187  /// Caution: this should be set to the same
1188  /// value on all nodes in your network. Default is 8.
1189  /// Sets the message preamble length in RH_RF22_REG_34_PREAMBLE_LENGTH
1190  /// \param[in] nibbles Preamble length in nibbles of 4 bits each.
1191  void setPreambleLength(uint8_t nibbles);
1192 
1193  /// Sets the sync words for transmit and receive in registers RH_RF22_REG_36_SYNC_WORD3
1194  /// to RH_RF22_REG_39_SYNC_WORD0
1195  /// Caution: SyncWords should be set to the same
1196  /// value on all nodes in your network. Nodes with different SyncWords set will never receive
1197  /// each others messages, so different SyncWords can be used to isolate different
1198  /// networks from each other. Default is { 0x2d, 0xd4 }.
1199  /// \param[in] syncWords Array of sync words, 1 to 4 octets long
1200  /// \param[in] len Number of sync words to set, 1 to 4.
1201  void setSyncWords(const uint8_t* syncWords, uint8_t len);
1202 
1203  /// Tells the receiver to accept messages with any TO address, not just messages
1204  /// addressed to thisAddress or the broadcast address
1205  /// \param[in] promiscuous true if you wish to receive messages with any TO address
1206  virtual void setPromiscuous(bool promiscuous);
1207 
1208  /// Sets the CRC polynomial to be used to generate the CRC for both receive and transmit
1209  /// otherwise the default of CRC_16_IBM will be used.
1210  /// \param[in] polynomial One of RH_RF22::CRCPolynomial choices CRC_*
1211  /// \return true if polynomial is a valid option for this radio.
1212  bool setCRCPolynomial(CRCPolynomial polynomial);
1213 
1214  /// Configures GPIO pins for reversed GPIO connections to the antenna switch.
1215  /// Normally on RF22 modules, GPIO0(out) is connected to TX_ANT(in) to enable tx antenna during transmit
1216  /// and GPIO1(out) is connected to RX_ANT(in) to enable rx antenna during receive. The RH_RF22 driver
1217  /// configures the GPIO pins during init() so the antenna switch works as expected.
1218  /// However, some RF22 modules, such as HAB-RFM22B-BOA HAB-RFM22B-BO, also Si4432 sold by Dorji.com via Tindie.com
1219  /// have these GPIO pins reversed, so that GPIO0 is connected to RX_ANT.
1220  /// Call this function with a true argument after init() and before transmitting
1221  /// in order to configure the module for reversed GPIO pins.
1222  /// \param[in] gpioReversed Set to true if your RF22 module has reversed GPIO antenna switch connections.
1223  void setGpioReversed(bool gpioReversed = false);
1224 
1225  /// Returns the time in millis since the last preamble was received, and when the last
1226  /// RSSI measurement was made.
1227  uint32_t getLastPreambleTime();
1228 
1229  /// The maximum message length supported by this driver
1230  /// \return The maximum message length supported by this driver
1231  uint8_t maxMessageLength();
1232 
1233  /// Sets the radio into low-power sleep mode.
1234  /// If successful, the transport will stay in sleep mode until woken by
1235  /// changing mode it idle, transmit or receive (eg by calling send(), recv(), available() etc)
1236  /// Caution: there is a time penalty as the radio takes a finite time to wake from sleep mode.
1237  /// \return true if sleep mode was successfully entered.
1238  virtual bool sleep();
1239 
1240 protected:
1241  /// This is a low level function to handle the interrupts for one instance of RH_RF22.
1242  /// Called automatically by isr*()
1243  /// Should not need to be called.
1244  void handleInterrupt();
1245 
1246  /// Clears the receiver buffer.
1247  /// Internal use only
1248  void clearRxBuf();
1249 
1250  /// Clears the transmitter buffer
1251  /// Internal use only
1252  void clearTxBuf();
1253 
1254  /// Fills the transmitter buffer with the data of a mesage to be sent
1255  /// \param[in] data Array of data bytes to be sent (1 to 255)
1256  /// \param[in] len Number of data bytes in data (> 0)
1257  /// \return true if the message length is valid
1258  bool fillTxBuf(const uint8_t* data, uint8_t len);
1259 
1260  /// Appends the transmitter buffer with the data of a mesage to be sent
1261  /// \param[in] data Array of data bytes to be sent (0 to 255)
1262  /// \param[in] len Number of data bytes in data
1263  /// \return false if the resulting message would exceed RH_RF22_MAX_MESSAGE_LEN, else true
1264  bool appendTxBuf(const uint8_t* data, uint8_t len);
1265 
1266  /// Internal function to load the next fragment of
1267  /// the current message into the transmitter FIFO
1268  /// Internal use only
1269  void sendNextFragment();
1270 
1271  /// function to copy the next fragment from
1272  /// the receiver FIF) into the receiver buffer
1273  void readNextFragment();
1274 
1275  /// Clears the RF22 Rx and Tx FIFOs
1276  /// Internal use only
1277  void resetFifos();
1278 
1279  /// Clears the RF22 Rx FIFO
1280  /// Internal use only
1281  void resetRxFifo();
1282 
1283  /// Clears the RF22 Tx FIFO
1284  /// Internal use only
1285  void resetTxFifo();
1286 
1287  /// This function will be called by handleInterrupt() if an RF22 external interrupt occurs.
1288  /// This can only happen if external interrupts are enabled in the RF22
1289  /// (which they are not by default).
1290  /// Subclasses may override this function to get control when an RF22 external interrupt occurs.
1291  virtual void handleExternalInterrupt();
1292 
1293  /// This function will be called by handleInterrupt() if an RF22 wakeup timer interrupt occurs.
1294  /// This can only happen if wakeup timer interrupts are enabled in theRF22
1295  /// (which they are not by default).
1296  /// Subclasses may override this function to get control when an RF22 wakeup timer interrupt occurs.
1297  virtual void handleWakeupTimerInterrupt();
1298 
1299  /// Start the transmission of the contents
1300  /// of the Tx buffer
1301  void startTransmit();
1302 
1303  /// ReStart the transmission of the contents
1304  /// of the Tx buffer after a atransmission failure
1305  void restartTransmit();
1306 
1307  void setThisAddress(uint8_t thisAddress);
1308 
1309  /// Sets the radio operating mode for the case when the driver is idle (ie not
1310  /// transmitting or receiving), allowing you to control the idle mode power requirements
1311  /// at the expense of slower transitions to transmit and receive modes.
1312  /// By default, the idle mode is RH_RF22_XTON,
1313  /// but eg setIdleMode(RH_RF22_PLL) will provide a much lower
1314  /// idle current but slower transitions. Call this function after init().
1315  /// \param[in] idleMode The chip operating mode to use when the driver is idle. One of the valid definitions for RH_RF22_REG_07_OPERATING_MODE
1316  void setIdleMode(uint8_t idleMode);
1317 
1318 protected:
1319  /// Low level interrupt service routine for RF22 connected to interrupt 0
1320  static void isr0();
1321 
1322  /// Low level interrupt service routine for RF22 connected to interrupt 1
1323  static void isr1();
1324 
1325  /// Low level interrupt service routine for RF22 connected to interrupt 1
1326  static void isr2();
1327 
1328  /// Array of instances connected to interrupts 0 and 1
1330 
1331  /// Index of next interrupt number to use in _deviceForInterrupt
1332  static uint8_t _interruptCount;
1333 
1334  /// The configured interrupt pin connected to this instance
1335  uint8_t _interruptPin;
1336 
1337  /// The index into _deviceForInterrupt[] for this device (if an interrupt is already allocated)
1338  /// else 0xff
1340 
1341  /// The radio mode to use when mode is idle
1342  uint8_t _idleMode;
1343 
1344  /// The device type reported by the RF22
1345  uint8_t _deviceType;
1346 
1347  /// The selected CRC polynomial
1349 
1350  // These volatile members may get changed in the interrupt service routine
1351  /// Number of octets in the receiver buffer
1352  volatile uint8_t _bufLen;
1353 
1354  /// The receiver buffer
1355  uint8_t _buf[RH_RF22_MAX_MESSAGE_LEN];
1356 
1357  /// True when there is a valid message in the Rx buffer
1358  volatile bool _rxBufValid;
1359 
1360  /// Index into TX buffer of the next to send chunk
1361  volatile uint8_t _txBufSentIndex;
1362 
1363  /// Time in millis since the last preamble was received (and the last time the RSSI was measured)
1365 };
1366 
1367 /// @example rf22_client.pde
1368 /// @example rf22_server.pde
1369 
1370 #endif
RHGenericDriver::_rxGood
volatile uint16_t _rxGood
Count of the number of successfully transmitted messaged.
Definition: RHGenericDriver.h:292
RH_RF22::wutRead
uint16_t wutRead()
Definition: RH_RF22.cpp:364
RH_RF22::FSK_PN9_Rb2Fd5
@ FSK_PN9_Rb2Fd5
FSK, No Manchester, Rb = 2kbs, Fd = 5kHz, PN9 random modulation for testing.
Definition: RH_RF22.h:970
RH_RF22::_deviceType
uint8_t _deviceType
The device type reported by the RF22.
Definition: RH_RF22.h:1345
RH_RF22::_rxBufValid
volatile bool _rxBufValid
True when there is a valid message in the Rx buffer.
Definition: RH_RF22.h:1358
RH_RF22::ModemConfig::reg_23
uint8_t reg_23
Value for register RH_RF22_REG_23_CLOCK_RECOVERY_OFFSET0.
Definition: RH_RF22.h:946
RH_RF22::setModemConfig
bool setModemConfig(ModemConfigChoice index)
Definition: RH_RF22.cpp:512
RH_RF22::FSK_Rb57_6Fd28_8
@ FSK_Rb57_6Fd28_8
FSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz.
Definition: RH_RF22.h:978
RH_RF22::isr0
static void isr0()
Low level interrupt service routine for RF22 connected to interrupt 0.
Definition: RH_RF22.cpp:312
RH_RF22::GFSK_Rb125Fd125
@ GFSK_Rb125Fd125
GFSK, No Manchester, Rb = 125kbs, Fd = 125kHz.
Definition: RH_RF22.h:990
RH_RF22::setOpMode
void setOpMode(uint8_t mode)
Definition: RH_RF22.cpp:447
RH_RF22::ModemConfig::reg_71
uint8_t reg_71
Value for register RH_RF22_REG_71_MODULATION_CONTROL2.
Definition: RH_RF22.h:957
RH_RF22::ModemConfig::reg_69
uint8_t reg_69
Value for register RH_RF22_REG_69_AGC_OVERRIDE1.
Definition: RH_RF22.h:953
RH_RF22::_myInterruptIndex
uint8_t _myInterruptIndex
Definition: RH_RF22.h:1339
RH_RF22::setModeRx
void setModeRx()
Definition: RH_RF22.cpp:471
RHGenericSPI
Base class for SPI interfaces.
Definition: RHGenericSPI.h:30
RH_RF22::setFrequency
bool setFrequency(float centre, float afcPullInRange=0.05)
Definition: RH_RF22.cpp:385
RH_RF22::setCRCPolynomial
bool setCRCPolynomial(CRCPolynomial polynomial)
Definition: RH_RF22.cpp:705
RH_RF22::OOK_Rb4_8Bw335
@ OOK_Rb4_8Bw335
OOK, No Manchester, Rb = 4.8kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:994
RHGenericDriver::_rxHeaderFrom
volatile uint8_t _rxHeaderFrom
FROM header in the last received mesasge.
Definition: RHGenericDriver.h:265
RH_RF22::resetFifos
void resetFifos()
Definition: RH_RF22.cpp:668
RH_RF22::ezmacStatusRead
uint8_t ezmacStatusRead()
Definition: RH_RF22.cpp:442
RH_RF22::_interruptCount
static uint8_t _interruptCount
Index of next interrupt number to use in _deviceForInterrupt.
Definition: RH_RF22.h:1332
RHSPIDriver::spiWrite
uint8_t spiWrite(uint8_t reg, uint8_t val)
Definition: RHSPIDriver.cpp:42
RHSPIDriver
Base class for RadioHead drivers that use the SPI bus to communicate with its transport hardware.
Definition: RHSPIDriver.h:38
RH_RF22::sleep
virtual bool sleep()
Definition: RH_RF22.cpp:461
RH_RF22::GFSK_Rb9_6Fd45
@ GFSK_Rb9_6Fd45
GFSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz.
Definition: RH_RF22.h:986
RH_RF22::appendTxBuf
bool appendTxBuf(const uint8_t *data, uint8_t len)
Definition: RH_RF22.cpp:627
RH_RF22::setSyncWords
void setSyncWords(const uint8_t *syncWords, uint8_t len)
Definition: RH_RF22.cpp:531
RHGenericDriver::_lastRssi
volatile int16_t _lastRssi
The value of the last received RSSI value, in some transport specific units.
Definition: RHGenericDriver.h:286
RH_RF22::ModemConfig::reg_2e
uint8_t reg_2e
Value for register RH_RF22_REG_2E_SLICER_PEAK_HOLD.
Definition: RH_RF22.h:951
RHGenericDriver::_rxBad
volatile uint16_t _rxBad
Count of the number of bad messages (eg bad checksum etc) received.
Definition: RHGenericDriver.h:289
RH_RF22
Driver to send and receive unaddressed, unreliable datagrams via an RF22 and compatible radio transce...
Definition: RH_RF22.h:926
RH_RF22::FSK_Rb2Fd5
@ FSK_Rb2Fd5
FSK, No Manchester, Rb = 2kbs, Fd = 5kHz.
Definition: RH_RF22.h:972
RH_RF22::resetRxFifo
void resetRxFifo()
Definition: RH_RF22.cpp:675
RH_RF22::ModemConfig
Defines register values for a set of modem configuration registers.
Definition: RH_RF22.h:939
RHGenericDriver::_rxHeaderTo
volatile uint8_t _rxHeaderTo
TO header in the last received mesasge.
Definition: RHGenericDriver.h:262
RH_RF22::ModemConfig::reg_1f
uint8_t reg_1f
Value for register RH_RF22_REG_1F_CLOCK_RECOVERY_GEARSHIFT_OVERRIDE.
Definition: RH_RF22.h:942
RH_RF22::available
bool available()
Definition: RH_RF22.cpp:544
RH_RF22::ModemConfig::reg_6f
uint8_t reg_6f
Value for register RH_RF22_REG_6F_TX_DATA_RATE0.
Definition: RH_RF22.h:955
RHGenericDriver::_txHeaderFrom
uint8_t _txHeaderFrom
FROM header to send in all messages.
Definition: RHGenericDriver.h:277
RH_RF22::setFHStepSize
bool setFHStepSize(uint8_t fhs)
Definition: RH_RF22.cpp:423
RH_RF22::UnmodulatedCarrier
@ UnmodulatedCarrier
Unmodulated carrier for testing.
Definition: RH_RF22.h:969
RH_RF22::ModemConfig::reg_21
uint8_t reg_21
Value for register RH_RF22_REG_21_CLOCK_RECOVERY_OFFSET2.
Definition: RH_RF22.h:944
RH_RF22::_bufLen
volatile uint8_t _bufLen
Number of octets in the receiver buffer.
Definition: RH_RF22.h:1352
RH_RF22::rssiRead
uint8_t rssiRead()
Definition: RH_RF22.cpp:437
RH_RF22::_interruptPin
uint8_t _interruptPin
The configured interrupt pin connected to this instance.
Definition: RH_RF22.h:1335
RH_RF22::setThisAddress
void setThisAddress(uint8_t thisAddress)
Definition: RH_RF22.cpp:722
RH_RF22::CRCPolynomial
CRCPolynomial
Defines the available choices for CRC Types of permitted CRC polynomials, to be passed to setCRCPolyn...
Definition: RH_RF22.h:1006
RHSPIDriver::spiUsingInterrupt
void spiUsingInterrupt(uint8_t interruptNumber)
Definition: RHSPIDriver.cpp:91
RH_RF22::GFSK_Rb4_8Fd45
@ GFSK_Rb4_8Fd45
GFSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz.
Definition: RH_RF22.h:985
RH_RF22::CRC_16_IBM
@ CRC_16_IBM
CRC-16 (IBM) The default used by RH_RF22 driver.
Definition: RH_RF22.h:1009
RH_RF22::ModemConfig::reg_58
uint8_t reg_58
Value for register RH_RF22_REG_58_CHARGE_PUMP_CURRENT_TRIMMING.
Definition: RH_RF22.h:952
RH_RF22::handleExternalInterrupt
virtual void handleExternalInterrupt()
Definition: RH_RF22.cpp:690
RH_RF22::ModemConfig::reg_20
uint8_t reg_20
Value for register RH_RF22_REG_20_CLOCK_RECOVERY_OVERSAMPLING_RATE.
Definition: RH_RF22.h:943
RHGenericDriver::_txGood
volatile uint16_t _txGood
Count of the number of bad messages (correct checksum etc) received.
Definition: RHGenericDriver.h:295
RH_RF22::FSK_Rb4_8Fd45
@ FSK_Rb4_8Fd45
FSK, No Manchester, Rb = 4.8kbs, Fd = 45kHz.
Definition: RH_RF22.h:974
RHGenericDriver::setPromiscuous
virtual void setPromiscuous(bool promiscuous)
Definition: RHGenericDriver.cpp:103
RH_RF22::ModemConfig::reg_1c
uint8_t reg_1c
Value for register RH_RF22_REG_1C_IF_FILTER_BANDWIDTH.
Definition: RH_RF22.h:941
RH_RF22::clearTxBuf
void clearTxBuf()
Definition: RH_RF22.cpp:573
RHGenericDriver::setThisAddress
virtual void setThisAddress(uint8_t thisAddress)
Definition: RHGenericDriver.cpp:108
RH_RF22::ModemConfigChoice
ModemConfigChoice
Definition: RH_RF22.h:967
RHGenericDriver::_rxHeaderFlags
volatile uint8_t _rxHeaderFlags
FLAGS header in the last received mesasge.
Definition: RHGenericDriver.h:271
RH_RF22::isr2
static void isr2()
Low level interrupt service routine for RF22 connected to interrupt 1.
Definition: RH_RF22.cpp:322
RH_RF22::GFSK_Rb57_6Fd28_8
@ GFSK_Rb57_6Fd28_8
GFSK, No Manchester, Rb = 57.6kbs, Fd = 28.8kHz.
Definition: RH_RF22.h:989
RH_RF22::getLastPreambleTime
uint32_t getLastPreambleTime()
Definition: RH_RF22.cpp:728
RH_RF22::setTxPower
void setTxPower(uint8_t power)
Definition: RH_RF22.cpp:493
RH_RF22::setGpioReversed
void setGpioReversed(bool gpioReversed=false)
Definition: RH_RF22.cpp:733
RH_RF22::handleWakeupTimerInterrupt
virtual void handleWakeupTimerInterrupt()
Definition: RH_RF22.cpp:695
RH_RF22::OOK_Rb19_2Bw335
@ OOK_Rb19_2Bw335
OOK, No Manchester, Rb = 19.2kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:996
RH_RF22::_buf
uint8_t _buf[RH_RF22_MAX_MESSAGE_LEN]
The receiver buffer.
Definition: RH_RF22.h:1355
RHSPIDriver::spiBurstRead
uint8_t spiBurstRead(uint8_t reg, uint8_t *dest, uint8_t len)
Definition: RHSPIDriver.cpp:56
RH_RF22::sendNextFragment
void sendNextFragment()
Definition: RH_RF22.cpp:640
RH_RF22::temperatureRead
uint8_t temperatureRead(uint8_t tsrange=RH_RF22_TSRANGE_M64_64C, uint8_t tvoffs=0)
Definition: RH_RF22.cpp:357
RH_RF22::setFHChannel
bool setFHChannel(uint8_t fhch)
Definition: RH_RF22.cpp:431
RH_RF22::ModemConfig::reg_2d
uint8_t reg_2d
Value for register RH_RF22_REG_2D_OOK_COUNTER_VALUE_2.
Definition: RH_RF22.h:950
RHGenericDriver::RHModeSleep
@ RHModeSleep
Transport hardware is in low power sleep mode (if supported)
Definition: RHGenericDriver.h:51
RH_RF22::init
bool init()
Definition: RH_RF22.cpp:74
RHSPIDriver::spiBurstWrite
uint8_t spiBurstWrite(uint8_t reg, const uint8_t *src, uint8_t len)
Definition: RHSPIDriver.cpp:71
RH_RF22::OOK_Rb2_4Bw335
@ OOK_Rb2_4Bw335
OOK, No Manchester, Rb = 2.4kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:993
RHSPIDriver::init
bool init()
Definition: RHSPIDriver.cpp:15
RH_RF22::FSK_Rb9_6Fd45
@ FSK_Rb9_6Fd45
FSK, No Manchester, Rb = 9.6kbs, Fd = 45kHz.
Definition: RH_RF22.h:975
RH_RF22::resetTxFifo
void resetTxFifo()
Definition: RH_RF22.cpp:683
RH_RF22::handleInterrupt
void handleInterrupt()
Definition: RH_RF22.cpp:190
RH_RF22::CRC_IEC_16
@ CRC_IEC_16
IEC-16.
Definition: RH_RF22.h:1010
RH_RF22::FSK_Rb125Fd125
@ FSK_Rb125Fd125
FSK, No Manchester, Rb = 125kbs, Fd = 125kHz.
Definition: RH_RF22.h:979
RH_RF22::setModeTx
void setModeTx()
Definition: RH_RF22.cpp:480
RH_RF22::OOK_Rb40Bw335
@ OOK_Rb40Bw335
OOK, No Manchester, Rb = 40kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:998
RH_RF22::setPromiscuous
virtual void setPromiscuous(bool promiscuous)
Definition: RH_RF22.cpp:699
RH_RF22::setIdleMode
void setIdleMode(uint8_t idleMode)
Definition: RH_RF22.cpp:69
RH_RF22::reset
void reset()
Definition: RH_RF22.cpp:328
RH_RF22::fillTxBuf
bool fillTxBuf(const uint8_t *data, uint8_t len)
Definition: RH_RF22.cpp:619
RH_RF22::setModemRegisters
void setModemRegisters(const ModemConfig *config)
Definition: RH_RF22.cpp:499
RH_RF22::_polynomial
CRCPolynomial _polynomial
The selected CRC polynomial.
Definition: RH_RF22.h:1348
RH_RF22::setWutPeriod
void setWutPeriod(uint16_t wtm, uint8_t wtr=0, uint8_t wtd=0)
Definition: RH_RF22.cpp:372
RH_RF22::OOK_Rb38_4Bw335
@ OOK_Rb38_4Bw335
OOK, No Manchester, Rb = 38.4kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:997
RH_RF22::ModemConfig::reg_70
uint8_t reg_70
Value for register RH_RF22_REG_70_MODULATION_CONTROL1.
Definition: RH_RF22.h:956
RHGenericDriver::_txHeaderId
uint8_t _txHeaderId
ID header to send in all messages.
Definition: RHGenericDriver.h:280
RH_RF22::readNextFragment
void readNextFragment()
Definition: RH_RF22.cpp:657
RHGenericDriver::_txHeaderTo
uint8_t _txHeaderTo
TO header to send in all messages.
Definition: RHGenericDriver.h:274
RH_RF22::maxMessageLength
uint8_t maxMessageLength()
Definition: RH_RF22.cpp:717
RH_RF22::ModemConfig::reg_72
uint8_t reg_72
Value for register RH_RF22_REG_72_FREQUENCY_DEVIATION.
Definition: RH_RF22.h:958
RH_RF22::OOK_Rb9_6Bw335
@ OOK_Rb9_6Bw335
OOK, No Manchester, Rb = 9.6kbs, Rx Bandwidth = 335kHz.
Definition: RH_RF22.h:995
RH_RF22::startTransmit
void startTransmit()
Definition: RH_RF22.cpp:581
RHGenericDriver::_txHeaderFlags
uint8_t _txHeaderFlags
FLAGS header to send in all messages.
Definition: RHGenericDriver.h:283
RH_RF22::_idleMode
uint8_t _idleMode
The radio mode to use when mode is idle.
Definition: RH_RF22.h:1342
RH_RF22::CRC_CCITT
@ CRC_CCITT
CCITT.
Definition: RH_RF22.h:1008
RH_RF22::FSK_Rb19_2Fd9_6
@ FSK_Rb19_2Fd9_6
FSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz.
Definition: RH_RF22.h:976
RH_RF22::OOK_Rb1_2Bw75
@ OOK_Rb1_2Bw75
OOK, No Manchester, Rb = 1.2kbs, Rx Bandwidth = 75kHz.
Definition: RH_RF22.h:992
RH_RF22::GFSK_Rb19_2Fd9_6
@ GFSK_Rb19_2Fd9_6
GFSK, No Manchester, Rb = 19.2kbs, Fd = 9.6kHz.
Definition: RH_RF22.h:987
RH_RF22::setPreambleLength
void setPreambleLength(uint8_t nibbles)
Definition: RH_RF22.cpp:525
RH_RF22::FSK_Rb_512Fd2_5
@ FSK_Rb_512Fd2_5
FSK, No Manchester, Rb = 512bs, Fd = 2.5kHz, for POCSAG compatibility.
Definition: RH_RF22.h:980
RH_RF22::GFSK_Rb38_4Fd19_6
@ GFSK_Rb38_4Fd19_6
GFSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz.
Definition: RH_RF22.h:988
RH_RF22::FSK_Rb38_4Fd19_6
@ FSK_Rb38_4Fd19_6
FSK, No Manchester, Rb = 38.4kbs, Fd = 19.6kHz.
Definition: RH_RF22.h:977
RHGenericDriver::_rxHeaderId
volatile uint8_t _rxHeaderId
ID header in the last received mesasge.
Definition: RHGenericDriver.h:268
RH_RF22::_deviceForInterrupt
static RH_RF22 * _deviceForInterrupt[]
Array of instances connected to interrupts 0 and 1.
Definition: RH_RF22.h:1329
RH_RF22::adcRead
uint8_t adcRead(uint8_t adcsel=RH_RF22_ADCSEL_INTERNAL_TEMPERATURE_SENSOR, uint8_t adcref=RH_RF22_ADCREF_BANDGAP_VOLTAGE, uint8_t adcgain=0, uint8_t adcoffs=0)
Definition: RH_RF22.cpp:340
RH_RF22::RH_RF22
RH_RF22(uint8_t slaveSelectPin=SS, uint8_t interruptPin=2, RHGenericSPI &spi=hardware_spi)
Definition: RH_RF22.cpp:59
RH_RF22::ModemConfig::reg_2c
uint8_t reg_2c
Value for register RH_RF22_REG_2C_OOK_COUNTER_VALUE_1.
Definition: RH_RF22.h:949
RHGenericDriver::RHModeIdle
@ RHModeIdle
Transport is idle.
Definition: RHGenericDriver.h:52
RH_RF22::_txBufSentIndex
volatile uint8_t _txBufSentIndex
Index into TX buffer of the next to send chunk.
Definition: RH_RF22.h:1361
RH_RF22::ModemConfig::reg_22
uint8_t reg_22
Value for register RH_RF22_REG_22_CLOCK_RECOVERY_OFFSET1.
Definition: RH_RF22.h:945
RH_RF22::ModemConfig::reg_25
uint8_t reg_25
Value for register RH_RF22_REG_25_CLOCK_RECOVERY_TIMING_LOOP_GAIN0.
Definition: RH_RF22.h:948
RH_RF22::ModemConfig::reg_24
uint8_t reg_24
Value for register RH_RF22_REG_24_CLOCK_RECOVERY_TIMING_LOOP_GAIN1.
Definition: RH_RF22.h:947
RH_RF22::setModeIdle
void setModeIdle()
Definition: RH_RF22.cpp:452
RHSPIDriver::spiRead
uint8_t spiRead(uint8_t reg)
Definition: RHSPIDriver.cpp:30
RHGenericDriver::waitPacketSent
virtual bool waitPacketSent()
Definition: RHGenericDriver.cpp:52
RHGenericDriver::_mode
volatile RHMode _mode
The current transport operating mode.
Definition: RHGenericDriver.h:253
RH_RF22::_lastPreambleTime
uint32_t _lastPreambleTime
Time in millis since the last preamble was received (and the last time the RSSI was measured)
Definition: RH_RF22.h:1364
RHGenericDriver::RHModeTx
@ RHModeTx
Transport is in the process of transmitting a message.
Definition: RHGenericDriver.h:53
RH_RF22::send
bool send(const uint8_t *data, uint8_t len)
Definition: RH_RF22.cpp:597
RH_RF22::ModemConfig::reg_6e
uint8_t reg_6e
Value for register RH_RF22_REG_6E_TX_DATA_RATE1.
Definition: RH_RF22.h:954
RH_RF22::FSK_Rb_512Fd4_5
@ FSK_Rb_512Fd4_5
FSK, No Manchester, Rb = 512bs, Fd = 4.5kHz, for POCSAG compatibility.
Definition: RH_RF22.h:981
RH_RF22::GFSK_Rb2_4Fd36
@ GFSK_Rb2_4Fd36
GFSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz.
Definition: RH_RF22.h:984
RH_RF22::restartTransmit
void restartTransmit()
Definition: RH_RF22.cpp:589
RH_RF22::clearRxBuf
void clearRxBuf()
Definition: RH_RF22.cpp:536
RH_RF22::recv
bool recv(uint8_t *buf, uint8_t *len)
Definition: RH_RF22.cpp:555
RHGenericDriver::mode
virtual RHMode mode()
Definition: RHGenericDriver.cpp:159
RHGenericDriver::RHModeRx
@ RHModeRx
Transport is in the process of receiving a message.
Definition: RHGenericDriver.h:54
RH_RF22::CRC_Biacheva
@ CRC_Biacheva
Biacheva.
Definition: RH_RF22.h:1011
RHGenericDriver::waitCAD
virtual bool waitCAD()
Definition: RHGenericDriver.cpp:72
RH_RF22::FSK_Rb2_4Fd36
@ FSK_Rb2_4Fd36
FSK, No Manchester, Rb = 2.4kbs, Fd = 36kHz.
Definition: RH_RF22.h:973
RH_RF22::isr1
static void isr1()
Low level interrupt service routine for RF22 connected to interrupt 1.
Definition: RH_RF22.cpp:317
RH_RF22::statusRead
uint8_t statusRead()
Definition: RH_RF22.cpp:335
RH_RF22::GFSK_Rb2Fd5
@ GFSK_Rb2Fd5
GFSK, No Manchester, Rb = 2kbs, Fd = 5kHz.
Definition: RH_RF22.h:983