RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
SX127x.h
1#if !defined(_RADIOLIB_SX127X_H)
2#define _RADIOLIB_SX127X_H
3
4#include "../../TypeDef.h"
5
6#if !RADIOLIB_EXCLUDE_SX127X
7
8#include "../../Module.h"
9
10#include "../../protocols/PhysicalLayer/PhysicalLayer.h"
11
12// SX127x physical layer properties
13#define RADIOLIB_SX127X_FREQUENCY_STEP_SIZE 61.03515625f
14#define RADIOLIB_SX127X_MAX_PACKET_LENGTH 255
15#define RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK 64 // as per datasheet Rev. 7, page 66, the FSK FIFO is just 64 bytes
16#define RADIOLIB_SX127X_CRYSTAL_FREQ 32.0f
17#define RADIOLIB_SX127X_DIV_EXPONENT 19
18#define RADIOLIB_SX1272_RFO_POUT_MIN -1
19#define RADIOLIB_SX1272_RFO_POUT_MAX 14
20#define RADIOLIB_SX1272_PA_BOOST_POUT_MIN 2
21#define RADIOLIB_SX1272_PA_BOOST_POUT_MAX 20
22#define RADIOLIB_SX1278_RFO_POUT_MIN -4
23#define RADIOLIB_SX1278_RFO_POUT_MAX 15
24#define RADIOLIB_SX1278_PA_BOOST_POUT_MIN 2
25#define RADIOLIB_SX1278_PA_BOOST_POUT_MAX 20
26
27// SX127x series common LoRa registers
28#define RADIOLIB_SX127X_REG_FIFO 0x00
29#define RADIOLIB_SX127X_REG_OP_MODE 0x01
30#define RADIOLIB_SX127X_REG_FRF_MSB 0x06
31#define RADIOLIB_SX127X_REG_FRF_MID 0x07
32#define RADIOLIB_SX127X_REG_FRF_LSB 0x08
33#define RADIOLIB_SX127X_REG_PA_CONFIG 0x09
34#define RADIOLIB_SX127X_REG_PA_RAMP 0x0A
35#define RADIOLIB_SX127X_REG_OCP 0x0B
36#define RADIOLIB_SX127X_REG_LNA 0x0C
37#define RADIOLIB_SX127X_REG_FIFO_ADDR_PTR 0x0D
38#define RADIOLIB_SX127X_REG_FIFO_TX_BASE_ADDR 0x0E
39#define RADIOLIB_SX127X_REG_FIFO_RX_BASE_ADDR 0x0F
40#define RADIOLIB_SX127X_REG_FIFO_RX_CURRENT_ADDR 0x10
41#define RADIOLIB_SX127X_REG_IRQ_FLAGS_MASK 0x11
42#define RADIOLIB_SX127X_REG_IRQ_FLAGS 0x12
43#define RADIOLIB_SX127X_REG_RX_NB_BYTES 0x13
44#define RADIOLIB_SX127X_REG_RX_HEADER_CNT_VALUE_MSB 0x14
45#define RADIOLIB_SX127X_REG_RX_HEADER_CNT_VALUE_LSB 0x15
46#define RADIOLIB_SX127X_REG_RX_PACKET_CNT_VALUE_MSB 0x16
47#define RADIOLIB_SX127X_REG_RX_PACKET_CNT_VALUE_LSB 0x17
48#define RADIOLIB_SX127X_REG_MODEM_STAT 0x18
49#define RADIOLIB_SX127X_REG_PKT_SNR_VALUE 0x19
50#define RADIOLIB_SX127X_REG_PKT_RSSI_VALUE 0x1A
51#define RADIOLIB_SX127X_REG_RSSI_VALUE 0x1B
52#define RADIOLIB_SX127X_REG_HOP_CHANNEL 0x1C
53#define RADIOLIB_SX127X_REG_MODEM_CONFIG_1 0x1D
54#define RADIOLIB_SX127X_REG_MODEM_CONFIG_2 0x1E
55#define RADIOLIB_SX127X_REG_SYMB_TIMEOUT_LSB 0x1F
56#define RADIOLIB_SX127X_REG_PREAMBLE_MSB 0x20
57#define RADIOLIB_SX127X_REG_PREAMBLE_LSB 0x21
58#define RADIOLIB_SX127X_REG_PAYLOAD_LENGTH 0x22
59#define RADIOLIB_SX127X_REG_MAX_PAYLOAD_LENGTH 0x23
60#define RADIOLIB_SX127X_REG_HOP_PERIOD 0x24
61#define RADIOLIB_SX127X_REG_FIFO_RX_BYTE_ADDR 0x25
62#define RADIOLIB_SX127X_REG_FEI_MSB 0x28
63#define RADIOLIB_SX127X_REG_FEI_MID 0x29
64#define RADIOLIB_SX127X_REG_FEI_LSB 0x2A
65#define RADIOLIB_SX127X_REG_RSSI_WIDEBAND 0x2C
66#define RADIOLIB_SX127X_REG_DETECT_OPTIMIZE 0x31
67#define RADIOLIB_SX127X_REG_INVERT_IQ 0x33
68#define RADIOLIB_SX127X_REG_DETECTION_THRESHOLD 0x37
69#define RADIOLIB_SX127X_REG_SYNC_WORD 0x39
70#define RADIOLIB_SX127X_REG_INVERT_IQ2 0x3B
71#define RADIOLIB_SX127X_REG_DIO_MAPPING_1 0x40
72#define RADIOLIB_SX127X_REG_DIO_MAPPING_2 0x41
73#define RADIOLIB_SX127X_REG_VERSION 0x42
74
75// SX127x common LoRa modem settings
76// RADIOLIB_SX127X_REG_OP_MODE MSB LSB DESCRIPTION
77#define RADIOLIB_SX127X_FSK_OOK 0b00000000 // 7 7 FSK/OOK mode
78#define RADIOLIB_SX127X_LORA 0b10000000 // 7 7 LoRa mode
79#define RADIOLIB_SX127X_ACCESS_SHARED_REG_OFF 0b00000000 // 6 6 access LoRa registers (0x0D:0x3F) in LoRa mode
80#define RADIOLIB_SX127X_ACCESS_SHARED_REG_ON 0b01000000 // 6 6 access FSK registers (0x0D:0x3F) in LoRa mode
81#define RADIOLIB_SX127X_SLEEP 0b00000000 // 2 0 sleep
82#define RADIOLIB_SX127X_STANDBY 0b00000001 // 2 0 standby
83#define RADIOLIB_SX127X_FSTX 0b00000010 // 2 0 frequency synthesis TX
84#define RADIOLIB_SX127X_TX 0b00000011 // 2 0 transmit
85#define RADIOLIB_SX127X_FSRX 0b00000100 // 2 0 frequency synthesis RX
86#define RADIOLIB_SX127X_RXCONTINUOUS 0b00000101 // 2 0 receive continuous
87#define RADIOLIB_SX127X_RXSINGLE 0b00000110 // 2 0 receive single
88#define RADIOLIB_SX127X_CAD 0b00000111 // 2 0 channel activity detection
89
90// RADIOLIB_SX127X_REG_PA_CONFIG
91#define RADIOLIB_SX127X_PA_SELECT_RFO 0b00000000 // 7 7 RFO pin output, power limited to +14 dBm
92#define RADIOLIB_SX127X_PA_SELECT_BOOST 0b10000000 // 7 7 PA_BOOST pin output, power limited to +20 dBm
93#define RADIOLIB_SX127X_OUTPUT_POWER 0b00001111 // 3 0 output power: P_out = 2 + OUTPUT_POWER [dBm] for PA_SELECT_BOOST
94 // P_out = -1 + OUTPUT_POWER [dBm] for PA_SELECT_RFO
95
96// RADIOLIB_SX127X_REG_OCP
97#define RADIOLIB_SX127X_OCP_OFF 0b00000000 // 5 5 PA overload current protection disabled
98#define RADIOLIB_SX127X_OCP_ON 0b00100000 // 5 5 PA overload current protection enabled
99#define RADIOLIB_SX127X_OCP_TRIM 0b00001011 // 4 0 OCP current: I_max(OCP_TRIM = 0b1011) = 100 mA
100
101// RADIOLIB_SX127X_REG_LNA
102#define RADIOLIB_SX127X_LNA_GAIN_1 0b00100000 // 7 5 LNA gain setting: max gain
103#define RADIOLIB_SX127X_LNA_GAIN_2 0b01000000 // 7 5 .
104#define RADIOLIB_SX127X_LNA_GAIN_3 0b01100000 // 7 5 .
105#define RADIOLIB_SX127X_LNA_GAIN_4 0b10000000 // 7 5 .
106#define RADIOLIB_SX127X_LNA_GAIN_5 0b10100000 // 7 5 .
107#define RADIOLIB_SX127X_LNA_GAIN_6 0b11000000 // 7 5 min gain
108#define RADIOLIB_SX127X_LNA_BOOST_OFF 0b00000000 // 1 0 default LNA current
109#define RADIOLIB_SX127X_LNA_BOOST_ON 0b00000011 // 1 0 150% LNA current
110
111// RADIOLIB_SX127X_REG_MODEM_CONFIG_2
112#define RADIOLIB_SX127X_SF_6 0b01100000 // 7 4 spreading factor: 64 chips/bit
113#define RADIOLIB_SX127X_SF_7 0b01110000 // 7 4 128 chips/bit
114#define RADIOLIB_SX127X_SF_8 0b10000000 // 7 4 256 chips/bit
115#define RADIOLIB_SX127X_SF_9 0b10010000 // 7 4 512 chips/bit
116#define RADIOLIB_SX127X_SF_10 0b10100000 // 7 4 1024 chips/bit
117#define RADIOLIB_SX127X_SF_11 0b10110000 // 7 4 2048 chips/bit
118#define RADIOLIB_SX127X_SF_12 0b11000000 // 7 4 4096 chips/bit
119#define RADIOLIB_SX127X_TX_MODE_SINGLE 0b00000000 // 3 3 single TX
120#define RADIOLIB_SX127X_TX_MODE_CONT 0b00001000 // 3 3 continuous TX
121#define RADIOLIB_SX127X_RX_TIMEOUT_MSB 0b00000000 // 1 0
122
123// RADIOLIB_SX127X_REG_SYMB_TIMEOUT_LSB
124#define RADIOLIB_SX127X_RX_TIMEOUT_LSB 0b01100100 // 7 0 10-bit RX operation timeout
125
126// RADIOLIB_SX127X_REG_PREAMBLE_MSB + REG_PREAMBLE_LSB
127#define RADIOLIB_SX127X_PREAMBLE_LENGTH_MSB 0b00000000 // 7 0 2-byte preamble length setting: l_P = PREAMBLE_LENGTH + 4.25
128#define RADIOLIB_SX127X_PREAMBLE_LENGTH_LSB 0b00001000 // 7 0 where l_p = preamble length
129
130// RADIOLIB_SX127X_REG_DETECT_OPTIMIZE
131#define RADIOLIB_SX127X_DETECT_OPTIMIZE_SF_6 0b00000101 // 2 0 SF6 detection optimization
132#define RADIOLIB_SX127X_DETECT_OPTIMIZE_SF_7_12 0b00000011 // 2 0 SF7 to SF12 detection optimization
133
134// RADIOLIB_SX127X_REG_INVERT_IQ
135#define RADIOLIB_SX127X_INVERT_IQ_RXPATH_ON 0b01000000 // 6 6 I and Q signals are inverted
136#define RADIOLIB_SX127X_INVERT_IQ_RXPATH_OFF 0b00000000 // 6 6 normal mode
137#define RADIOLIB_SX127X_INVERT_IQ_TXPATH_ON 0b00000001 // 0 0 I and Q signals are inverted
138#define RADIOLIB_SX127X_INVERT_IQ_TXPATH_OFF 0b00000000 // 0 0 normal mode
139
140// RADIOLIB_SX127X_REG_DETECTION_THRESHOLD
141#define RADIOLIB_SX127X_DETECTION_THRESHOLD_SF_6 0b00001100 // 7 0 SF6 detection threshold
142#define RADIOLIB_SX127X_DETECTION_THRESHOLD_SF_7_12 0b00001010 // 7 0 SF7 to SF12 detection threshold
143
144// RADIOLIB_SX127X_REG_PA_DAC
145#define RADIOLIB_SX127X_PA_BOOST_OFF 0b00000100 // 2 0 PA_BOOST disabled
146#define RADIOLIB_SX127X_PA_BOOST_ON 0b00000111 // 2 0 +20 dBm on PA_BOOST when OUTPUT_POWER = 0b1111
147
148// RADIOLIB_SX127X_REG_HOP_PERIOD
149#define RADIOLIB_SX127X_HOP_PERIOD_OFF 0b00000000 // 7 0 number of periods between frequency hops; 0 = disabled
150#define RADIOLIB_SX127X_HOP_PERIOD_MAX 0b11111111 // 7 0
151
152// RADIOLIB_SX127X_REG_IRQ_FLAGS
153#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_RX_TIMEOUT 0b10000000 // 7 7 timeout
154#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_RX_DONE 0b01000000 // 6 6 packet reception complete
155#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_PAYLOAD_CRC_ERROR 0b00100000 // 5 5 payload CRC error
156#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_VALID_HEADER 0b00010000 // 4 4 valid header received
157#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_TX_DONE 0b00001000 // 3 3 payload transmission complete
158#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_CAD_DONE 0b00000100 // 2 2 CAD complete
159#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_FHSS_CHANGE_CHANNEL 0b00000010 // 1 1 FHSS change channel
160#define RADIOLIB_SX127X_CLEAR_IRQ_FLAG_CAD_DETECTED 0b00000001 // 0 0 valid LoRa signal detected during CAD operation
161
162// RADIOLIB_SX127X_REG_IRQ_FLAGS_MASK
163#define RADIOLIB_SX127X_MASK_IRQ_FLAG_RX_TIMEOUT 0b01111111 // 7 7 timeout
164#define RADIOLIB_SX127X_MASK_IRQ_FLAG_RX_DONE 0b10111111 // 6 6 packet reception complete
165#define RADIOLIB_SX127X_MASK_IRQ_FLAG_PAYLOAD_CRC_ERROR 0b11011111 // 5 5 payload CRC error
166#define RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER 0b11101111 // 4 4 valid header received
167#define RADIOLIB_SX127X_MASK_IRQ_FLAG_TX_DONE 0b11110111 // 3 3 payload transmission complete
168#define RADIOLIB_SX127X_MASK_IRQ_FLAG_CAD_DONE 0b11111011 // 2 2 CAD complete
169#define RADIOLIB_SX127X_MASK_IRQ_FLAG_FHSS_CHANGE_CHANNEL 0b11111101 // 1 1 FHSS change channel
170#define RADIOLIB_SX127X_MASK_IRQ_FLAG_CAD_DETECTED 0b11111110 // 0 0 valid LoRa signal detected during CAD operation
171
172// RADIOLIB_SX127X_REG_FIFO_TX_BASE_ADDR
173#define RADIOLIB_SX127X_FIFO_TX_BASE_ADDR_MAX 0b00000000 // 7 0 allocate the entire FIFO buffer for TX only
174
175// RADIOLIB_SX127X_REG_FIFO_RX_BASE_ADDR
176#define RADIOLIB_SX127X_FIFO_RX_BASE_ADDR_MAX 0b00000000 // 7 0 allocate the entire FIFO buffer for RX only
177
178// RADIOLIB_SX127X_REG_SYNC_WORD
179#define RADIOLIB_SX127X_SYNC_WORD 0x12 // 7 0 default LoRa sync word
180#define RADIOLIB_SX127X_SYNC_WORD_LORAWAN 0x34 // 7 0 sync word reserved for LoRaWAN networks
181
182// RADIOLIB_SX127X_REG_INVERT_IQ2
183#define RADIOLIB_SX127X_IQ2_ENABLE 0x19 // 7 0 enable optimize for inverted IQ
184#define RADIOLIB_SX127X_IQ2_DISABLE 0x1D // 7 0 reset optimize for inverted IQ
185
186// SX127x series common FSK registers
187// NOTE: FSK register names that are conflicting with LoRa registers are marked with "_FSK" suffix
188#define RADIOLIB_SX127X_REG_BITRATE_MSB 0x02
189#define RADIOLIB_SX127X_REG_BITRATE_LSB 0x03
190#define RADIOLIB_SX127X_REG_FDEV_MSB 0x04
191#define RADIOLIB_SX127X_REG_FDEV_LSB 0x05
192#define RADIOLIB_SX127X_REG_RX_CONFIG 0x0D
193#define RADIOLIB_SX127X_REG_RSSI_CONFIG 0x0E
194#define RADIOLIB_SX127X_REG_RSSI_COLLISION 0x0F
195#define RADIOLIB_SX127X_REG_RSSI_THRESH 0x10
196#define RADIOLIB_SX127X_REG_RSSI_VALUE_FSK 0x11
197#define RADIOLIB_SX127X_REG_RX_BW 0x12
198#define RADIOLIB_SX127X_REG_AFC_BW 0x13
199#define RADIOLIB_SX127X_REG_OOK_PEAK 0x14
200#define RADIOLIB_SX127X_REG_OOK_FIX 0x15
201#define RADIOLIB_SX127X_REG_OOK_AVG 0x16
202#define RADIOLIB_SX127X_REG_AFC_FEI 0x1A
203#define RADIOLIB_SX127X_REG_AFC_MSB 0x1B
204#define RADIOLIB_SX127X_REG_AFC_LSB 0x1C
205#define RADIOLIB_SX127X_REG_FEI_MSB_FSK 0x1D
206#define RADIOLIB_SX127X_REG_FEI_LSB_FSK 0x1E
207#define RADIOLIB_SX127X_REG_PREAMBLE_DETECT 0x1F
208#define RADIOLIB_SX127X_REG_RX_TIMEOUT_1 0x20
209#define RADIOLIB_SX127X_REG_RX_TIMEOUT_2 0x21
210#define RADIOLIB_SX127X_REG_RX_TIMEOUT_3 0x22
211#define RADIOLIB_SX127X_REG_RX_DELAY 0x23
212#define RADIOLIB_SX127X_REG_OSC 0x24
213#define RADIOLIB_SX127X_REG_PREAMBLE_MSB_FSK 0x25
214#define RADIOLIB_SX127X_REG_PREAMBLE_LSB_FSK 0x26
215#define RADIOLIB_SX127X_REG_SYNC_CONFIG 0x27
216#define RADIOLIB_SX127X_REG_SYNC_VALUE_1 0x28
217#define RADIOLIB_SX127X_REG_SYNC_VALUE_2 0x29
218#define RADIOLIB_SX127X_REG_SYNC_VALUE_3 0x2A
219#define RADIOLIB_SX127X_REG_SYNC_VALUE_4 0x2B
220#define RADIOLIB_SX127X_REG_SYNC_VALUE_5 0x2C
221#define RADIOLIB_SX127X_REG_SYNC_VALUE_6 0x2D
222#define RADIOLIB_SX127X_REG_SYNC_VALUE_7 0x2E
223#define RADIOLIB_SX127X_REG_SYNC_VALUE_8 0x2F
224#define RADIOLIB_SX127X_REG_PACKET_CONFIG_1 0x30
225#define RADIOLIB_SX127X_REG_PACKET_CONFIG_2 0x31
226#define RADIOLIB_SX127X_REG_PAYLOAD_LENGTH_FSK 0x32
227#define RADIOLIB_SX127X_REG_NODE_ADRS 0x33
228#define RADIOLIB_SX127X_REG_BROADCAST_ADRS 0x34
229#define RADIOLIB_SX127X_REG_FIFO_THRESH 0x35
230#define RADIOLIB_SX127X_REG_SEQ_CONFIG_1 0x36
231#define RADIOLIB_SX127X_REG_SEQ_CONFIG_2 0x37
232#define RADIOLIB_SX127X_REG_TIMER_RESOL 0x38
233#define RADIOLIB_SX127X_REG_TIMER1_COEF 0x39
234#define RADIOLIB_SX127X_REG_TIMER2_COEF 0x3A
235#define RADIOLIB_SX127X_REG_IMAGE_CAL 0x3B
236#define RADIOLIB_SX127X_REG_TEMP 0x3C
237#define RADIOLIB_SX127X_REG_LOW_BAT 0x3D
238#define RADIOLIB_SX127X_REG_IRQ_FLAGS_1 0x3E
239#define RADIOLIB_SX127X_REG_IRQ_FLAGS_2 0x3F
240
241// SX127x common FSK modem settings
242// RADIOLIB_SX127X_REG_OP_MODE
243#define RADIOLIB_SX127X_MODULATION_FSK 0b00000000 // 6 5 FSK modulation scheme
244#define RADIOLIB_SX127X_MODULATION_OOK 0b00100000 // 6 5 OOK modulation scheme
245#define RADIOLIB_SX127X_RX 0b00000101 // 2 0 receiver mode
246
247// RADIOLIB_SX127X_REG_BITRATE_MSB + SX127X_REG_BITRATE_LSB
248#define RADIOLIB_SX127X_BITRATE_MSB 0x1A // 7 0 bit rate setting: BitRate = F(XOSC)/(BITRATE + BITRATE_FRAC/16)
249#define RADIOLIB_SX127X_BITRATE_LSB 0x0B // 7 0 default value: 4.8 kbps
250
251// RADIOLIB_SX127X_REG_FDEV_MSB + SX127X_REG_FDEV_LSB
252#define RADIOLIB_SX127X_FDEV_MSB 0x00 // 5 0 frequency deviation: Fdev = Fstep * FDEV
253#define RADIOLIB_SX127X_FDEV_LSB 0x52 // 7 0 default value: 5 kHz
254
255// RADIOLIB_SX127X_REG_RX_CONFIG
256#define RADIOLIB_SX127X_RESTART_RX_ON_COLLISION_OFF 0b00000000 // 7 7 automatic receiver restart disabled (default)
257#define RADIOLIB_SX127X_RESTART_RX_ON_COLLISION_ON 0b10000000 // 7 7 automatically restart receiver if it gets saturated or on packet collision
258#define RADIOLIB_SX127X_RESTART_RX_WITHOUT_PLL_LOCK 0b01000000 // 6 6 manually restart receiver without frequency change
259#define RADIOLIB_SX127X_RESTART_RX_WITH_PLL_LOCK 0b00100000 // 5 5 manually restart receiver with frequency change
260#define RADIOLIB_SX127X_AFC_AUTO_OFF 0b00000000 // 4 4 no AFC performed (default)
261#define RADIOLIB_SX127X_AFC_AUTO_ON 0b00010000 // 4 4 AFC performed at each receiver startup
262#define RADIOLIB_SX127X_AGC_AUTO_OFF 0b00000000 // 3 3 LNA gain set manually by register
263#define RADIOLIB_SX127X_AGC_AUTO_ON 0b00001000 // 3 3 LNA gain controlled by AGC
264#define RADIOLIB_SX127X_RX_TRIGGER_NONE 0b00000000 // 2 0 receiver startup at: none
265#define RADIOLIB_SX127X_RX_TRIGGER_RSSI_INTERRUPT 0b00000001 // 2 0 RSSI interrupt
266#define RADIOLIB_SX127X_RX_TRIGGER_PREAMBLE_DETECT 0b00000110 // 2 0 preamble detected
267#define RADIOLIB_SX127X_RX_TRIGGER_BOTH 0b00000111 // 2 0 RSSI interrupt and preamble detected
268
269// RADIOLIB_SX127X_REG_RSSI_CONFIG
270#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_2 0b00000000 // 2 0 number of samples for RSSI average: 2
271#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_4 0b00000001 // 2 0 4
272#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_8 0b00000010 // 2 0 8 (default)
273#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_16 0b00000011 // 2 0 16
274#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_32 0b00000100 // 2 0 32
275#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_64 0b00000101 // 2 0 64
276#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_128 0b00000110 // 2 0 128
277#define RADIOLIB_SX127X_RSSI_SMOOTHING_SAMPLES_256 0b00000111 // 2 0 256
278
279// RADIOLIB_SX127X_REG_RSSI_COLLISION
280#define RADIOLIB_SX127X_RSSI_COLLISION_THRESHOLD 0x0A // 7 0 RSSI threshold in dB that will be considered a collision, default value: 10 dB
281
282// RADIOLIB_SX127X_REG_RSSI_THRESH
283#define RADIOLIB_SX127X_RSSI_THRESHOLD 0xFF // 7 0 RSSI threshold that will trigger RSSI interrupt, RssiThreshold = RSSI_THRESHOLD / 2 [dBm]
284
285// RADIOLIB_SX127X_REG_RX_BW
286#define RADIOLIB_SX127X_RX_BW_MANT_16 0b00000000 // 4 3 channel filter bandwidth: RxBw = F(XOSC) / (RxBwMant * 2^(RxBwExp + 2)) [kHz]
287#define RADIOLIB_SX127X_RX_BW_MANT_20 0b00001000 // 4 3
288#define RADIOLIB_SX127X_RX_BW_MANT_24 0b00010000 // 4 3 default RxBwMant parameter
289#define RADIOLIB_SX127X_RX_BW_EXP 0b00000101 // 2 0 default RxBwExp parameter
290#define RADIOLIB_SX127X_RX_BW_2_6 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x07)
291#define RADIOLIB_SX127X_RX_BW_3_1 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x07)
292#define RADIOLIB_SX127X_RX_BW_3_9 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x07)
293#define RADIOLIB_SX127X_RX_BW_5_2 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x06)
294#define RADIOLIB_SX127X_RX_BW_6_3 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x06)
295#define RADIOLIB_SX127X_RX_BW_7_8 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x06)
296#define RADIOLIB_SX127X_RX_BW_10_4 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x05)
297#define RADIOLIB_SX127X_RX_BW_12_5 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x05)
298#define RADIOLIB_SX127X_RX_BW_15_6 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x05)
299#define RADIOLIB_SX127X_RX_BW_20_8 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x04)
300#define RADIOLIB_SX127X_RX_BW_25_0 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x04)
301#define RADIOLIB_SX127X_RX_BW_31_3 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x04)
302#define RADIOLIB_SX127X_RX_BW_41_7 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x03)
303#define RADIOLIB_SX127X_RX_BW_50_0 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x03)
304#define RADIOLIB_SX127X_RX_BW_62_5 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x03)
305#define RADIOLIB_SX127X_RX_BW_83_3 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x02)
306#define RADIOLIB_SX127X_RX_BW_100 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x02)
307#define RADIOLIB_SX127X_RX_BW_125 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x02)
308#define RADIOLIB_SX127X_RX_BW_167 (RADIOLIB_SX127X_RX_BW_MANT_24 | 0x01)
309#define RADIOLIB_SX127X_RX_BW_200 (RADIOLIB_SX127X_RX_BW_MANT_20 | 0x01)
310#define RADIOLIB_SX127X_RX_BW_250 (RADIOLIB_SX127X_RX_BW_MANT_16 | 0x01)
311
312// RADIOLIB_SX127X_REG_AFC_BW
313#define RADIOLIB_SX127X_RX_BW_MANT_AFC 0b00001000 // 4 3 default RxBwMant parameter used during AFC
314#define RADIOLIB_SX127X_RX_BW_EXP_AFC 0b00000011 // 2 0 default RxBwExp parameter used during AFC
315
316// RADIOLIB_SX127X_REG_OOK_PEAK
317#define RADIOLIB_SX127X_BIT_SYNC_OFF 0b00000000 // 5 5 bit synchronizer disabled (not allowed in packet mode)
318#define RADIOLIB_SX127X_BIT_SYNC_ON 0b00100000 // 5 5 bit synchronizer enabled (default)
319#define RADIOLIB_SX127X_OOK_THRESH_FIXED 0b00000000 // 4 3 OOK threshold type: fixed value
320#define RADIOLIB_SX127X_OOK_THRESH_PEAK 0b00001000 // 4 3 peak mode (default)
321#define RADIOLIB_SX127X_OOK_THRESH_AVERAGE 0b00010000 // 4 3 average mode
322#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_0_5_DB 0b00000000 // 2 0 OOK demodulator step size: 0.5 dB (default)
323#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_1_0_DB 0b00000001 // 2 0 1.0 dB
324#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_1_5_DB 0b00000010 // 2 0 1.5 dB
325#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_2_0_DB 0b00000011 // 2 0 2.0 dB
326#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_3_0_DB 0b00000100 // 2 0 3.0 dB
327#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_4_0_DB 0b00000101 // 2 0 4.0 dB
328#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_5_0_DB 0b00000110 // 2 0 5.0 dB
329#define RADIOLIB_SX127X_OOK_PEAK_THRESH_STEP_6_0_DB 0b00000111 // 2 0 6.0 dB
330
331// RADIOLIB_SX127X_REG_OOK_FIX
332#define RADIOLIB_SX127X_OOK_FIXED_THRESHOLD 0x0C // 7 0 default fixed threshold for OOK data slicer
333
334// RADIOLIB_SX127X_REG_OOK_AVG
335#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_1_1_CHIP 0b00000000 // 7 5 OOK demodulator step period: once per chip (default)
336#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_1_2_CHIP 0b00100000 // 7 5 once every 2 chips
337#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_1_4_CHIP 0b01000000 // 7 5 once every 4 chips
338#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_1_8_CHIP 0b01100000 // 7 5 once every 8 chips
339#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_2_1_CHIP 0b10000000 // 7 5 2 times per chip
340#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_4_1_CHIP 0b10100000 // 7 5 4 times per chip
341#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_8_1_CHIP 0b11000000 // 7 5 8 times per chip
342#define RADIOLIB_SX127X_OOK_PEAK_THRESH_DEC_16_1_CHIP 0b11100000 // 7 5 16 times per chip
343#define RADIOLIB_SX127X_OOK_AVERAGE_OFFSET_0_DB 0b00000000 // 3 2 OOK average threshold offset: 0.0 dB (default)
344#define RADIOLIB_SX127X_OOK_AVERAGE_OFFSET_2_DB 0b00000100 // 3 2 2.0 dB
345#define RADIOLIB_SX127X_OOK_AVERAGE_OFFSET_4_DB 0b00001000 // 3 2 4.0 dB
346#define RADIOLIB_SX127X_OOK_AVERAGE_OFFSET_6_DB 0b00001100 // 3 2 6.0 dB
347#define RADIOLIB_SX127X_OOK_AVG_THRESH_FILT_32_PI 0b00000000 // 1 0 OOK average filter coefficient: chip rate / 32*pi
348#define RADIOLIB_SX127X_OOK_AVG_THRESH_FILT_8_PI 0b00000001 // 1 0 chip rate / 8*pi
349#define RADIOLIB_SX127X_OOK_AVG_THRESH_FILT_4_PI 0b00000010 // 1 0 chip rate / 4*pi (default)
350#define RADIOLIB_SX127X_OOK_AVG_THRESH_FILT_2_PI 0b00000011 // 1 0 chip rate / 2*pi
351
352// RADIOLIB_SX127X_REG_AFC_FEI
353#define RADIOLIB_SX127X_AGC_START 0b00010000 // 4 4 manually start AGC sequence
354#define RADIOLIB_SX127X_AFC_CLEAR 0b00000010 // 1 1 manually clear AFC register
355#define RADIOLIB_SX127X_AFC_AUTO_CLEAR_OFF 0b00000000 // 0 0 AFC register will not be cleared at the start of AFC (default)
356#define RADIOLIB_SX127X_AFC_AUTO_CLEAR_ON 0b00000001 // 0 0 AFC register will be cleared at the start of AFC
357
358// RADIOLIB_SX127X_REG_PREAMBLE_DETECT
359#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_OFF 0b00000000 // 7 7 preamble detection disabled
360#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_ON 0b10000000 // 7 7 preamble detection enabled (default)
361#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_1_BYTE 0b00000000 // 6 5 preamble detection size: 1 byte (default)
362#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_2_BYTE 0b00100000 // 6 5 2 bytes
363#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_3_BYTE 0b01000000 // 6 5 3 bytes
364#define RADIOLIB_SX127X_PREAMBLE_DETECTOR_TOL 0x0A // 4 0 default number of tolerated errors per chip (4 chips per bit)
365
366// RADIOLIB_SX127X_REG_RX_TIMEOUT_1
367#define RADIOLIB_SX127X_TIMEOUT_RX_RSSI_OFF 0x00 // 7 0 disable receiver timeout when RSSI interrupt doesn't occur (default)
368
369// RADIOLIB_SX127X_REG_RX_TIMEOUT_2
370#define RADIOLIB_SX127X_TIMEOUT_RX_PREAMBLE_OFF 0x00 // 7 0 disable receiver timeout when preamble interrupt doesn't occur (default)
371
372// RADIOLIB_SX127X_REG_RX_TIMEOUT_3
373#define RADIOLIB_SX127X_TIMEOUT_SIGNAL_SYNC_OFF 0x00 // 7 0 disable receiver timeout when sync address interrupt doesn't occur (default)
374
375// RADIOLIB_SX127X_REG_OSC
376#define RADIOLIB_SX127X_RC_CAL_START 0b00000000 // 3 3 manually start RC oscillator calibration
377#define RADIOLIB_SX127X_CLK_OUT_FXOSC 0b00000000 // 2 0 ClkOut frequency: F(XOSC)
378#define RADIOLIB_SX127X_CLK_OUT_FXOSC_2 0b00000001 // 2 0 F(XOSC) / 2
379#define RADIOLIB_SX127X_CLK_OUT_FXOSC_4 0b00000010 // 2 0 F(XOSC) / 4
380#define RADIOLIB_SX127X_CLK_OUT_FXOSC_8 0b00000011 // 2 0 F(XOSC) / 8
381#define RADIOLIB_SX127X_CLK_OUT_FXOSC_16 0b00000100 // 2 0 F(XOSC) / 16
382#define RADIOLIB_SX127X_CLK_OUT_FXOSC_32 0b00000101 // 2 0 F(XOSC) / 32
383#define RADIOLIB_SX127X_CLK_OUT_RC 0b00000110 // 2 0 RC
384#define RADIOLIB_SX127X_CLK_OUT_OFF 0b00000111 // 2 0 disabled (default)
385
386// RADIOLIB_SX127X_REG_PREAMBLE_MSB_FSK + SX127X_REG_PREAMBLE_LSB_FSK
387#define RADIOLIB_SX127X_PREAMBLE_SIZE_MSB 0x00 // 7 0 preamble size in bytes
388#define RADIOLIB_SX127X_PREAMBLE_SIZE_LSB 0x03 // 7 0 default value: 3 bytes
389
390// RADIOLIB_SX127X_REG_SYNC_CONFIG
391#define RADIOLIB_SX127X_AUTO_RESTART_RX_MODE_OFF 0b00000000 // 7 6 Rx mode restart after packet reception: disabled
392#define RADIOLIB_SX127X_AUTO_RESTART_RX_MODE_NO_PLL 0b01000000 // 7 6 enabled, don't wait for PLL lock
393#define RADIOLIB_SX127X_AUTO_RESTART_RX_MODE_PLL 0b10000000 // 7 6 enabled, wait for PLL lock (default)
394#define RADIOLIB_SX127X_PREAMBLE_POLARITY_AA 0b00000000 // 5 5 preamble polarity: 0xAA = 0b10101010 (default)
395#define RADIOLIB_SX127X_PREAMBLE_POLARITY_55 0b00100000 // 5 5 0x55 = 0b01010101
396#define RADIOLIB_SX127X_SYNC_OFF 0b00000000 // 4 4 sync word disabled
397#define RADIOLIB_SX127X_SYNC_ON 0b00010000 // 4 4 sync word enabled (default)
398#define RADIOLIB_SX127X_SYNC_SIZE 0x03 // 2 0 sync word size in bytes, SyncSize = SYNC_SIZE + 1 bytes
399
400// RADIOLIB_SX127X_REG_SYNC_VALUE_1 - SX127X_REG_SYNC_VALUE_8
401#define RADIOLIB_SX127X_SYNC_VALUE_1 0x01 // 7 0 sync word: 1st byte (MSB)
402#define RADIOLIB_SX127X_SYNC_VALUE_2 0x01 // 7 0 2nd byte
403#define RADIOLIB_SX127X_SYNC_VALUE_3 0x01 // 7 0 3rd byte
404#define RADIOLIB_SX127X_SYNC_VALUE_4 0x01 // 7 0 4th byte
405#define RADIOLIB_SX127X_SYNC_VALUE_5 0x01 // 7 0 5th byte
406#define RADIOLIB_SX127X_SYNC_VALUE_6 0x01 // 7 0 6th byte
407#define RADIOLIB_SX127X_SYNC_VALUE_7 0x01 // 7 0 7th byte
408#define RADIOLIB_SX127X_SYNC_VALUE_8 0x01 // 7 0 8th byte (LSB)
409
410// RADIOLIB_SX127X_REG_PACKET_CONFIG_1
411#define RADIOLIB_SX127X_PACKET_FIXED 0b00000000 // 7 7 packet format: fixed length
412#define RADIOLIB_SX127X_PACKET_VARIABLE 0b10000000 // 7 7 variable length (default)
413#define RADIOLIB_SX127X_DC_FREE_NONE 0b00000000 // 6 5 DC-free encoding: disabled (default)
414#define RADIOLIB_SX127X_DC_FREE_MANCHESTER 0b00100000 // 6 5 Manchester
415#define RADIOLIB_SX127X_DC_FREE_WHITENING 0b01000000 // 6 5 Whitening
416#define RADIOLIB_SX127X_CRC_OFF 0b00000000 // 4 4 CRC disabled
417#define RADIOLIB_SX127X_CRC_ON 0b00010000 // 4 4 CRC enabled (default)
418#define RADIOLIB_SX127X_CRC_AUTOCLEAR_OFF 0b00001000 // 3 3 keep FIFO on CRC mismatch, issue payload ready interrupt
419#define RADIOLIB_SX127X_CRC_AUTOCLEAR_ON 0b00000000 // 3 3 clear FIFO on CRC mismatch, do not issue payload ready interrupt
420#define RADIOLIB_SX127X_ADDRESS_FILTERING_OFF 0b00000000 // 2 1 address filtering: none (default)
421#define RADIOLIB_SX127X_ADDRESS_FILTERING_NODE 0b00000010 // 2 1 node
422#define RADIOLIB_SX127X_ADDRESS_FILTERING_NODE_BROADCAST 0b00000100 // 2 1 node or broadcast
423#define RADIOLIB_SX127X_CRC_WHITENING_TYPE_CCITT 0b00000000 // 0 0 CRC and whitening algorithms: CCITT CRC with standard whitening (default)
424#define RADIOLIB_SX127X_CRC_WHITENING_TYPE_IBM 0b00000001 // 0 0 IBM CRC with alternate whitening
425
426// RADIOLIB_SX127X_REG_PACKET_CONFIG_2
427#define RADIOLIB_SX127X_DATA_MODE_PACKET 0b01000000 // 6 6 data mode: packet (default)
428#define RADIOLIB_SX127X_DATA_MODE_CONTINUOUS 0b00000000 // 6 6 continuous
429#define RADIOLIB_SX127X_IO_HOME_OFF 0b00000000 // 5 5 io-homecontrol compatibility disabled (default)
430#define RADIOLIB_SX127X_IO_HOME_ON 0b00100000 // 5 5 io-homecontrol compatibility enabled
431
432// RADIOLIB_SX127X_REG_FIFO_THRESH
433#define RADIOLIB_SX127X_TX_START_FIFO_LEVEL 0b00000000 // 7 7 start packet transmission when: number of bytes in FIFO exceeds FIFO_THRESHOLD
434#define RADIOLIB_SX127X_TX_START_FIFO_NOT_EMPTY 0b10000000 // 7 7 at least one byte in FIFO (default)
435#define RADIOLIB_SX127X_FIFO_THRESH 0x1F // 5 0 FIFO level threshold
436
437// RADIOLIB_SX127X_REG_SEQ_CONFIG_1
438#define RADIOLIB_SX127X_SEQUENCER_START 0b10000000 // 7 7 manually start sequencer
439#define RADIOLIB_SX127X_SEQUENCER_STOP 0b01000000 // 6 6 manually stop sequencer
440#define RADIOLIB_SX127X_IDLE_MODE_STANDBY 0b00000000 // 5 5 chip mode during sequencer idle mode: standby (default)
441#define RADIOLIB_SX127X_IDLE_MODE_SLEEP 0b00100000 // 5 5 sleep
442#define RADIOLIB_SX127X_FROM_START_LP_SELECTION 0b00000000 // 4 3 mode that will be set after starting sequencer: low power selection (default)
443#define RADIOLIB_SX127X_FROM_START_RECEIVE 0b00001000 // 4 3 receive
444#define RADIOLIB_SX127X_FROM_START_TRANSMIT 0b00010000 // 4 3 transmit
445#define RADIOLIB_SX127X_FROM_START_TRANSMIT_FIFO_LEVEL 0b00011000 // 4 3 transmit on a FIFO level interrupt
446#define RADIOLIB_SX127X_LP_SELECTION_SEQ_OFF 0b00000000 // 2 2 mode that will be set after exiting low power selection: sequencer off (default)
447#define RADIOLIB_SX127X_LP_SELECTION_IDLE 0b00000100 // 2 2 idle state
448#define RADIOLIB_SX127X_FROM_IDLE_TRANSMIT 0b00000000 // 1 1 mode that will be set after exiting idle mode: transmit (default)
449#define RADIOLIB_SX127X_FROM_IDLE_RECEIVE 0b00000010 // 1 1 receive
450#define RADIOLIB_SX127X_FROM_TRANSMIT_LP_SELECTION 0b00000000 // 0 0 mode that will be set after exiting transmit mode: low power selection (default)
451#define RADIOLIB_SX127X_FROM_TRANSMIT_RECEIVE 0b00000001 // 0 0 receive
452
453// RADIOLIB_SX127X_REG_SEQ_CONFIG_2
454#define RADIOLIB_SX127X_FROM_RECEIVE_PACKET_RECEIVED_PAYLOAD 0b00100000 // 7 5 mode that will be set after exiting receive mode: packet received on payload ready interrupt (default)
455#define RADIOLIB_SX127X_FROM_RECEIVE_LP_SELECTION 0b01000000 // 7 5 low power selection
456#define RADIOLIB_SX127X_FROM_RECEIVE_PACKET_RECEIVED_CRC_OK 0b01100000 // 7 5 packet received on CRC OK interrupt
457#define RADIOLIB_SX127X_FROM_RECEIVE_SEQ_OFF_RSSI 0b10000000 // 7 5 sequencer off on RSSI interrupt
458#define RADIOLIB_SX127X_FROM_RECEIVE_SEQ_OFF_SYNC_ADDR 0b10100000 // 7 5 sequencer off on sync address interrupt
459#define RADIOLIB_SX127X_FROM_RECEIVE_SEQ_OFF_PREAMBLE_DETECT 0b11000000 // 7 5 sequencer off on preamble detect interrupt
460#define RADIOLIB_SX127X_FROM_RX_TIMEOUT_RECEIVE 0b00000000 // 4 3 mode that will be set after Rx timeout: receive (default)
461#define RADIOLIB_SX127X_FROM_RX_TIMEOUT_TRANSMIT 0b00001000 // 4 3 transmit
462#define RADIOLIB_SX127X_FROM_RX_TIMEOUT_LP_SELECTION 0b00010000 // 4 3 low power selection
463#define RADIOLIB_SX127X_FROM_RX_TIMEOUT_SEQ_OFF 0b00011000 // 4 3 sequencer off
464#define RADIOLIB_SX127X_FROM_PACKET_RECEIVED_SEQ_OFF 0b00000000 // 2 0 mode that will be set after packet received: sequencer off (default)
465#define RADIOLIB_SX127X_FROM_PACKET_RECEIVED_TRANSMIT 0b00000001 // 2 0 transmit
466#define RADIOLIB_SX127X_FROM_PACKET_RECEIVED_LP_SELECTION 0b00000010 // 2 0 low power selection
467#define RADIOLIB_SX127X_FROM_PACKET_RECEIVED_RECEIVE_FS 0b00000011 // 2 0 receive via FS
468#define RADIOLIB_SX127X_FROM_PACKET_RECEIVED_RECEIVE 0b00000100 // 2 0 receive
469
470// RADIOLIB_SX127X_REG_TIMER_RESOL
471#define RADIOLIB_SX127X_TIMER1_OFF 0b00000000 // 3 2 timer 1 resolution: disabled (default)
472#define RADIOLIB_SX127X_TIMER1_RESOLUTION_64_US 0b00000100 // 3 2 64 us
473#define RADIOLIB_SX127X_TIMER1_RESOLUTION_4_1_MS 0b00001000 // 3 2 4.1 ms
474#define RADIOLIB_SX127X_TIMER1_RESOLUTION_262_MS 0b00001100 // 3 2 262 ms
475#define RADIOLIB_SX127X_TIMER2_OFF 0b00000000 // 3 2 timer 2 resolution: disabled (default)
476#define RADIOLIB_SX127X_TIMER2_RESOLUTION_64_US 0b00000001 // 3 2 64 us
477#define RADIOLIB_SX127X_TIMER2_RESOLUTION_4_1_MS 0b00000010 // 3 2 4.1 ms
478#define RADIOLIB_SX127X_TIMER2_RESOLUTION_262_MS 0b00000011 // 3 2 262 ms
479
480// RADIOLIB_SX127X_REG_TIMER1_COEF
481#define RADIOLIB_SX127X_TIMER1_COEFFICIENT 0xF5 // 7 0 multiplication coefficient for timer 1
482
483// RADIOLIB_SX127X_REG_TIMER2_COEF
484#define RADIOLIB_SX127X_TIMER2_COEFFICIENT 0x20 // 7 0 multiplication coefficient for timer 2
485
486// RADIOLIB_SX127X_REG_IMAGE_CAL
487#define RADIOLIB_SX127X_AUTO_IMAGE_CAL_OFF 0b00000000 // 7 7 temperature calibration disabled (default)
488#define RADIOLIB_SX127X_AUTO_IMAGE_CAL_ON 0b10000000 // 7 7 temperature calibration enabled
489#define RADIOLIB_SX127X_IMAGE_CAL_START 0b01000000 // 6 6 start temperature calibration
490#define RADIOLIB_SX127X_IMAGE_CAL_RUNNING 0b00100000 // 5 5 temperature calibration is on-going
491#define RADIOLIB_SX127X_IMAGE_CAL_COMPLETE 0b00000000 // 5 5 temperature calibration finished
492#define RADIOLIB_SX127X_TEMP_CHANGED 0b00001000 // 3 3 temperature changed more than TEMP_THRESHOLD since last calibration
493#define RADIOLIB_SX127X_TEMP_THRESHOLD_5_DEG_C 0b00000000 // 2 1 temperature change threshold: 5 deg. C
494#define RADIOLIB_SX127X_TEMP_THRESHOLD_10_DEG_C 0b00000010 // 2 1 10 deg. C (default)
495#define RADIOLIB_SX127X_TEMP_THRESHOLD_15_DEG_C 0b00000100 // 2 1 15 deg. C
496#define RADIOLIB_SX127X_TEMP_THRESHOLD_20_DEG_C 0b00000110 // 2 1 20 deg. C
497#define RADIOLIB_SX127X_TEMP_MONITOR_ON 0b00000000 // 0 0 temperature monitoring enabled (default)
498#define RADIOLIB_SX127X_TEMP_MONITOR_OFF 0b00000001 // 0 0 temperature monitoring disabled
499
500// RADIOLIB_SX127X_REG_LOW_BAT
501#define RADIOLIB_SX127X_LOW_BAT_OFF 0b00000000 // 3 3 low battery detector disabled
502#define RADIOLIB_SX127X_LOW_BAT_ON 0b00001000 // 3 3 low battery detector enabled
503#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_695_V 0b00000000 // 2 0 battery voltage threshold: 1.695 V
504#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_764_V 0b00000001 // 2 0 1.764 V
505#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_835_V 0b00000010 // 2 0 1.835 V (default)
506#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_905_V 0b00000011 // 2 0 1.905 V
507#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_976_V 0b00000100 // 2 0 1.976 V
508#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_045_V 0b00000101 // 2 0 2.045 V
509#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_116_V 0b00000110 // 2 0 2.116 V
510#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_185_V 0b00000111 // 2 0 2.185 V
511
512// RADIOLIB_SX127X_REG_IRQ_FLAGS_1
513#define RADIOLIB_SX127X_FLAG_MODE_READY 0b10000000 // 7 7 requested mode is ready
514#define RADIOLIB_SX127X_FLAG_RX_READY 0b01000000 // 6 6 reception ready (after RSSI, AGC, AFC)
515#define RADIOLIB_SX127X_FLAG_TX_READY 0b00100000 // 5 5 transmission ready (after PA ramp-up)
516#define RADIOLIB_SX127X_FLAG_PLL_LOCK 0b00010000 // 4 4 PLL locked
517#define RADIOLIB_SX127X_FLAG_RSSI 0b00001000 // 3 3 RSSI value exceeds RSSI threshold
518#define RADIOLIB_SX127X_FLAG_TIMEOUT 0b00000100 // 2 2 timeout occurred
519#define RADIOLIB_SX127X_FLAG_PREAMBLE_DETECT 0b00000010 // 1 1 valid preamble was detected
520#define RADIOLIB_SX127X_FLAG_SYNC_ADDRESS_MATCH 0b00000001 // 0 0 sync address matched
521
522// RADIOLIB_SX127X_REG_IRQ_FLAGS_2
523#define RADIOLIB_SX127X_FLAG_FIFO_FULL 0b10000000 // 7 7 FIFO is full
524#define RADIOLIB_SX127X_FLAG_FIFO_EMPTY 0b01000000 // 6 6 FIFO is empty
525#define RADIOLIB_SX127X_FLAG_FIFO_LEVEL 0b00100000 // 5 5 number of bytes in FIFO exceeds FIFO_THRESHOLD
526#define RADIOLIB_SX127X_FLAG_FIFO_OVERRUN 0b00010000 // 4 4 FIFO overrun occurred
527#define RADIOLIB_SX127X_FLAG_PACKET_SENT 0b00001000 // 3 3 packet was successfully sent
528#define RADIOLIB_SX127X_FLAG_PAYLOAD_READY 0b00000100 // 2 2 packet was successfully received
529#define RADIOLIB_SX127X_FLAG_CRC_OK 0b00000010 // 1 1 CRC check passed
530#define RADIOLIB_SX127X_FLAG_LOW_BAT 0b00000001 // 0 0 battery voltage dropped below threshold
531#define RADIOLIB_SX127X_FLAGS_ALL 0xFFFF
532
533// RADIOLIB_SX127X_REG_DIO_MAPPING_1
534#define RADIOLIB_SX127X_DIO0_LORA_RX_DONE 0b00000000 // 7 6
535#define RADIOLIB_SX127X_DIO0_LORA_TX_DONE 0b01000000 // 7 6
536#define RADIOLIB_SX127X_DIO0_LORA_CAD_DONE 0b10000000 // 7 6
537#define RADIOLIB_SX127X_DIO0_CONT_MODE_READY 0b11000000 // 7 6
538#define RADIOLIB_SX127X_DIO0_CONT_SYNC_ADDRESS 0b00000000 // 7 6
539#define RADIOLIB_SX127X_DIO0_CONT_RSSI_PREAMBLE_DETECT 0b01000000 // 7 6
540#define RADIOLIB_SX127X_DIO0_CONT_RX_READY 0b10000000 // 7 6
541#define RADIOLIB_SX127X_DIO0_CONT_TX_READY 0b00000000 // 7 6
542#define RADIOLIB_SX127X_DIO0_PACK_PAYLOAD_READY 0b00000000 // 7 6
543#define RADIOLIB_SX127X_DIO0_PACK_PACKET_SENT 0b00000000 // 7 6
544#define RADIOLIB_SX127X_DIO0_PACK_CRC_OK 0b01000000 // 7 6
545#define RADIOLIB_SX127X_DIO0_PACK_TEMP_CHANGE_LOW_BAT 0b11000000 // 7 6
546#define RADIOLIB_SX127X_DIO1_LORA_RX_TIMEOUT 0b00000000 // 5 4
547#define RADIOLIB_SX127X_DIO1_LORA_FHSS_CHANGE_CHANNEL 0b00010000 // 5 4
548#define RADIOLIB_SX127X_DIO1_LORA_CAD_DETECTED 0b00100000 // 5 4
549#define RADIOLIB_SX127X_DIO1_CONT_DCLK 0b00000000 // 5 4
550#define RADIOLIB_SX127X_DIO1_CONT_RSSI_PREAMBLE_DETECT 0b00010000 // 5 4
551#define RADIOLIB_SX127X_DIO1_PACK_FIFO_LEVEL 0b00000000 // 5 4
552#define RADIOLIB_SX127X_DIO1_PACK_FIFO_EMPTY 0b00010000 // 5 4
553#define RADIOLIB_SX127X_DIO1_PACK_FIFO_FULL 0b00100000 // 5 4
554#define RADIOLIB_SX127X_DIO2_LORA_FHSS_CHANGE_CHANNEL 0b00000000 // 3 2
555#define RADIOLIB_SX127X_DIO2_CONT_DATA 0b00000000 // 3 2
556#define RADIOLIB_SX127X_DIO2_PACK_FIFO_FULL 0b00000000 // 3 2
557#define RADIOLIB_SX127X_DIO2_PACK_RX_READY 0b00000100 // 3 2
558#define RADIOLIB_SX127X_DIO2_PACK_TIMEOUT 0b00001000 // 3 2
559#define RADIOLIB_SX127X_DIO2_PACK_SYNC_ADDRESS 0b00011000 // 3 2
560#define RADIOLIB_SX127X_DIO3_LORA_CAD_DONE 0b00000000 // 1 0
561#define RADIOLIB_SX127X_DIO3_LORA_VALID_HEADER 0b00000001 // 1 0
562#define RADIOLIB_SX127X_DIO3_LORA_PAYLOAD_CRC_ERROR 0b00000010 // 1 0
563#define RADIOLIB_SX127X_DIO3_CONT_TIMEOUT 0b00000000 // 1 0
564#define RADIOLIB_SX127X_DIO3_CONT_RSSI_PREAMBLE_DETECT 0b00000001 // 1 0
565#define RADIOLIB_SX127X_DIO3_CONT_TEMP_CHANGE_LOW_BAT 0b00000011 // 1 0
566#define RADIOLIB_SX127X_DIO3_PACK_FIFO_EMPTY 0b00000000 // 1 0
567#define RADIOLIB_SX127X_DIO3_PACK_TX_READY 0b00000001 // 1 0
568
569// RADIOLIB_SX127X_REG_DIO_MAPPING_2
570#define RADIOLIB_SX127X_DIO4_LORA_CAD_DETECTED 0b10000000 // 7 6
571#define RADIOLIB_SX127X_DIO4_LORA_PLL_LOCK 0b01000000 // 7 6
572#define RADIOLIB_SX127X_DIO4_CONT_TEMP_CHANGE_LOW_BAT 0b00000000 // 7 6
573#define RADIOLIB_SX127X_DIO4_CONT_PLL_LOCK 0b01000000 // 7 6
574#define RADIOLIB_SX127X_DIO4_CONT_TIMEOUT 0b10000000 // 7 6
575#define RADIOLIB_SX127X_DIO4_CONT_MODE_READY 0b11000000 // 7 6
576#define RADIOLIB_SX127X_DIO4_PACK_TEMP_CHANGE_LOW_BAT 0b00000000 // 7 6
577#define RADIOLIB_SX127X_DIO4_PACK_PLL_LOCK 0b01000000 // 7 6
578#define RADIOLIB_SX127X_DIO4_PACK_TIMEOUT 0b10000000 // 7 6
579#define RADIOLIB_SX127X_DIO4_PACK_RSSI_PREAMBLE_DETECT 0b11000000 // 7 6
580#define RADIOLIB_SX127X_DIO5_LORA_MODE_READY 0b00000000 // 5 4
581#define RADIOLIB_SX127X_DIO5_LORA_CLK_OUT 0b00010000 // 5 4
582#define RADIOLIB_SX127X_DIO5_CONT_CLK_OUT 0b00000000 // 5 4
583#define RADIOLIB_SX127X_DIO5_CONT_PLL_LOCK 0b00010000 // 5 4
584#define RADIOLIB_SX127X_DIO5_CONT_RSSI_PREAMBLE_DETECT 0b00100000 // 5 4
585#define RADIOLIB_SX127X_DIO5_CONT_MODE_READY 0b00110000 // 5 4
586#define RADIOLIB_SX127X_DIO5_PACK_CLK_OUT 0b00000000 // 5 4
587#define RADIOLIB_SX127X_DIO5_PACK_PLL_LOCK 0b00010000 // 5 4
588#define RADIOLIB_SX127X_DIO5_PACK_DATA 0b00100000 // 5 4
589#define RADIOLIB_SX127X_DIO5_PACK_MODE_READY 0b00110000 // 5 4
590#define RADIOLIB_SX127X_DIO_MAP_PREAMBLE_DETECT 0b00000001 // 0 0
591#define RADIOLIB_SX127X_DIO_MAP_RSSI 0b00000000 // 0 0
592
593// SX1272_REG_PLL_HOP + SX1278_REG_PLL_HOP
594#define RADIOLIB_SX127X_FAST_HOP_OFF 0b00000000 // 7 7 carrier frequency validated when FRF registers are written
595#define RADIOLIB_SX127X_FAST_HOP_ON 0b10000000 // 7 7 carrier frequency validated when FS modes are requested
596
597// SX1272_REG_TCXO + SX1278_REG_TCXO
598#define RADIOLIB_SX127X_TCXO_INPUT_EXTERNAL 0b00000000 // 4 4 use external crystal oscillator
599#define RADIOLIB_SX127X_TCXO_INPUT_EXTERNAL_CLIPPED 0b00010000 // 4 4 use external crystal oscillator clipped sine connected to XTA pin
600
601// SX1272_REG_PLL + SX1278_REG_PLL
602#define RADIOLIB_SX127X_PLL_BANDWIDTH_75_KHZ 0b00000000 // 7 6 PLL bandwidth: 75 kHz
603#define RADIOLIB_SX127X_PLL_BANDWIDTH_150_KHZ 0b01000000 // 7 6 150 kHz
604#define RADIOLIB_SX127X_PLL_BANDWIDTH_225_KHZ 0b10000000 // 7 6 225 kHz
605#define RADIOLIB_SX127X_PLL_BANDWIDTH_300_KHZ 0b11000000 // 7 6 300 kHz (default)
606
612class SX127x: public PhysicalLayer {
613 public:
614 // introduce PhysicalLayer overloads
620
621 // constructor
622
627 explicit SX127x(Module* mod);
628
634 uint8_t gain = 0;
635
640 bool enableOOK = false;
641
642 // basic methods
643
652 int16_t begin(const uint8_t* chipVersions, uint8_t numVersions, uint8_t syncWord, uint16_t preambleLength);
653
657 virtual void reset();
658
668 int16_t beginFSK(const uint8_t* chipVersions, uint8_t numVersions, uint32_t freqDev, uint32_t rxBw, uint16_t preambleLength);
669
678 int16_t transmit(const uint8_t* data, size_t len, uint8_t addr = 0) override;
679
689 int16_t receive(uint8_t* data, size_t len, RadioLibTime_t timeout = 0) override;
690
695 int16_t scanChannel() override;
696
702 int16_t scanChannel(const ChannelScanConfig_t &config) override;
703
709 int16_t sleep() override;
710
715 int16_t standby() override;
716
722 int16_t standby(uint8_t mode) override;
723
730 int16_t transmitDirect(uint32_t frf = 0) override;
731
737 int16_t receiveDirect() override;
738
743 int16_t packetMode();
744
745 // interrupt methods
746
752 void setDio0Action(void (*func)(void), uint32_t dir);
753
757 void clearDio0Action();
758
764 void setDio1Action(void (*func)(void), uint32_t dir);
765
769 void clearDio1Action();
770
775 void setFifoEmptyAction(void (*func)(void));
776
781
788 void setFifoThreshold(uint8_t threshold);
789
794 void setFifoFullAction(void (*func)(void));
795
799 void clearFifoFullAction();
800
808 bool fifoAdd(uint8_t* data, int totalLen, int* remLen);
809
817 bool fifoGet(volatile uint8_t* data, int totalLen, volatile int* rcvLen);
818
823 int16_t finishTransmit() override;
824
830 int16_t startReceive() override;
831
840 int16_t readData(uint8_t* data, size_t len) override;
841
846 int16_t finishReceive() override;
847
853 int16_t startChannelScan() override;
854
861 int16_t startChannelScan(const ChannelScanConfig_t &cfg) override;
862
867 int16_t getChannelScanResult() override;
868
869 // configuration methods
870
876 int16_t setSyncWord(uint8_t syncWord);
877
883 int16_t setCurrentLimit(uint8_t currentLimit);
884
891 int16_t setPreambleLength(size_t len, size_t detLen = 0xFFFFFFFF) override;
892
898 int16_t invertPreamble(bool enable);
899
905 int32_t getFrequencyError(bool autoCorrect = false);
906
911 float getAFCError();
912
917 float getSNR() override;
918
924 int16_t setFrequencyDeviation(uint32_t freqDev) override;
925
933 int16_t setRxBandwidth(uint32_t rxBw);
934
942 int16_t setAFCBandwidth(uint32_t afcBw);
943
949 int16_t setAFC(bool isEnabled);
950
956 int16_t setAFCAGCTrigger(uint8_t trigger);
957
964 int16_t setSyncWord(uint8_t* syncWord, size_t len) override;
965
971 int16_t setNodeAddress(uint8_t nodeAddr);
972
978 int16_t setBroadcastAddress(uint8_t broadAddr);
979
984 int16_t disableAddressFiltering();
985
991 int16_t setOOK(bool enable);
992
998 int16_t setOokThresholdType(uint8_t type);
999
1005 int16_t setOokPeakThresholdDecrement(uint8_t value);
1006
1012 int16_t setOokFixedOrFloorThreshold(uint8_t value);
1013
1019 int16_t setOokPeakThresholdStep(uint8_t value);
1020
1025 int16_t enableBitSync();
1026
1031 int16_t disableBitSync();
1032
1038 size_t getPacketLength(bool update = true) override;
1039
1046 int16_t getLoRaRxHeaderInfo(uint8_t* cr, bool* hasCRC);
1047
1053 int16_t fixedPacketLengthMode(uint8_t len = RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK);
1054
1060 int16_t variablePacketLengthMode(uint8_t maxLen = RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK);
1061
1067 RadioLibTime_t getTimeOnAir(size_t len) override;
1068
1077 RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len) override;
1078
1085
1093 int16_t setLoRaSymbNumTimeout(uint16_t numSymbols);
1094
1099 uint32_t getIrqFlags() override;
1100
1110 int16_t setIrqFlags(uint32_t irq) override;
1111
1117 int16_t clearIrqFlags(uint32_t irq) override;
1118
1124 int16_t setCrcFiltering(bool enable = true);
1125
1133 int16_t setRSSIConfig(uint8_t smoothingSamples, int8_t offset = 0);
1134
1141 int16_t setEncoding(uint8_t encoding) override;
1142
1149 uint16_t getIRQFlags();
1150
1155 uint8_t getModemStatus();
1156
1162 int8_t getTempRaw();
1163
1165 void setRfSwitchPins(uint32_t rxEn, uint32_t txEn);
1166
1168 void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
1169
1174 uint8_t randomByte() override;
1175
1180 int16_t getChipVersion();
1181
1187 int16_t invertIQ(bool enable) override;
1188
1194 int16_t getModem(ModemType_t* modem) override;
1195
1197 int16_t getMode(RadioModeType_t* mode) override;
1198
1200 int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t* cfg) override;
1201
1203 int16_t launchMode() override;
1204
1211 int16_t writeTxBuffer(const uint8_t* data, size_t len) override;
1212
1214 int16_t clearTxBuffer() override;
1215
1216 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
1221 void setDirectAction(void (*func)(void)) override;
1222
1227 void readBit(uint32_t pin) override;
1228 #endif
1229
1235 int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod);
1236
1241 uint8_t getFHSSHoppingPeriod(void);
1242
1247 uint8_t getFHSSChannel(void);
1248
1252 void clearFHSSInt(void);
1253
1260 int16_t setDIOMapping(uint32_t pin, uint32_t value);
1261
1267 int16_t setDIOPreambleDetect(bool usePreambleDetect);
1268
1274 int16_t setRSSIThreshold(float dbm);
1275
1284 int16_t setLowBatteryThreshold(int8_t level, uint32_t pin = RADIOLIB_NC);
1285
1286#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
1287 protected:
1288#endif
1289 Module* getMod() override;
1290
1291#if !RADIOLIB_GODMODE
1292 protected:
1293#endif
1294 uint32_t frequency = 0;
1295 uint32_t bandwidth = RADIOLIB_UNIT_KILO(125);
1296 uint8_t spreadingFactor = 9;
1297 size_t packetLength = 0;
1298 uint8_t codingRate = 0;
1299 bool crcEnabled = false;
1300 bool ookEnabled = false;
1301 bool implicitHdr = false;
1302 bool ldroAuto = true;
1303 bool ldroEnabled = false;
1304
1305 virtual int16_t configFSK();
1306 int16_t getActiveModem();
1307 int16_t setFrequencyRaw(uint32_t newFreq);
1308 int16_t setBitRateCommon(uint32_t br, uint8_t fracRegAddr);
1309 float getRSSICommon(bool packet, bool skipReceive, int16_t offset);
1310 int16_t setHeaderType(uint8_t headerType, uint8_t bitIndex, size_t len = 0xFF);
1311
1312#if !RADIOLIB_GODMODE
1313 private:
1314#endif
1315 Module* mod;
1316
1317 uint32_t bitRate = 0, frequencyDev = 0;
1318 bool crcOn = true; // default value used in FSK mode
1319 bool packetLengthQueried = false; // FSK packet length is the first byte in FIFO, length can only be queried once
1320 uint8_t packetLengthConfig = RADIOLIB_SX127X_PACKET_VARIABLE;
1321 uint8_t rxMode = RADIOLIB_SX127X_RXCONTINUOUS;
1322
1323 int16_t config();
1324 int16_t directMode();
1325 int16_t setPacketMode(uint8_t mode, uint8_t len);
1326 bool findChip(const uint8_t* vers, uint8_t num);
1327 int16_t setMode(uint8_t mode);
1328 int16_t setActiveModem(uint8_t modem);
1329 void clearFIFO(size_t count); // used mostly to clear remaining bytes in FIFO after a packet read
1330 int16_t setRxBw(uint32_t rxBw, bool afc);
1331
1332 virtual void errataFix(bool rx); // should be implemented in derived class
1333};
1334
1335#endif
1336
1337#endif
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition Module.h:74
static const size_t RFSWITCH_MAX_PINS
The maximum number of pins supported by the RF switch code. Note: It is not recommended to use this c...
Definition Module.h:83
virtual int16_t startReceive()
Sets module to received mode using its default configuration.
Definition PhysicalLayer.cpp:131
virtual int16_t readData(uint8_t *data, size_t len)
Reads data that was received after calling startReceive method.
Definition PhysicalLayer.cpp:235
int16_t transmit(const char *str, uint8_t addr=0)
C-string transmit method.
Definition PhysicalLayer.cpp:53
int16_t startTransmit(const char *str, uint8_t addr=0)
Interrupt-driven Arduino String transmit method. Unlike the standard transmit method,...
Definition PhysicalLayer.cpp:157
virtual int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0)
Binary receive method. Must be implemented in module class.
Definition PhysicalLayer.cpp:111
PhysicalLayer()
Default constructor.
Definition PhysicalLayer.cpp:5
int16_t setLoRaSymbNumTimeout(uint16_t numSymbols)
Set the LoRa sync (symbol-number) timeout. In single reception mode, the radio will abort reception i...
Definition SX127x.cpp:1217
int16_t setRxBandwidth(uint32_t rxBw)
Sets FSK receiver bandwidth. Allowed values range from 5200 Hz to 500 kHz. Only available in FSK mode...
Definition SX127x.cpp:843
int16_t packetMode()
Disables direct mode and enables packet mode, allowing the module to receive packets....
Definition SX127x.cpp:380
void readBit(uint32_t pin) override
Function to read and process data bit in direct reception mode.
Definition SX127x.cpp:1958
void clearFifoFullAction()
Clears interrupt service routine to call when FIFO is full.
Definition SX127x.cpp:437
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 SX127x.cpp:1984
int16_t scanChannel() override
Performs scan for valid LoRa preamble in the current channel.
Definition SX127x.cpp:264
int16_t setAFCBandwidth(uint32_t afcBw)
Sets FSK automatic frequency correction bandwidth. Allowed values range from 5200 to 500 kHz....
Definition SX127x.cpp:847
virtual void reset()
Reset method. Will reset the chip to the default state using RST pin. Should be implemented in derive...
Definition SX127x.cpp:260
int16_t setOokFixedOrFloorThreshold(uint8_t value)
Fixed threshold for the Data Slicer in OOK mode or floor threshold for the Data Slicer in OOK when Pe...
Definition SX127x.cpp:1017
int16_t enableBitSync()
Enable Bit synchronizer.
Definition SX127x.cpp:1041
int16_t variablePacketLengthMode(uint8_t maxLen=RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK)
Set modem in variable packet length mode. Available in FSK mode only.
Definition SX127x.cpp:1136
int16_t sleep() override
Sets the LoRa module to sleep to save power. Module will not be able to transmit or receive any data ...
Definition SX127x.cpp:288
void setFifoFullAction(void(*func)(void))
Set interrupt service routine function to call when FIFO is full.
Definition SX127x.cpp:428
uint32_t getIrqFlags() override
Read currently active IRQ flags.
Definition SX127x.cpp:1235
bool fifoGet(volatile uint8_t *data, int totalLen, volatile int *rcvLen)
Set interrupt service routine function to call when FIFO is sufficiently full to read.
Definition SX127x.cpp:470
int16_t beginFSK(const uint8_t *chipVersions, uint8_t numVersions, uint32_t freqDev, uint32_t rxBw, uint16_t preambleLength)
Initialization method for FSK modem. Will be called with appropriate parameters when calling FSK init...
Definition SX127x.cpp:73
uint8_t getModemStatus()
Reads modem status. Only available in LoRa mode.
Definition SX127x.cpp:1436
int16_t getModem(ModemType_t *modem) override
Get modem currently in use by the radio.
Definition SX127x.cpp:1682
int16_t invertIQ(bool enable) override
Enable/disable inversion of the I and Q signals.
Definition SX127x.cpp:1660
bool fifoAdd(uint8_t *data, int totalLen, int *remLen)
Set interrupt service routine function to call when FIFO is empty.
Definition SX127x.cpp:447
int16_t stageMode(RadioModeType_t mode, RadioModeConfig_t *cfg) override
Stage mode of the radio to be launched later using launchMode.
Definition SX127x.cpp:1733
int16_t setCurrentLimit(uint8_t currentLimit)
Sets current limit for over current protection at transmitter amplifier. Allowed values range from 45...
Definition SX127x.cpp:631
void clearFHSSInt(void)
Clear the FHSS interrupt.
Definition SX127x.cpp:1975
int16_t writeTxBuffer(const uint8_t *data, size_t len) override
Write a payload into the transmit buffer without staging or starting a transmission....
Definition SX127x.cpp:1894
int16_t setAFC(bool isEnabled)
Enables or disables FSK automatic frequency correction(AFC).
Definition SX127x.cpp:903
int16_t getLoRaRxHeaderInfo(uint8_t *cr, bool *hasCRC)
Get LoRa header information from last received packet. Only valid in explicit header mode.
Definition SX127x.cpp:1118
size_t getPacketLength(bool update=true) override
Query modem for the packet length of received payload.
Definition SX127x.cpp:1090
float getSNR() override
Gets signal-to-noise ratio of the latest received packet. Only available in LoRa mode.
Definition SX127x.cpp:768
int16_t setPreambleLength(size_t len, size_t detLen=0xFFFFFFFF) override
Sets LoRa or FSK preamble length. Allowed values range from 6 to 65535 in LoRa mode or 0 to 65535 in ...
Definition SX127x.cpp:655
int16_t setOokPeakThresholdStep(uint8_t value)
Size of each decrement of the RSSI threshold in the OOK demodulator.
Definition SX127x.cpp:1033
int16_t clearTxBuffer() override
Discard a payload previously written by writeTxBuffer. On radios whose transmit buffer is simply over...
Definition SX127x.cpp:1922
float getAFCError()
Gets current AFC error.
Definition SX127x.cpp:754
int16_t setRSSIThreshold(float dbm)
Sets the RSSI value above which the RSSI interrupt is signaled.
Definition SX127x.cpp:1366
int16_t launchMode() override
Launch previously staged mode.
Definition SX127x.cpp:1930
int16_t receive(uint8_t *data, size_t len, RadioLibTime_t timeout=0) override
Binary receive method. Will attempt to receive arbitrary binary data up to 255 bytes long using LoRa ...
Definition SX127x.cpp:211
uint8_t getFHSSChannel(void)
Gets the FHSS channel in use.
Definition SX127x.cpp:1971
int16_t invertPreamble(bool enable)
Invert FSK preamble polarity. The default (non-inverted) is 0x55, the inverted is 0xAA.
Definition SX127x.cpp:686
int16_t startChannelScan() override
Interrupt-driven channel activity detection method. DIO1 will be activated when LoRa preamble is dete...
Definition SX127x.cpp:578
int16_t fixedPacketLengthMode(uint8_t len=RADIOLIB_SX127X_MAX_PACKET_LENGTH_FSK)
Set modem in fixed packet length mode. Available in FSK mode only.
Definition SX127x.cpp:1132
void setFifoEmptyAction(void(*func)(void))
Set interrupt service routine function to call when FIFO is empty.
Definition SX127x.cpp:415
void clearDio0Action()
Clears interrupt service routine to call when DIO0 activates.
Definition SX127x.cpp:397
int16_t transmit(const uint8_t *data, size_t len, uint8_t addr=0) override
Binary transmit method. Will transmit arbitrary binary data up to 255 bytes long using LoRa or up to ...
Definition SX127x.cpp:171
int16_t standby() override
Sets the LoRa module to standby.
Definition SX127x.cpp:301
int32_t getFrequencyError(bool autoCorrect=false)
Gets frequency error of the latest received packet.
Definition SX127x.cpp:705
void setDio1Action(void(*func)(void), uint32_t dir)
Set interrupt service routine function to call when DIO1 activates.
Definition SX127x.cpp:401
int16_t setDIOPreambleDetect(bool usePreambleDetect)
Configure DIO mapping to use RSSI or Preamble Detect for pins that support it.
Definition SX127x.cpp:1994
void setFifoThreshold(uint8_t threshold)
Set FIFO threshold level. Be aware that threshold is also set in setFifoFullAction method....
Definition SX127x.cpp:424
int16_t begin(const uint8_t *chipVersions, uint8_t numVersions, uint8_t syncWord, uint16_t preambleLength)
Initialization method. Will be called with appropriate parameters when calling initialization method ...
Definition SX127x.cpp:11
int16_t setFHSSHoppingPeriod(uint8_t freqHoppingPeriod)
Sets the hopping period and enables FHSS.
Definition SX127x.cpp:1963
int16_t finishTransmit() override
Clean up after transmission is done.
Definition SX127x.cpp:492
int16_t disableBitSync()
Disable Bit synchronizer (not allowed in Packet mode).
Definition SX127x.cpp:1045
int16_t getMode(RadioModeType_t *mode) override
Read the operating mode the radio is in, as the chip reports it. Unlike PhysicalLayer::stagedMode,...
Definition SX127x.cpp:1698
int16_t getChannelScanResult() override
Read the channel scan result.
Definition SX127x.cpp:611
int16_t setOokThresholdType(uint8_t type)
Selects the type of threshold in the OOK data slicer.
Definition SX127x.cpp:1009
int16_t setFrequencyDeviation(uint32_t freqDev) override
Sets FSK frequency deviation from carrier frequency. Allowed values depend on bit rate setting and mu...
Definition SX127x.cpp:816
void setRfSwitchPins(uint32_t rxEn, uint32_t txEn)
Some modules contain external RF switch controlled by pins. This function gives RadioLib control over...
Definition SX127x.cpp:1446
int8_t getTempRaw()
Reads uncalibrated temperature value. This function will change operating mode and should not be call...
Definition SX127x.cpp:1483
uint8_t randomByte() override
Get one truly random byte from RSSI noise.
Definition SX127x.cpp:1454
RadioLibTime_t calculateTimeOnAir(ModemType_t modem, DataRate_t dr, PacketConfig_t pc, size_t len) override
Calculate the expected time-on-air for a given modem, data rate, packet configuration and payload siz...
Definition SX127x.cpp:1140
void clearDio1Action()
Clears interrupt service routine to call when DIO1 activates.
Definition SX127x.cpp:408
int16_t setLowBatteryThreshold(int8_t level, uint32_t pin=RADIOLIB_NC)
Set low battery indicator threshold.
Definition SX127x.cpp:2059
RadioLibTime_t getTimeOnAir(size_t len) override
Get expected time-on-air for a given size of payload.
Definition SX127x.cpp:1148
int16_t clearIrqFlags(uint32_t irq) override
Clear interrupt on a specific IRQ bit (e.g. RxTimeout, CadDone).
Definition SX127x.cpp:1341
int16_t receiveDirect() override
Enables direct reception mode on pins DIO1 (clock) and DIO2 (data). While in direct mode,...
Definition SX127x.cpp:343
void clearFifoEmptyAction()
Clears interrupt service routine to call when FIFO is empty.
Definition SX127x.cpp:420
int16_t setOokPeakThresholdDecrement(uint8_t value)
Period of decrement of the RSSI threshold in the OOK demodulator.
Definition SX127x.cpp:1025
int16_t setIrqFlags(uint32_t irq) override
Set interrupt on DIO1 to be sent on a specific IRQ bit (e.g. RxTimeout, CadDone). NOTE: Unlike other ...
Definition SX127x.cpp:1239
int16_t setAFCAGCTrigger(uint8_t trigger)
Controls trigger of AFC and AGC.
Definition SX127x.cpp:913
int16_t setCrcFiltering(bool enable=true)
Enable CRC filtering and generation.
Definition SX127x.cpp:1356
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 SX127x.cpp:1450
int16_t setNodeAddress(uint8_t nodeAddr)
Sets FSK node address. Calling this method will enable address filtering. Only available in FSK mode.
Definition SX127x.cpp:963
int16_t setEncoding(uint8_t encoding) override
Sets transmission encoding. Only available in FSK mode. Allowed values are RADIOLIB_ENCODING_NRZ,...
Definition SX127x.cpp:1401
int16_t startReceive() override
Interrupt-driven receive method with default parameters. Implemented for compatibility with PhysicalL...
Definition SX127x.cpp:389
int16_t setBroadcastAddress(uint8_t broadAddr)
Sets FSK broadcast address. Calling this method will enable address filtering. Only available in FSK ...
Definition SX127x.cpp:977
int16_t readData(uint8_t *data, size_t len) override
Reads data that was received after calling startReceive method. When the packet length is not known i...
Definition SX127x.cpp:505
int16_t setSyncWord(uint8_t syncWord)
Sets LoRa sync word. Only available in LoRa mode.
Definition SX127x.cpp:618
uint16_t getIRQFlags()
Reads currently active IRQ flags, can be used to check which event caused an interrupt....
Definition SX127x.cpp:1420
SX127x(Module *mod)
Default constructor. Called internally when creating new LoRa instance.
Definition SX127x.cpp:5
int16_t finishReceive() override
Clean up after reception is done.
Definition SX127x.cpp:561
int16_t setRSSIConfig(uint8_t smoothingSamples, int8_t offset=0)
Sets RSSI measurement configuration in FSK mode.
Definition SX127x.cpp:1372
uint8_t getFHSSHoppingPeriod(void)
Gets FHSS hopping period.
Definition SX127x.cpp:1967
RadioLibTime_t calculateRxTimeout(RadioLibTime_t timeoutUs) override
Calculate the timeout value for this specific module / series (in number of symbols or units of time)...
Definition SX127x.cpp:1199
int16_t setOOK(bool enable)
Enables/disables OOK modulation instead of FSK.
Definition SX127x.cpp:1049
void setDirectAction(void(*func)(void)) override
Set interrupt service routine function to call when data bit is received in direct mode.
Definition SX127x.cpp:1954
void setDio0Action(void(*func)(void), uint32_t dir)
Set interrupt service routine function to call when DIO0 activates.
Definition SX127x.cpp:393
int16_t getChipVersion()
Read version SPI register. Should return SX1278_CHIP_VERSION (0x12) or SX1272_CHIP_VERSION (0x22) if ...
Definition SX127x.cpp:1479
int16_t transmitDirect(uint32_t frf=0) override
Enables direct transmission mode on pins DIO1 (clock) and DIO2 (data). While in direct mode,...
Definition SX127x.cpp:314
int16_t disableAddressFiltering()
Disables FSK address filtering.
Definition SX127x.cpp:991
bool enableOOK
Use OOK modulation instead of FSK.
Definition SX127x.h:640
uint8_t gain
Gain of receiver LNA (low-noise amplifier). Can be set to any integer in range 1 to 6 where 1 is the ...
Definition SX127x.h:634
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:783
Description of RF switch pin states for a single mode. See setRfSwitchTable for details.
Definition Module.h:90
Common channel scan configuration structure.
Definition PhysicalLayer.h:168
Common data rate structure.
Definition PhysicalLayer.h:74
Common packet configuration structure.
Definition PhysicalLayer.h:119
Definition PhysicalLayer.h:214