RadioLib
Universal wireless communication library for Arduino
RF69.h
1 #if !defined(_RADIOLIB_RF69_H)
2 #define _RADIOLIB_RF69_H
3 
4 #include "../../TypeDef.h"
5 
6 #if !defined(RADIOLIB_EXCLUDE_RF69)
7 
8 #include "../../Module.h"
9 
10 #include "../../protocols/PhysicalLayer/PhysicalLayer.h"
11 
12 // RF69 physical layer properties
13 #define RADIOLIB_RF69_FREQUENCY_STEP_SIZE 61.03515625
14 #define RADIOLIB_RF69_MAX_PACKET_LENGTH 64
15 #define RADIOLIB_RF69_CRYSTAL_FREQ 32.0
16 #define RADIOLIB_RF69_DIV_EXPONENT 19
17 
18 // RF69 register map
19 #define RADIOLIB_RF69_REG_FIFO 0x00
20 #define RADIOLIB_RF69_REG_OP_MODE 0x01
21 #define RADIOLIB_RF69_REG_DATA_MODUL 0x02
22 #define RADIOLIB_RF69_REG_BITRATE_MSB 0x03
23 #define RADIOLIB_RF69_REG_BITRATE_LSB 0x04
24 #define RADIOLIB_RF69_REG_FDEV_MSB 0x05
25 #define RADIOLIB_RF69_REG_FDEV_LSB 0x06
26 #define RADIOLIB_RF69_REG_FRF_MSB 0x07
27 #define RADIOLIB_RF69_REG_FRF_MID 0x08
28 #define RADIOLIB_RF69_REG_FRF_LSB 0x09
29 #define RADIOLIB_RF69_REG_OSC_1 0x0A
30 #define RADIOLIB_RF69_REG_AFC_CTRL 0x0B
31 #define RADIOLIB_RF69_REG_LISTEN_1 0x0D
32 #define RADIOLIB_RF69_REG_LISTEN_2 0x0E
33 #define RADIOLIB_RF69_REG_LISTEN_3 0x0F
34 #define RADIOLIB_RF69_REG_VERSION 0x10
35 #define RADIOLIB_RF69_REG_PA_LEVEL 0x11
36 #define RADIOLIB_RF69_REG_PA_RAMP 0x12
37 #define RADIOLIB_RF69_REG_OCP 0x13
38 #define RADIOLIB_RF69_REG_LNA 0x18
39 #define RADIOLIB_RF69_REG_RX_BW 0x19
40 #define RADIOLIB_RF69_REG_AFC_BW 0x1A
41 #define RADIOLIB_RF69_REG_OOK_PEAK 0x1B
42 #define RADIOLIB_RF69_REG_OOK_AVG 0x1C
43 #define RADIOLIB_RF69_REG_OOK_FIX 0x1D
44 #define RADIOLIB_RF69_REG_AFC_FEI 0x1E
45 #define RADIOLIB_RF69_REG_AFC_MSB 0x1F
46 #define RADIOLIB_RF69_REG_AFC_LSB 0x20
47 #define RADIOLIB_RF69_REG_FEI_MSB 0x21
48 #define RADIOLIB_RF69_REG_FEI_LSB 0x22
49 #define RADIOLIB_RF69_REG_RSSI_CONFIG 0x23
50 #define RADIOLIB_RF69_REG_RSSI_VALUE 0x24
51 #define RADIOLIB_RF69_REG_DIO_MAPPING_1 0x25
52 #define RADIOLIB_RF69_REG_DIO_MAPPING_2 0x26
53 #define RADIOLIB_RF69_REG_IRQ_FLAGS_1 0x27
54 #define RADIOLIB_RF69_REG_IRQ_FLAGS_2 0x28
55 #define RADIOLIB_RF69_REG_RSSI_THRESH 0x29
56 #define RADIOLIB_RF69_REG_RX_TIMEOUT_1 0x2A
57 #define RADIOLIB_RF69_REG_RX_TIMEOUT_2 0x2B
58 #define RADIOLIB_RF69_REG_PREAMBLE_MSB 0x2C
59 #define RADIOLIB_RF69_REG_PREAMBLE_LSB 0x2D
60 #define RADIOLIB_RF69_REG_SYNC_CONFIG 0x2E
61 #define RADIOLIB_RF69_REG_SYNC_VALUE_1 0x2F
62 #define RADIOLIB_RF69_REG_SYNC_VALUE_2 0x30
63 #define RADIOLIB_RF69_REG_SYNC_VALUE_3 0x31
64 #define RADIOLIB_RF69_REG_SYNC_VALUE_4 0x32
65 #define RADIOLIB_RF69_REG_SYNC_VALUE_5 0x33
66 #define RADIOLIB_RF69_REG_SYNC_VALUE_6 0x34
67 #define RADIOLIB_RF69_REG_SYNC_VALUE_7 0x35
68 #define RADIOLIB_RF69_REG_SYNC_VALUE_8 0x36
69 #define RADIOLIB_RF69_REG_PACKET_CONFIG_1 0x37
70 #define RADIOLIB_RF69_REG_PAYLOAD_LENGTH 0x38
71 #define RADIOLIB_RF69_REG_NODE_ADRS 0x39
72 #define RADIOLIB_RF69_REG_BROADCAST_ADRS 0x3A
73 #define RADIOLIB_RF69_REG_AUTO_MODES 0x3B
74 #define RADIOLIB_RF69_REG_FIFO_THRESH 0x3C
75 #define RADIOLIB_RF69_REG_PACKET_CONFIG_2 0x3D
76 #define RADIOLIB_RF69_REG_AES_KEY_1 0x3E
77 #define RADIOLIB_RF69_REG_AES_KEY_2 0x3F
78 #define RADIOLIB_RF69_REG_AES_KEY_3 0x40
79 #define RADIOLIB_RF69_REG_AES_KEY_4 0x41
80 #define RADIOLIB_RF69_REG_AES_KEY_5 0x42
81 #define RADIOLIB_RF69_REG_AES_KEY_6 0x43
82 #define RADIOLIB_RF69_REG_AES_KEY_7 0x44
83 #define RADIOLIB_RF69_REG_AES_KEY_8 0x45
84 #define RADIOLIB_RF69_REG_AES_KEY_9 0x46
85 #define RADIOLIB_RF69_REG_AES_KEY_10 0x47
86 #define RADIOLIB_RF69_REG_AES_KEY_11 0x48
87 #define RADIOLIB_RF69_REG_AES_KEY_12 0x49
88 #define RADIOLIB_RF69_REG_AES_KEY_13 0x4A
89 #define RADIOLIB_RF69_REG_AES_KEY_14 0x4B
90 #define RADIOLIB_RF69_REG_AES_KEY_15 0x4C
91 #define RADIOLIB_RF69_REG_AES_KEY_16 0x4D
92 #define RADIOLIB_RF69_REG_TEMP_1 0x4E
93 #define RADIOLIB_RF69_REG_TEMP_2 0x4F
94 #define RADIOLIB_RF69_REG_TEST_LNA 0x58
95 #define RADIOLIB_RF69_REG_TEST_PA1 0x5A
96 #define RADIOLIB_RF69_REG_TEST_PA2 0x5C
97 #define RADIOLIB_RF69_REG_TEST_DAGC 0x6F
98 
99 // RF69 modem settings
100 // RADIOLIB_RF69_REG_OP_MODE MSB LSB DESCRIPTION
101 #define RADIOLIB_RF69_SEQUENCER_OFF 0b00000000 // 7 7 disable automatic sequencer
102 #define RADIOLIB_RF69_SEQUENCER_ON 0b10000000 // 7 7 enable automatic sequencer
103 #define RADIOLIB_RF69_LISTEN_OFF 0b00000000 // 6 6 disable Listen mode
104 #define RADIOLIB_RF69_LISTEN_ON 0b01000000 // 6 6 enable Listen mode
105 #define RADIOLIB_RF69_LISTEN_ABORT 0b00100000 // 5 5 abort Listen mode (has to be set together with RF69_LISTEN_OFF)
106 #define RADIOLIB_RF69_SLEEP 0b00000000 // 4 2 sleep
107 #define RADIOLIB_RF69_STANDBY 0b00000100 // 4 2 standby
108 #define RADIOLIB_RF69_FS 0b00001000 // 4 2 frequency synthesis
109 #define RADIOLIB_RF69_TX 0b00001100 // 4 2 transmit
110 #define RADIOLIB_RF69_RX 0b00010000 // 4 2 receive
111 
112 // RADIOLIB_RF69_REG_DATA_MODUL
113 #define RADIOLIB_RF69_PACKET_MODE 0b00000000 // 6 5 packet mode (default)
114 #define RADIOLIB_RF69_CONTINUOUS_MODE_WITH_SYNC 0b01000000 // 6 5 continuous mode with bit synchronizer
115 #define RADIOLIB_RF69_CONTINUOUS_MODE 0b01100000 // 6 5 continuous mode without bit synchronizer
116 #define RADIOLIB_RF69_FSK 0b00000000 // 4 3 modulation: FSK (default)
117 #define RADIOLIB_RF69_OOK 0b00001000 // 4 3 OOK
118 #define RADIOLIB_RF69_NO_SHAPING 0b00000000 // 1 0 modulation shaping: no shaping (default)
119 #define RADIOLIB_RF69_FSK_GAUSSIAN_1_0 0b00000001 // 1 0 FSK modulation Gaussian filter, BT = 1.0
120 #define RADIOLIB_RF69_FSK_GAUSSIAN_0_5 0b00000010 // 1 0 FSK modulation Gaussian filter, BT = 0.5
121 #define RADIOLIB_RF69_FSK_GAUSSIAN_0_3 0b00000011 // 1 0 FSK modulation Gaussian filter, BT = 0.3
122 #define RADIOLIB_RF69_OOK_FILTER_BR 0b00000001 // 1 0 OOK modulation filter, f_cutoff = BR
123 #define RADIOLIB_RF69_OOK_FILTER_2BR 0b00000010 // 1 0 OOK modulation filter, f_cutoff = 2*BR
124 
125 // RADIOLIB_RF69_REG_BITRATE_MSB + REG_BITRATE_LSB
126 #define RADIOLIB_RF69_BITRATE_MSB 0x1A // 7 0 bit rate setting: rate = F(XOSC) / BITRATE
127 #define RADIOLIB_RF69_BITRATE_LSB 0x0B // 7 0 default value: 4.8 kbps 0x40 // 7 0
128 
129 // RADIOLIB_RF69_REG_FDEV_MSB + REG_FDEV_LSB
130 #define RADIOLIB_RF69_FDEV_MSB 0x00 // 5 0 frequency deviation: f_dev = f_step * FDEV
131 #define RADIOLIB_RF69_FDEV_LSB 0x52 // 7 0 default value: 5 kHz
132 
133 // RADIOLIB_RF69_REG_FRF_MSB + REG_FRF_MID + REG_FRF_LSB
134 #define RADIOLIB_RF69_FRF_MSB 0xE4 // 7 0 carrier frequency setting: f_RF = (F(XOSC) * FRF)/2^19
135 #define RADIOLIB_RF69_FRF_MID 0xC0 // 7 0 where F(XOSC) = 32 MHz
136 #define RADIOLIB_RF69_FRF_LSB 0x00 // 7 0 default value: 915 MHz
137 
138 // RADIOLIB_RF69_REG_OSC_1
139 #define RADIOLIB_RF69_RC_CAL_START 0b10000000 // 7 7 force RC oscillator calibration
140 #define RADIOLIB_RF69_RC_CAL_RUNNING 0b00000000 // 6 6 RC oscillator calibration is still running
141 #define RADIOLIB_RF69_RC_CAL_DONE 0b00000000 // 5 5 RC oscillator calibration has finished
142 
143 // RADIOLIB_RF69_REG_AFC_CTRL
144 #define RADIOLIB_RF69_AFC_LOW_BETA_OFF 0b00000000 // 5 5 standard AFC routine
145 #define RADIOLIB_RF69_AFC_LOW_BETA_ON 0b00100000 // 5 5 improved AFC routine for signals with modulation index less than 2
146 
147 // RADIOLIB_RF69_REG_LISTEN_1
148 #define RADIOLIB_RF69_LISTEN_RES_IDLE_64_US 0b01000000 // 7 6 resolution of Listen mode idle time: 64 us
149 #define RADIOLIB_RF69_LISTEN_RES_IDLE_4_1_MS 0b10000000 // 7 6 4.1 ms (default)
150 #define RADIOLIB_RF69_LISTEN_RES_IDLE_262_MS 0b11000000 // 7 6 262 ms
151 #define RADIOLIB_RF69_LISTEN_RES_RX_64_US 0b00010000 // 5 4 resolution of Listen mode rx time: 64 us (default)
152 #define RADIOLIB_RF69_LISTEN_RES_RX_4_1_MS 0b00100000 // 5 4 4.1 ms
153 #define RADIOLIB_RF69_LISTEN_RES_RX_262_MS 0b00110000 // 5 4 262 ms
154 #define RADIOLIB_RF69_LISTEN_ACCEPT_ABOVE_RSSI_THRESH 0b00000000 // 3 3 packet acceptance criteria: RSSI above threshold
155 #define RADIOLIB_RF69_LISTEN_ACCEPT_MATCH_SYNC_ADDRESS 0b00001000 // 3 3 RSSI above threshold AND sync address matched
156 #define RADIOLIB_RF69_LISTEN_END_KEEP_RX 0b00000000 // 2 1 action after packet acceptance: stay in Rx mode
157 #define RADIOLIB_RF69_LISTEN_END_KEEP_RX_TIMEOUT 0b00000010 // 2 1 stay in Rx mode until timeout (default)
158 #define RADIOLIB_RF69_LISTEN_END_KEEP_RX_TIMEOUT_RESUME 0b00000100 // 2 1 stay in Rx mode until timeout, Listen mode will resume
159 
160 // RADIOLIB_RF69_REG_LISTEN_2
161 #define RADIOLIB_RF69_LISTEN_COEF_IDLE 0xF5 // 7 0 duration of idle phase in Listen mode
162 
163 // RADIOLIB_RF69_REG_LISTEN_3
164 #define RADIOLIB_RF69_LISTEN_COEF_RX 0x20 // 7 0 duration of Rx phase in Listen mode
165 
166 // RADIOLIB_RF69_REG_VERSION
167 #define RADIOLIB_RF69_CHIP_VERSION 0x24 // 7 0
168 
169 // RADIOLIB_RF69_REG_PA_LEVEL
170 #define RADIOLIB_RF69_PA0_OFF 0b00000000 // 7 7 PA0 disabled
171 #define RADIOLIB_RF69_PA0_ON 0b10000000 // 7 7 PA0 enabled (default)
172 #define RADIOLIB_RF69_PA1_OFF 0b00000000 // 6 6 PA1 disabled (default)
173 #define RADIOLIB_RF69_PA1_ON 0b01000000 // 6 6 PA1 enabled
174 #define RADIOLIB_RF69_PA2_OFF 0b00000000 // 5 5 PA2 disabled (default)
175 #define RADIOLIB_RF69_PA2_ON 0b00100000 // 5 5 PA2 enabled
176 #define RADIOLIB_RF69_OUTPUT_POWER 0b00011111 // 4 0 output power: P_out = -18 + OUTPUT_POWER
177 
178 // RADIOLIB_RF69_REG_PA_RAMP
179 #define RADIOLIB_RF69_PA_RAMP_3_4_MS 0b00000000 // 3 0 PA ramp rise/fall time: 3.4 ms
180 #define RADIOLIB_RF69_PA_RAMP_2_MS 0b00000001 // 3 0 2 ms
181 #define RADIOLIB_RF69_PA_RAMP_1_MS 0b00000010 // 3 0 1 ms
182 #define RADIOLIB_RF69_PA_RAMP_500_US 0b00000011 // 3 0 500 us
183 #define RADIOLIB_RF69_PA_RAMP_250_US 0b00000100 // 3 0 250 us
184 #define RADIOLIB_RF69_PA_RAMP_125_US 0b00000101 // 3 0 125 us
185 #define RADIOLIB_RF69_PA_RAMP_100_US 0b00000110 // 3 0 100 us
186 #define RADIOLIB_RF69_PA_RAMP_62_US 0b00000111 // 3 0 62 us
187 #define RADIOLIB_RF69_PA_RAMP_50_US 0b00001000 // 3 0 50 us
188 #define RADIOLIB_RF69_PA_RAMP_40_US 0b00001001 // 3 0 40 us (default)
189 #define RADIOLIB_RF69_PA_RAMP_31_US 0b00001010 // 3 0 31 us
190 #define RADIOLIB_RF69_PA_RAMP_25_US 0b00001011 // 3 0 25 us
191 #define RADIOLIB_RF69_PA_RAMP_20_US 0b00001100 // 3 0 20 us
192 #define RADIOLIB_RF69_PA_RAMP_15_US 0b00001101 // 3 0 15 us
193 #define RADIOLIB_RF69_PA_RAMP_12_US 0b00001110 // 3 0 12 us
194 #define RADIOLIB_RF69_PA_RAMP_10_US 0b00001111 // 3 0 10 us
195 
196 // RADIOLIB_RF69_REG_OCP
197 #define RADIOLIB_RF69_OCP_OFF 0b00000000 // 4 4 PA overload current protection disabled
198 #define RADIOLIB_RF69_OCP_ON 0b00010000 // 4 4 PA overload current protection enabled
199 #define RADIOLIB_RF69_OCP_TRIM 0b00001010 // 3 0 OCP current: I_max(OCP_TRIM = 0b1010) = 95 mA
200 
201 // RADIOLIB_RF69_REG_LNA
202 #define RADIOLIB_RF69_LNA_Z_IN_50_OHM 0b00000000 // 7 7 LNA input impedance: 50 ohm
203 #define RADIOLIB_RF69_LNA_Z_IN_200_OHM 0b10000000 // 7 7 200 ohm
204 #define RADIOLIB_RF69_LNA_CURRENT_GAIN 0b00001000 // 5 3 manually set LNA current gain
205 #define RADIOLIB_RF69_LNA_GAIN_AUTO 0b00000000 // 2 0 LNA gain setting: set automatically by AGC
206 #define RADIOLIB_RF69_LNA_GAIN_MAX 0b00000001 // 2 0 max gain
207 #define RADIOLIB_RF69_LNA_GAIN_MAX_6_DB 0b00000010 // 2 0 max gain - 6 dB
208 #define RADIOLIB_RF69_LNA_GAIN_MAX_12_DB 0b00000011 // 2 0 max gain - 12 dB
209 #define RADIOLIB_RF69_LNA_GAIN_MAX_24_DB 0b00000100 // 2 0 max gain - 24 dB
210 #define RADIOLIB_RF69_LNA_GAIN_MAX_36_DB 0b00000101 // 2 0 max gain - 36 dB
211 #define RADIOLIB_RF69_LNA_GAIN_MAX_48_DB 0b00000110 // 2 0 max gain - 48 dB
212 
213 // RADIOLIB_RF69_REG_RX_BW
214 #define RADIOLIB_RF69_DCC_FREQ 0b01000000 // 7 5 DC offset canceller cutoff frequency (4% Rx BW by default)
215 #define RADIOLIB_RF69_RX_BW_MANT_16 0b00000000 // 4 3 Channel filter bandwidth FSK: RxBw = F(XOSC)/(RxBwMant * 2^(RxBwExp + 2))
216 #define RADIOLIB_RF69_RX_BW_MANT_20 0b00001000 // 4 3 OOK: RxBw = F(XOSC)/(RxBwMant * 2^(RxBwExp + 3))
217 #define RADIOLIB_RF69_RX_BW_MANT_24 0b00010000 // 4 3
218 #define RADIOLIB_RF69_RX_BW_EXP 0b00000101 // 2 0 default RxBwExp value = 5
219 
220 // RADIOLIB_RF69_REG_AFC_BW
221 #define RADIOLIB_RF69_DCC_FREQ_AFC 0b10000000 // 7 5 default DccFreq parameter for AFC
222 #define RADIOLIB_RF69_DCC_RX_BW_MANT_AFC 0b00001000 // 4 3 default RxBwMant parameter for AFC
223 #define RADIOLIB_RF69_DCC_RX_BW_EXP_AFC 0b00000011 // 2 0 default RxBwExp parameter for AFC
224 
225 // RADIOLIB_RF69_REG_OOK_PEAK
226 #define RADIOLIB_RF69_OOK_THRESH_FIXED 0b00000000 // 7 6 OOK threshold type: fixed
227 #define RADIOLIB_RF69_OOK_THRESH_PEAK 0b01000000 // 7 6 peak (default)
228 #define RADIOLIB_RF69_OOK_THRESH_AVERAGE 0b10000000 // 7 6 average
229 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_0_5_DB 0b00000000 // 5 3 OOK demodulator step size: 0.5 dB (default)
230 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_1_0_DB 0b00001000 // 5 3 1.0 dB
231 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_1_5_DB 0b00010000 // 5 3 1.5 dB
232 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_2_0_DB 0b00011000 // 5 3 2.0 dB
233 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_3_0_DB 0b00100000 // 5 3 3.0 dB
234 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_4_0_DB 0b00101000 // 5 3 4.0 dB
235 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_5_0_DB 0b00110000 // 5 3 5.0 dB
236 #define RADIOLIB_RF69_OOK_PEAK_THRESH_STEP_6_0_DB 0b00111000 // 5 3 6.0 dB
237 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_1_1_CHIP 0b00000000 // 2 0 OOK demodulator step period: once per chip (default)
238 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_1_2_CHIP 0b00000001 // 2 0 once every 2 chips
239 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_1_4_CHIP 0b00000010 // 2 0 once every 4 chips
240 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_1_8_CHIP 0b00000011 // 2 0 once every 8 chips
241 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_2_1_CHIP 0b00000100 // 2 0 2 times per chip
242 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_4_1_CHIP 0b00000101 // 2 0 4 times per chip
243 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_8_1_CHIP 0b00000110 // 2 0 8 times per chip
244 #define RADIOLIB_RF69_OOK_PEAK_THRESH_DEC_16_1_CHIP 0b00000111 // 2 0 16 times per chip
245 
246 // RADIOLIB_RF69_REG_OOK_AVG
247 #define RADIOLIB_RF69_OOK_AVG_THRESH_FILT_32_PI 0b00000000 // 7 6 OOK average filter coefficient: chip rate / 32*pi
248 #define RADIOLIB_RF69_OOK_AVG_THRESH_FILT_8_PI 0b01000000 // 7 6 chip rate / 8*pi
249 #define RADIOLIB_RF69_OOK_AVG_THRESH_FILT_4_PI 0b10000000 // 7 6 chip rate / 4*pi (default)
250 #define RADIOLIB_RF69_OOK_AVG_THRESH_FILT_2_PI 0b11000000 // 7 6 chip rate / 2*pi
251 
252 // RADIOLIB_RF69_REG_OOK_FIX
253 #define RADIOLIB_RF69_OOK_FIXED_THRESH 0b00000110 // 7 0 default OOK fixed threshold (6 dB)
254 
255 // RADIOLIB_RF69_REG_AFC_FEI
256 #define RADIOLIB_RF69_FEI_RUNNING 0b00000000 // 6 6 FEI status: on-going
257 #define RADIOLIB_RF69_FEI_DONE 0b01000000 // 6 6 done
258 #define RADIOLIB_RF69_FEI_START 0b00100000 // 5 5 force new FEI measurement
259 #define RADIOLIB_RF69_AFC_RUNNING 0b00000000 // 4 4 AFC status: on-going
260 #define RADIOLIB_RF69_AFC_DONE 0b00010000 // 4 4 done
261 #define RADIOLIB_RF69_AFC_AUTOCLEAR_OFF 0b00000000 // 3 3 AFC register autoclear disabled
262 #define RADIOLIB_RF69_AFC_AUTOCLEAR_ON 0b00001000 // 3 3 AFC register autoclear enabled
263 #define RADIOLIB_RF69_AFC_AUTO_OFF 0b00000000 // 2 2 perform AFC only manually
264 #define RADIOLIB_RF69_AFC_AUTO_ON 0b00000100 // 2 2 perform AFC each time Rx mode is started
265 #define RADIOLIB_RF69_AFC_CLEAR 0b00000010 // 1 1 clear AFC register
266 #define RADIOLIB_RF69_AFC_START 0b00000001 // 0 0 start AFC
267 
268 // RADIOLIB_RF69_REG_RSSI_CONFIG
269 #define RADIOLIB_RF69_RSSI_RUNNING 0b00000000 // 1 1 RSSI status: on-going
270 #define RADIOLIB_RF69_RSSI_DONE 0b00000010 // 1 1 done
271 #define RADIOLIB_RF69_RSSI_START 0b00000001 // 0 0 start RSSI measurement
272 
273 // RADIOLIB_RF69_REG_DIO_MAPPING_1
274 #define RADIOLIB_RF69_DIO0_CONT_MODE_READY 0b11000000 // 7 6
275 #define RADIOLIB_RF69_DIO0_CONT_PLL_LOCK 0b00000000 // 7 6
276 #define RADIOLIB_RF69_DIO0_CONT_SYNC_ADDRESS 0b00000000 // 7 6
277 #define RADIOLIB_RF69_DIO0_CONT_TIMEOUT 0b01000000 // 7 6
278 #define RADIOLIB_RF69_DIO0_CONT_RSSI 0b10000000 // 7 6
279 #define RADIOLIB_RF69_DIO0_CONT_TX_READY 0b01000000 // 7 6
280 #define RADIOLIB_RF69_DIO0_PACK_PLL_LOCK 0b11000000 // 7 6
281 #define RADIOLIB_RF69_DIO0_PACK_CRC_OK 0b00000000 // 7 6
282 #define RADIOLIB_RF69_DIO0_PACK_PAYLOAD_READY 0b01000000 // 7 6
283 #define RADIOLIB_RF69_DIO0_PACK_SYNC_ADDRESS 0b10000000 // 7 6
284 #define RADIOLIB_RF69_DIO0_PACK_RSSI 0b11000000 // 7 6
285 #define RADIOLIB_RF69_DIO0_PACK_PACKET_SENT 0b00000000 // 7 6
286 #define RADIOLIB_RF69_DIO0_PACK_TX_READY 0b01000000 // 7 6
287 #define RADIOLIB_RF69_DIO1_CONT_PLL_LOCK 0b00110000 // 5 4
288 #define RADIOLIB_RF69_DIO1_CONT_DCLK 0b00000000 // 5 4
289 #define RADIOLIB_RF69_DIO1_CONT_RX_READY 0b00010000 // 5 4
290 #define RADIOLIB_RF69_DIO1_CONT_SYNC_ADDRESS 0b00110000 // 5 4
291 #define RADIOLIB_RF69_DIO1_CONT_TX_READY 0b00010000 // 5 4
292 #define RADIOLIB_RF69_DIO1_PACK_FIFO_LEVEL 0b00000000 // 5 4
293 #define RADIOLIB_RF69_DIO1_PACK_FIFO_FULL 0b00010000 // 5 4
294 #define RADIOLIB_RF69_DIO1_PACK_FIFO_NOT_EMPTY 0b00100000 // 5 4
295 #define RADIOLIB_RF69_DIO1_PACK_PLL_LOCK 0b00110000 // 5 4
296 #define RADIOLIB_RF69_DIO1_PACK_TIMEOUT 0b00110000 // 5 4
297 #define RADIOLIB_RF69_DIO2_CONT_DATA 0b00000000 // 3 2
298 #define RADIOLIB_RF69_DIO2_PACK_FIFO_NOT_EMPTY 0b00000000 // 3 2
299 #define RADIOLIB_RF69_DIO2_PACK_AUTO_MODE 0b00001100 // 3 2
300 #define RADIOLIB_RF69_DIO2_PACK_DATA 0b00000100 // 3 2
301 #define RADIOLIB_RF69_DIO3_CONT_AUTO_MODE 0b00000010 // 0 1
302 #define RADIOLIB_RF69_DIO3_CONT_RSSI 0b00000000 // 0 1
303 #define RADIOLIB_RF69_DIO3_CONT_RX_READY 0b00000001 // 0 1
304 #define RADIOLIB_RF69_DIO3_CONT_TIMEOUT 0b00000011 // 0 1
305 #define RADIOLIB_RF69_DIO3_CONT_TX_READY 0b00000001 // 0 1
306 #define RADIOLIB_RF69_DIO3_PACK_FIFO_FULL 0b00000000 // 0 1
307 #define RADIOLIB_RF69_DIO3_PACK_PLL_LOCK 0b00000011 // 0 1
308 #define RADIOLIB_RF69_DIO3_PACK_RSSI 0b00000001 // 0 1
309 #define RADIOLIB_RF69_DIO3_PACK_SYNC_ADDRESSS 0b00000010 // 0 1
310 #define RADIOLIB_RF69_DIO3_PACK_TX_READY 0b00000001 // 0 1
311 
312 // RADIOLIB_RF69_REG_DIO_MAPPING_2
313 #define RADIOLIB_RF69_DIO4_CONT_PLL_LOCK 0b11000000 // 7 6
314 #define RADIOLIB_RF69_DIO4_CONT_TIMEOUT 0b00000000 // 7 6
315 #define RADIOLIB_RF69_DIO4_CONT_RX_READY 0b01000000 // 7 6
316 #define RADIOLIB_RF69_DIO4_CONT_SYNC_ADDRESS 0b10000000 // 7 6
317 #define RADIOLIB_RF69_DIO4_CONT_TX_READY 0b01000000 // 7 6
318 #define RADIOLIB_RF69_DIO4_PACK_PLL_LOCK 0b11000000 // 7 6
319 #define RADIOLIB_RF69_DIO4_PACK_TIMEOUT 0b00000000 // 7 6
320 #define RADIOLIB_RF69_DIO4_PACK_RSSI 0b01000000 // 7 6
321 #define RADIOLIB_RF69_DIO4_PACK_RX_READY 0b10000000 // 7 6
322 #define RADIOLIB_RF69_DIO4_PACK_MODE_READY 0b00000000 // 7 6
323 #define RADIOLIB_RF69_DIO4_PACK_TX_READY 0b01000000 // 7 6
324 #define RADIOLIB_RF69_DIO5_CONT_MODE_READY 0b00110000 // 5 4
325 #define RADIOLIB_RF69_DIO5_CONT_CLK_OUT 0b00000000 // 5 4
326 #define RADIOLIB_RF69_DIO5_CONT_RSSI 0b00010000 // 5 4
327 #define RADIOLIB_RF69_DIO5_PACK_MODE_READY 0b00110000 // 5 4
328 #define RADIOLIB_RF69_DIO5_PACK_CLK_OUT 0b00000000 // 5 4
329 #define RADIOLIB_RF69_DIO5_PACK_DATA 0b00010000 // 5 4
330 #define RADIOLIB_RF69_CLK_OUT_FXOSC 0b00000000 // 2 0 ClkOut frequency: F(XOSC)
331 #define RADIOLIB_RF69_CLK_OUT_FXOSC_2 0b00000001 // 2 0 F(XOSC) / 2
332 #define RADIOLIB_RF69_CLK_OUT_FXOSC_4 0b00000010 // 2 0 F(XOSC) / 4
333 #define RADIOLIB_RF69_CLK_OUT_FXOSC_8 0b00000011 // 2 0 F(XOSC) / 8
334 #define RADIOLIB_RF69_CLK_OUT_FXOSC_16 0b00000100 // 2 0 F(XOSC) / 16
335 #define RADIOLIB_RF69_CLK_OUT_FXOSC_32 0b00000101 // 2 0 F(XOSC) / 31
336 #define RADIOLIB_RF69_CLK_OUT_RC 0b00000110 // 2 0 RC
337 #define RADIOLIB_RF69_CLK_OUT_OFF 0b00000111 // 2 0 disabled (default)
338 
339 // RADIOLIB_RF69_REG_IRQ_FLAGS_1
340 #define RADIOLIB_RF69_IRQ_MODE_READY 0b10000000 // 7 7 requested mode was set
341 #define RADIOLIB_RF69_IRQ_RX_READY 0b01000000 // 6 6 Rx mode ready
342 #define RADIOLIB_RF69_IRQ_TX_READY 0b00100000 // 5 5 Tx mode ready
343 #define RADIOLIB_RF69_IRQ_PLL_LOCK 0b00010000 // 4 4 PLL is locked
344 #define RADIOLIB_RF69_IRQ_RSSI 0b00001000 // 3 3 RSSI value exceeded RssiThreshold
345 #define RADIOLIB_RF69_IRQ_TIMEOUT 0b00000100 // 2 2 timeout occurred
346 #define RADIOLIB_RF69_IRQ_AUTO_MODE 0b00000010 // 1 1 entered intermediate mode
347 #define RADIOLIB_RF69_SYNC_ADDRESS_MATCH 0b00000001 // 0 0 sync address detected
348 
349 // RADIOLIB_RF69_REG_IRQ_FLAGS_2
350 #define RADIOLIB_RF69_IRQ_FIFO_FULL 0b10000000 // 7 7 FIFO is full
351 #define RADIOLIB_RF69_IRQ_FIFO_NOT_EMPTY 0b01000000 // 6 6 FIFO contains at least 1 byte
352 #define RADIOLIB_RF69_IRQ_FIFO_LEVEL 0b00100000 // 5 5 FIFO contains more than FifoThreshold bytes
353 #define RADIOLIB_RF69_IRQ_FIFO_OVERRUN 0b00010000 // 4 4 FIFO overrun occurred
354 #define RADIOLIB_RF69_IRQ_PACKET_SENT 0b00001000 // 3 3 packet was sent
355 #define RADIOLIB_RF69_IRQ_PAYLOAD_READY 0b00000100 // 2 2 last payload byte received and CRC check passed
356 #define RADIOLIB_RF69_IRQ_CRC_OK 0b00000010 // 1 1 CRC check passed
357 
358 // RADIOLIB_RF69_REG_RSSI_THRESH
359 #define RADIOLIB_RF69_RSSI_THRESHOLD 0xE4 // 7 0 RSSI threshold level (2 dB by default)
360 
361 // RADIOLIB_RF69_REG_RX_TIMEOUT_1
362 #define RADIOLIB_RF69_TIMEOUT_RX_START_OFF 0x00 // 7 0 RSSI interrupt timeout disabled (default)
363 #define RADIOLIB_RF69_TIMEOUT_RX_START 0xFF // 7 0 timeout will occur if RSSI interrupt is not received
364 
365 // RADIOLIB_RF69_REG_RX_TIMEOUT_2
366 #define RADIOLIB_RF69_TIMEOUT_RSSI_THRESH_OFF 0x00 // 7 0 PayloadReady interrupt timeout disabled (default)
367 #define RADIOLIB_RF69_TIMEOUT_RSSI_THRESH 0xFF // 7 0 timeout will occur if PayloadReady interrupt is not received
368 
369 // RADIOLIB_RF69_REG_PREAMBLE_MSB + REG_PREAMBLE_MSB
370 #define RADIOLIB_RF69_PREAMBLE_MSB 0x00 // 7 0 2-byte preamble size value
371 #define RADIOLIB_RF69_PREAMBLE_LSB 0x03 // 7 0
372 
373 // RADIOLIB_RF69_REG_SYNC_CONFIG
374 #define RADIOLIB_RF69_SYNC_OFF 0b00000000 // 7 7 sync word detection off
375 #define RADIOLIB_RF69_SYNC_ON 0b10000000 // 7 7 sync word detection on (default)
376 #define RADIOLIB_RF69_FIFO_FILL_CONDITION_SYNC 0b00000000 // 6 6 FIFO fill condition: on SyncAddress interrupt (default)
377 #define RADIOLIB_RF69_FIFO_FILL_CONDITION 0b01000000 // 6 6 as long as the bit is set
378 #define RADIOLIB_RF69_SYNC_SIZE 0b00001000 // 5 3 size of sync word: SyncSize + 1 bytes
379 #define RADIOLIB_RF69_SYNC_TOL 0b00000000 // 2 0 number of tolerated errors in sync word
380 
381 // RADIOLIB_RF69_REG_SYNC_VALUE_1 - SYNC_VALUE_8
382 #define RADIOLIB_RF69_SYNC_BYTE_1 0x01 // 7 0 sync word: 1st byte (MSB)
383 #define RADIOLIB_RF69_SYNC_BYTE_2 0x01 // 7 0 2nd byte
384 #define RADIOLIB_RF69_SYNC_BYTE_3 0x01 // 7 0 3rd byte
385 #define RADIOLIB_RF69_SYNC_BYTE_4 0x01 // 7 0 4th byte
386 #define RADIOLIB_RF69_SYNC_BYTE_5 0x01 // 7 0 5th byte
387 #define RADIOLIB_RF69_SYNC_BYTE_6 0x01 // 7 0 6th byte
388 #define RADIOLIB_RF69_SYNC_BYTE_7 0x01 // 7 0 7th byte
389 #define RADIOLIB_RF69_SYNC_BYTE_8 0x01 // 7 0 8th byte (LSB)
390 
391 // RADIOLIB_RF69_REG_PACKET_CONFIG_1
392 #define RADIOLIB_RF69_PACKET_FORMAT_FIXED 0b00000000 // 7 7 fixed packet length (default)
393 #define RADIOLIB_RF69_PACKET_FORMAT_VARIABLE 0b10000000 // 7 7 variable packet length
394 #define RADIOLIB_RF69_DC_FREE_NONE 0b00000000 // 6 5 DC-free encoding: none (default)
395 #define RADIOLIB_RF69_DC_FREE_MANCHESTER 0b00100000 // 6 5 Manchester
396 #define RADIOLIB_RF69_DC_FREE_WHITENING 0b01000000 // 6 5 Whitening
397 #define RADIOLIB_RF69_CRC_OFF 0b00000000 // 4 4 CRC disabled
398 #define RADIOLIB_RF69_CRC_ON 0b00010000 // 4 4 CRC enabled (default)
399 #define RADIOLIB_RF69_CRC_AUTOCLEAR_ON 0b00000000 // 3 3 discard packet when CRC check fails (default)
400 #define RADIOLIB_RF69_CRC_AUTOCLEAR_OFF 0b00001000 // 3 3 keep packet when CRC check fails
401 #define RADIOLIB_RF69_ADDRESS_FILTERING_OFF 0b00000000 // 2 1 address filtering: none (default)
402 #define RADIOLIB_RF69_ADDRESS_FILTERING_NODE 0b00000010 // 2 1 node
403 #define RADIOLIB_RF69_ADDRESS_FILTERING_NODE_BROADCAST 0b00000100 // 2 1 node or broadcast
404 
405 // RADIOLIB_RF69_REG_PAYLOAD_LENGTH
406 #define RADIOLIB_RF69_PAYLOAD_LENGTH 0xFF // 7 0 payload length
407 
408 // RADIOLIB_RF69_REG_AUTO_MODES
409 #define RADIOLIB_RF69_ENTER_COND_NONE 0b00000000 // 7 5 condition for entering intermediate mode: none, AutoModes disabled (default)
410 #define RADIOLIB_RF69_ENTER_COND_FIFO_NOT_EMPTY 0b00100000 // 7 5 FifoNotEmpty rising edge
411 #define RADIOLIB_RF69_ENTER_COND_FIFO_LEVEL 0b01000000 // 7 5 FifoLevel rising edge
412 #define RADIOLIB_RF69_ENTER_COND_CRC_OK 0b01100000 // 7 5 CrcOk rising edge
413 #define RADIOLIB_RF69_ENTER_COND_PAYLOAD_READY 0b10000000 // 7 5 PayloadReady rising edge
414 #define RADIOLIB_RF69_ENTER_COND_SYNC_ADDRESS 0b10100000 // 7 5 SyncAddress rising edge
415 #define RADIOLIB_RF69_ENTER_COND_PACKET_SENT 0b11000000 // 7 5 PacketSent rising edge
416 #define RADIOLIB_RF69_ENTER_COND_FIFO_EMPTY 0b11100000 // 7 5 FifoNotEmpty falling edge
417 #define RADIOLIB_RF69_EXIT_COND_NONE 0b00000000 // 4 2 condition for exiting intermediate mode: none, AutoModes disabled (default)
418 #define RADIOLIB_RF69_EXIT_COND_FIFO_EMPTY 0b00100000 // 4 2 FifoNotEmpty falling edge
419 #define RADIOLIB_RF69_EXIT_COND_FIFO_LEVEL 0b01000000 // 4 2 FifoLevel rising edge
420 #define RADIOLIB_RF69_EXIT_COND_CRC_OK 0b01100000 // 4 2 CrcOk rising edge
421 #define RADIOLIB_RF69_EXIT_COND_PAYLOAD_READY 0b10000000 // 4 2 PayloadReady rising edge
422 #define RADIOLIB_RF69_EXIT_COND_SYNC_ADDRESS 0b10100000 // 4 2 SyncAddress rising edge
423 #define RADIOLIB_RF69_EXIT_COND_PACKET_SENT 0b11000000 // 4 2 PacketSent rising edge
424 #define RADIOLIB_RF69_EXIT_COND_TIMEOUT 0b11100000 // 4 2 timeout rising edge
425 #define RADIOLIB_RF69_INTER_MODE_SLEEP 0b00000000 // 1 0 intermediate mode: sleep (default)
426 #define RADIOLIB_RF69_INTER_MODE_STANDBY 0b00000001 // 1 0 standby
427 #define RADIOLIB_RF69_INTER_MODE_RX 0b00000010 // 1 0 Rx
428 #define RADIOLIB_RF69_INTER_MODE_TX 0b00000011 // 1 0 Tx
429 
430 // RADIOLIB_RF69_REG_FIFO_THRESH
431 #define RADIOLIB_RF69_TX_START_CONDITION_FIFO_LEVEL 0b00000000 // 7 7 packet transmission start condition: FifoLevel
432 #define RADIOLIB_RF69_TX_START_CONDITION_FIFO_NOT_EMPTY 0b10000000 // 7 7 FifoNotEmpty (default)
433 #define RADIOLIB_RF69_FIFO_THRESH 0x1F // 6 0 default threshold to trigger FifoLevel interrupt
434 
435 // RADIOLIB_RF69_REG_PACKET_CONFIG_2
436 #define RADIOLIB_RF69_INTER_PACKET_RX_DELAY 0b00000000 // 7 4 delay between FIFO empty and start of new RSSI phase
437 #define RADIOLIB_RF69_RESTART_RX 0b00000100 // 2 2 force receiver into wait mode
438 #define RADIOLIB_RF69_AUTO_RX_RESTART_OFF 0b00000000 // 1 1 auto Rx restart disabled
439 #define RADIOLIB_RF69_AUTO_RX_RESTART_ON 0b00000010 // 1 1 auto Rx restart enabled (default)
440 #define RADIOLIB_RF69_AES_OFF 0b00000000 // 0 0 AES encryption disabled (default)
441 #define RADIOLIB_RF69_AES_ON 0b00000001 // 0 0 AES encryption enabled, payload size limited to 66 bytes
442 
443 // RADIOLIB_RF69_REG_TEST_LNA
444 #define RADIOLIB_RF69_TEST_LNA_BOOST_NORMAL 0x1B // 7 0
445 #define RADIOLIB_RF69_TEST_LNA_BOOST_HIGH 0x2D // 7 0
446 
447 // RADIOLIB_RF69_REG_TEMP_1
448 #define RADIOLIB_RF69_TEMP_MEAS_START 0b00001000 // 3 3 trigger temperature measurement
449 #define RADIOLIB_RF69_TEMP_MEAS_RUNNING 0b00000100 // 2 2 temperature measurement status: on-going
450 #define RADIOLIB_RF69_TEMP_MEAS_DONE 0b00000000 // 2 2 done
451 
452 // RADIOLIB_RF69_REG_TEST_DAGC
453 #define RADIOLIB_RF69_CONTINUOUS_DAGC_NORMAL 0x00 // 7 0 fading margin improvement: normal mode
454 #define RADIOLIB_RF69_CONTINUOUS_DAGC_LOW_BETA_ON 0x20 // 7 0 improved mode for AfcLowBetaOn
455 #define RADIOLIB_RF69_CONTINUOUS_DAGC_LOW_BETA_OFF 0x30 // 7 0 improved mode for AfcLowBetaOff (default)
456 
457 // RADIOLIB_RF69_REG_TEST_PA1
458 #define RADIOLIB_RF69_PA1_NORMAL 0x55 // 7 0 PA_BOOST: none
459 #define RADIOLIB_RF69_PA1_20_DBM 0x5D // 7 0 +20 dBm
460 
461 // RADIOLIB_RF69_REG_TEST_PA2
462 #define RADIOLIB_RF69_PA2_NORMAL 0x70 // 7 0 PA_BOOST: none
463 #define RADIOLIB_RF69_PA2_20_DBM 0x7C // 7 0 +20 dBm
464 
465 // RadioLib defaults
466 #define RADIOLIB_RF69_DEFAULT_FREQ 434.0
467 #define RADIOLIB_RF69_DEFAULT_BR 4.8
468 #define RADIOLIB_RF69_DEFAULT_FREQDEV 5.0
469 #define RADIOLIB_RF69_DEFAULT_RXBW 125.0
470 #define RADIOLIB_RF69_DEFAULT_POWER 10
471 #define RADIOLIB_RF69_DEFAULT_PREAMBLELEN 16
472 #define RADIOLIB_RF69_DEFAULT_SW {0x12, 0xAD}
473 #define RADIOLIB_RF69_DEFAULT_SW_LEN 2
474 
479 class RF69: public PhysicalLayer {
480  public:
481  // introduce PhysicalLayer overloads
486 
491  RF69(Module* module);
492 
493  Module* getMod();
494 
495  // basic methods
496 
507  int16_t begin(
508  float freq = RADIOLIB_RF69_DEFAULT_FREQ,
509  float br = RADIOLIB_RF69_DEFAULT_BR,
510  float freqDev = RADIOLIB_RF69_DEFAULT_FREQDEV,
511  float rxBw = RADIOLIB_RF69_DEFAULT_RXBW,
512  int8_t pwr = RADIOLIB_RF69_DEFAULT_POWER,
513  uint8_t preambleLen = RADIOLIB_RF69_DEFAULT_PREAMBLELEN);
514 
518  void reset();
519 
528  int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
529 
537  int16_t receive(uint8_t* data, size_t len) override;
538 
543  int16_t sleep();
544 
549  int16_t standby() override;
550 
556  int16_t standby(uint8_t mode) override;
557 
563  int16_t transmitDirect(uint32_t frf = 0) override;
564 
569  int16_t receiveDirect() override;
570 
574  int16_t packetMode();
575 
576  // hardware AES support
577 
582  void setAESKey(uint8_t* key);
583 
588  int16_t enableAES();
589 
594  int16_t disableAES();
595 
596  // interrupt methods
597 
602  void setDio0Action(void (*func)(void));
603 
607  void clearDio0Action();
608 
613  void setDio1Action(void (*func)(void));
614 
618  void clearDio1Action();
619 
624  void setFifoEmptyAction(void (*func)(void));
625 
629  void clearFifoEmptyAction();
630 
635  void setFifoFullAction(void (*func)(void));
636 
640  void clearFifoFullAction();
641 
649  bool fifoAdd(uint8_t* data, int totalLen, int* remLen);
650 
658  bool fifoGet(volatile uint8_t* data, int totalLen, volatile int* rcvLen);
659 
668  int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
669 
674  int16_t finishTransmit() override;
675 
680  int16_t startReceive();
681 
690  int16_t startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask, size_t len);
691 
699  int16_t readData(uint8_t* data, size_t len) override;
700 
701  // configuration methods
702 
709  int16_t setFrequency(float freq);
710 
716  int16_t getFrequency(float *freq);
717 
723  int16_t setBitRate(float br);
724 
731  int16_t setRxBandwidth(float rxBw);
732 
738  int16_t setFrequencyDeviation(float freqDev) override;
739 
745  int16_t getFrequencyDeviation(float *freqDev);
746 
755  int16_t setOutputPower(int8_t pwr, bool highPower = false);
756 
763  int16_t setSyncWord(uint8_t* syncWord, size_t len, uint8_t maxErrBits = 0);
764 
770  int16_t setPreambleLength(uint8_t preambleLen);
771 
777  int16_t setNodeAddress(uint8_t nodeAddr);
778 
784  int16_t setBroadcastAddress(uint8_t broadAddr);
785 
790  int16_t disableAddressFiltering();
791 
792  // measurement methods
793 
798  void setAmbientTemperature(int16_t tempAmbient);
799 
804  int16_t getTemperature();
805 
811  size_t getPacketLength(bool update = true) override;
812 
819  int16_t setOOK(bool enable);
820 
827  int16_t setOokThresholdType(uint8_t type);
828 
836  int16_t setOokFixedThreshold(uint8_t value);
837 
843  int16_t setOokPeakThresholdDecrement(uint8_t value);
844 
850  int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_RF69_MAX_PACKET_LENGTH);
851 
857  int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_RF69_MAX_PACKET_LENGTH);
858 
864  int16_t enableSyncWordFiltering(uint8_t maxErrBits = 0);
865 
870  int16_t disableSyncWordFiltering();
871 
876  int16_t enableContinuousModeBitSync();
877 
883 
889  int16_t setCrcFiltering(bool crcOn = true);
890 
896  int16_t setPromiscuousMode(bool enable = true);
897 
905  int16_t setDataShaping(uint8_t sh) override;
906 
913  int16_t setEncoding(uint8_t encoding) override;
914 
920  int16_t setLnaTestBoost(bool value);
921 
926  float getRSSI();
927 
933  int16_t setRSSIThreshold(float dbm);
934 
936  void setRfSwitchPins(uint32_t rxEn, uint32_t txEn);
937 
939  void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
940 
945  uint8_t randomByte();
946 
951  int16_t getChipVersion();
952 
953  #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
958  void setDirectAction(void (*func)(void));
959 
964  void readBit(uint32_t pin);
965  #endif
966 
973  int16_t setDIOMapping(uint32_t pin, uint32_t value);
974 
975 #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
976  protected:
977 #endif
978  Module* mod;
979 
980 #if !defined(RADIOLIB_GODMODE)
981  protected:
982 #endif
983 
984  float frequency = RADIOLIB_RF69_DEFAULT_FREQ;
985  float bitRate = RADIOLIB_RF69_DEFAULT_BR;
986  float rxBandwidth = RADIOLIB_RF69_DEFAULT_RXBW;
987  bool ookEnabled = false;
988  int16_t tempOffset = 0;
989  int8_t power = RADIOLIB_RF69_DEFAULT_POWER;
990 
991  size_t packetLength = 0;
992  bool packetLengthQueried = false;
993  uint8_t packetLengthConfig = RADIOLIB_RF69_PACKET_FORMAT_VARIABLE;
994 
995  bool promiscuous = false;
996 
997  uint8_t syncWordLength = RADIOLIB_RF69_DEFAULT_SW_LEN;
998 
999  bool bitSync = true;
1000 
1001  int16_t config();
1002  int16_t directMode();
1003  int16_t setPacketMode(uint8_t mode, uint8_t len);
1004 
1005 #if !defined(RADIOLIB_GODMODE)
1006  private:
1007 #endif
1008  int16_t setMode(uint8_t mode);
1009  void clearIRQFlags();
1010  void clearFIFO(size_t count);
1011 };
1012 
1013 #endif
1014 
1015 #endif
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition: Module.h:28
static const size_t RFSWITCH_MAX_PINS
The maximum number of pins supported by the RF switch code.
Definition: Module.h:39
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:15
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition: PhysicalLayer.cpp:205
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition: PhysicalLayer.cpp:52
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition: PhysicalLayer.cpp:145
virtual int16_t receive(uint8_t *data, size_t len)
Binary receive method. Must be implemented in module class.
Definition: PhysicalLayer.cpp:112
Control class for RF69 module. Also serves as base class for SX1231.
Definition: RF69.h:479
int16_t getTemperature()
Measures temperature.
Definition: RF69.cpp:752
int16_t getChipVersion()
Read version SPI register. Should return RF69_CHIP_VERSION (0x24) if SX127x is connected and working.
Definition: RF69.cpp:969
int16_t setDIOMapping(uint32_t pin, uint32_t value)
Configure DIO pin mapping to get a given signal on a DIO pin (if available).
Definition: RF69.cpp:957
void clearFifoEmptyAction()
Clears interrupt service routine to call when FIFO is empty.
Definition: RF69.cpp:308
int16_t fixedPacketLengthMode(uint8_t len=RADIOLIB_RF69_MAX_PACKET_LENGTH)
Set modem in fixed packet length mode.
Definition: RF69.cpp:782
int16_t disableAES()
Disables AES encryption.
Definition: RF69.cpp:234
void setFifoFullAction(void(*func)(void))
Set interrupt service routine function to call when FIFO is full.
Definition: RF69.cpp:312
int16_t setBroadcastAddress(uint8_t broadAddr)
Sets broadcast address. Calling this method will also enable address filtering for node and broadcast...
Definition: RF69.cpp:726
int16_t enableAES()
Enables AES encryption.
Definition: RF69.cpp:230
uint8_t randomByte()
Get one truly random byte from RSSI noise.
Definition: RF69.cpp:928
int16_t standby() override
Sets the module to standby mode.
Definition: RF69.cpp:159
int16_t setOokThresholdType(uint8_t type)
Selects the type of threshold in the OOK data slicer.
Definition: RF69.cpp:493
int16_t transmitDirect(uint32_t frf=0) override
Starts direct mode transmission.
Definition: RF69.cpp:172
int16_t getFrequency(float *freq)
Gets carrier frequency.
Definition: RF69.cpp:529
int16_t setSyncWord(uint8_t *syncWord, size_t len, uint8_t maxErrBits=0)
Sets sync word. Up to 8 bytes can be set as sync word.
Definition: RF69.cpp:679
int16_t getFrequencyDeviation(float *freqDev)
Gets frequency deviation.
Definition: RF69.cpp:617
int16_t setOokFixedThreshold(uint8_t value)
Fixed threshold for the Data Slicer in OOK mode or floor threshold for the Data Slicer in OOK when Pe...
Definition: RF69.cpp:500
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition: PhysicalLayer.cpp:205
int16_t finishTransmit() override
Clean up after transmission is done.
Definition: RF69.cpp:429
int16_t disableSyncWordFiltering()
Disable preamble and sync word filtering and generation.
Definition: RF69.cpp:795
int16_t setDataShaping(uint8_t sh) override
Sets Gaussian filter bandwidth-time product that will be used for data shaping. Allowed values are RA...
Definition: RF69.cpp:864
int16_t setOokPeakThresholdDecrement(uint8_t value)
Period of decrement of the RSSI threshold in the OOK demodulator.
Definition: RF69.cpp:504
int16_t setOOK(bool enable)
Enables/disables OOK modulation instead of FSK. Note: This function calls setRxBandwidth again,...
Definition: RF69.cpp:474
int16_t sleep()
Sets the module to sleep mode.
Definition: RF69.cpp:151
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition: PhysicalLayer.cpp:52
int16_t disableAddressFiltering()
Disables address filtering. Calling this method will also erase previously set addresses.
Definition: RF69.cpp:735
int16_t begin(float freq=RADIOLIB_RF69_DEFAULT_FREQ, float br=RADIOLIB_RF69_DEFAULT_BR, float freqDev=RADIOLIB_RF69_DEFAULT_FREQDEV, float rxBw=RADIOLIB_RF69_DEFAULT_RXBW, int8_t pwr=RADIOLIB_RF69_DEFAULT_POWER, uint8_t preambleLen=RADIOLIB_RF69_DEFAULT_PREAMBLELEN)
Initialization method.
Definition: RF69.cpp:13
int16_t enableSyncWordFiltering(uint8_t maxErrBits=0)
Enable sync word filtering and generation.
Definition: RF69.cpp:790
int16_t packetMode()
Stops direct mode. It is required to call this method to switch from direct transmissions to packet-b...
Definition: RF69.cpp:222
int16_t setOutputPower(int8_t pwr, bool highPower=false)
Sets output power. Allowed values range from -18 to 13 dBm for low power modules (RF69C/CW) or -2 to ...
Definition: RF69.cpp:641
int16_t setRxBandwidth(float rxBw)
Sets receiver bandwidth. Allowed values are 2.6, 3.1, 3.9, 5.2, 6.3, 7.8, 10.4, 12....
Definition: RF69.cpp:566
void setFifoEmptyAction(void(*func)(void))
Set interrupt service routine function to call when FIFO is empty.
Definition: RF69.cpp:297
int16_t setPreambleLength(uint8_t preambleLen)
Sets preamble length.
Definition: RF69.cpp:705
int16_t enableContinuousModeBitSync()
Enable Bit synchronization in continuous mode.
Definition: RF69.cpp:800
void setDirectAction(void(*func)(void))
Set interrupt service routine function to call when data bit is receveid in direct mode.
Definition: RF69.cpp:948
size_t getPacketLength(bool update=true) override
Query modem for the packet length of received payload.
Definition: RF69.cpp:769
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition: PhysicalLayer.cpp:145
void clearDio0Action()
Clears interrupt service routine to call when DIO0 activates.
Definition: RF69.cpp:278
int16_t disableContinuousModeBitSync()
Disable Bit synchronization in continuous mode.
Definition: RF69.cpp:809
void setDio0Action(void(*func)(void))
Sets interrupt service routine to call when DIO0 activates.
Definition: RF69.cpp:274
int16_t setLnaTestBoost(bool value)
Enable/disable LNA Boost mode (disabled by default).
Definition: RF69.cpp:902
bool fifoGet(volatile uint8_t *data, int totalLen, volatile int *rcvLen)
Set interrupt service routine function to call when FIFO is sufficently full to read.
Definition: RF69.cpp:349
void setDio1Action(void(*func)(void))
Sets interrupt service routine to call when DIO1 activates.
Definition: RF69.cpp:282
int16_t setEncoding(uint8_t encoding) override
Sets transmission encoding. Allowed values are RADIOLIB_ENCODING_NRZ, RADIOLIB_ENCODING_MANCHESTER an...
Definition: RF69.cpp:884
int16_t setFrequency(float freq)
Sets carrier frequency. Allowed values are in bands 290.0 to 340.0 MHz, 431.0 to 510....
Definition: RF69.cpp:508
bool fifoAdd(uint8_t *data, int totalLen, int *remLen)
Set interrupt service routine function to call when FIFO is empty.
Definition: RF69.cpp:326
void readBit(uint32_t pin)
Function to read and process data bit in direct reception mode.
Definition: RF69.cpp:952
virtual int16_t receive(uint8_t *data, size_t len)
Binary receive method. Must be implemented in module class.
Definition: PhysicalLayer.cpp:112
int16_t setNodeAddress(uint8_t nodeAddr)
Sets node address. Calling this method will also enable address filtering for node address only.
Definition: RF69.cpp:717
int16_t receiveDirect() override
Starts direct mode reception.
Definition: RF69.cpp:193
void setAESKey(uint8_t *key)
Sets AES key.
Definition: RF69.cpp:226
int16_t setCrcFiltering(bool crcOn=true)
Enable CRC filtering and generation.
Definition: RF69.cpp:818
void setRfSwitchPins(uint32_t rxEn, uint32_t txEn)
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition: RF69.cpp:920
void setAmbientTemperature(int16_t tempAmbient)
Sets ambient temperature. Required to correct values from on-board temperature sensor.
Definition: RF69.cpp:748
float getRSSI()
Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
Definition: RF69.cpp:910
int16_t setBitRate(float br)
Sets bit rate. Allowed values range from 0.5 to 300.0 kbps.
Definition: RF69.cpp:544
int16_t setFrequencyDeviation(float freqDev) override
Sets frequency deviation.
Definition: RF69.cpp:594
void clearDio1Action()
Clears interrupt service routine to call when DIO1 activates.
Definition: RF69.cpp:290
int16_t setPromiscuousMode(bool enable=true)
Set modem in "sniff" mode: no packet filtering (e.g., no preamble, sync word, address,...
Definition: RF69.cpp:826
void clearFifoFullAction()
Clears interrupt service routine to call when FIFO is full.
Definition: RF69.cpp:321
int16_t variablePacketLengthMode(uint8_t maxLen=RADIOLIB_RF69_MAX_PACKET_LENGTH)
Set modem in variable packet length mode.
Definition: RF69.cpp:786
void reset()
Reset method. Will reset the chip to the default state using RST pin.
Definition: RF69.cpp:97
int16_t startReceive()
Interrupt-driven receive method. GDO0 will be activated when full packet is received.
Definition: RF69.cpp:238
RF69(Module *module)
Default constructor.
Definition: RF69.cpp:5
int16_t setRSSIThreshold(float dbm)
Sets the RSSI value above which the RSSI interrupt is signaled.
Definition: RF69.cpp:914
void setRfSwitchTable(const uint32_t(&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[])
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition: RF69.cpp:924
Definition: Module.h:46