3 #define REG_LR_FIRMWARE_VERSION_MSB 0x0153 //The address of the register holding the firmware version MSB
4 #define SX1280_REG_LR_ESTIMATED_FREQUENCY_ERROR_MSB 0x0954
5 #define SX1280_REG_LR_ESTIMATED_FREQUENCY_ERROR_MASK 0x0FFFFF
7 #define SX1280_REG_SF_ADDITIONAL_CONFIG 0x925
8 #define SX1280_REG_FREQ_ERR_CORRECTION 0x93C
9 #define SX1280_REG_FLRC_CRC_SEED 0x9C8
10 #define SX1280_REG_FLRC_SYNC_WORD 0x9CF
12 #define SX1280_XTAL_FREQ 52000000
13 #define FREQ_STEP ((double)(SX1280_XTAL_FREQ / pow(2.0, 18.0))) // 198.3642578125
15 #define SX1280_POWER_MIN (-18)
16 #define SX1280_POWER_MAX (13)
20 SX1280_RF_IDLE
= 0x00, //!< The radio is idle
21 SX1280_RF_RX_RUNNING
, //!< The radio is in reception state
22 SX1280_RF_TX_RUNNING
, //!< The radio is in transmission state
23 SX1280_RF_CAD
, //!< The radio is doing channel activity detection
24 } SX1280_RadioStates_t
;
27 * \brief Represents the operating mode the radio is actually running
31 SX1280_MODE_SLEEP
= 0x00, //! The radio is in sleep mode
32 SX1280_MODE_CALIBRATION
, //! The radio is in calibration mode
33 SX1280_MODE_STDBY_RC
, //! The radio is in standby mode with RC oscillator
34 SX1280_MODE_STDBY_XOSC
, //! The radio is in standby mode with XOSC oscillator
35 SX1280_MODE_FS
, //! The radio is in frequency synthesis mode
36 SX1280_MODE_RX
, //! The radio is in receive mode
37 SX1280_MODE_RX_CONT
, //! The radio is in continuous receive mode
38 SX1280_MODE_TX
, //! The radio is in transmit mode
39 SX1280_MODE_CAD
//! The radio is in channel activity detection mode
40 } SX1280_RadioOperatingModes_t
;
42 #define SX1280_RX_TX_CONTINUOUS \
43 (TickTime_t) { RADIO_TICK_SIZE_0015_US, 0xFFFF }
44 #define SX1280_RX_TX_SINGLE \
45 (TickTime_t) { RADIO_TICK_SIZE_0015_US, 0 }
48 * \brief Declares the oscillator in use while in standby mode
50 * Using the STDBY_RC standby mode allow to reduce the energy consumption
51 * STDBY_XOSC should be used for time critical applications
55 SX1280_STDBY_RC
= 0x00,
56 SX1280_STDBY_XOSC
= 0x01,
57 } SX1280_RadioStandbyModes_t
;
60 * \brief Declares the power regulation used to power the device
62 * This command allows the user to specify if DC-DC or LDO is used for power regulation.
63 * Using only LDO implies that the Rx or Tx current is doubled
67 SX1280_USE_LDO
= 0x00, //! Use LDO (default value)
68 SX1280_USE_DCDC
= 0x01, //! Use DCDC
69 } SX1280_RadioRegulatorModes_t
;
72 * \brief Represents the possible packet type (i.e. modem) used
76 SX1280_PACKET_TYPE_GFSK
= 0x00,
77 SX1280_PACKET_TYPE_LORA
,
78 SX1280_PACKET_TYPE_RANGING
,
79 SX1280_PACKET_TYPE_FLRC
,
80 SX1280_PACKET_TYPE_BLE
,
81 SX1280_PACKET_TYPE_NONE
= 0x0F,
82 } SX1280_RadioPacketTypes_t
;
87 // SX1280_PREAMBLE_LENGTH_04_BITS = 0x00, //!< Preamble length: 04 bits
88 // SX1280_PREAMBLE_LENGTH_08_BITS = 0x10, //!< Preamble length: 08 bits
89 // SX1280_PREAMBLE_LENGTH_12_BITS = 0x20, //!< Preamble length: 12 bits
90 // SX1280_PREAMBLE_LENGTH_16_BITS = 0x30, //!< Preamble length: 16 bits
91 // SX1280_PREAMBLE_LENGTH_20_BITS = 0x40, //!< Preamble length: 20 bits
92 // SX1280_PREAMBLE_LENGTH_24_BITS = 0x50, //!< Preamble length: 24 bits
93 // SX1280_PREAMBLE_LENGTH_28_BITS = 0x60, //!< Preamble length: 28 bits
94 // SX1280_PREAMBLE_LENGTH_32_BITS = 0x70, //!< Preamble length: 32 bits
95 // } SX1280_RadioPreambleLengths_t;
99 SX1280_LORA_IQ_NORMAL
= 0x40,
100 SX1280_LORA_IQ_INVERTED
= 0x00,
101 } SX1280_RadioLoRaIQModes_t
;
105 SX1280_RADIO_CRC_OFF
= 0x00, //!< No CRC in use
106 SX1280_RADIO_CRC_1_BYTES
= 0x10,
107 SX1280_RADIO_CRC_2_BYTES
= 0x20,
108 SX1280_RADIO_CRC_3_BYTES
= 0x30,
109 } SX1280_RadioCrcTypes_t
;
112 * \brief Represents the ramping time for power amplifier
116 SX1280_RADIO_RAMP_02_US
= 0x00,
117 SX1280_RADIO_RAMP_04_US
= 0x20,
118 SX1280_RADIO_RAMP_06_US
= 0x40,
119 SX1280_RADIO_RAMP_08_US
= 0x60,
120 SX1280_RADIO_RAMP_10_US
= 0x80,
121 SX1280_RADIO_RAMP_12_US
= 0xA0,
122 SX1280_RADIO_RAMP_16_US
= 0xC0,
123 SX1280_RADIO_RAMP_20_US
= 0xE0,
124 } SX1280_RadioRampTimes_t
;
127 * \brief Represents the number of symbols to be used for channel activity detection operation
131 SX1280_LORA_CAD_01_SYMBOL
= 0x00,
132 SX1280_LORA_CAD_02_SYMBOLS
= 0x20,
133 SX1280_LORA_CAD_04_SYMBOLS
= 0x40,
134 SX1280_LORA_CAD_08_SYMBOLS
= 0x60,
135 SX1280_LORA_CAD_16_SYMBOLS
= 0x80,
136 } SX1280_RadioLoRaCadSymbols_t
;
139 * \brief Represents the possible spreading factor values in LORA packet types
143 SX1280_LORA_SF5
= 0x50,
144 SX1280_LORA_SF6
= 0x60,
145 SX1280_LORA_SF7
= 0x70,
146 SX1280_LORA_SF8
= 0x80,
147 SX1280_LORA_SF9
= 0x90,
148 SX1280_LORA_SF10
= 0xA0,
149 SX1280_LORA_SF11
= 0xB0,
150 SX1280_LORA_SF12
= 0xC0,
151 } SX1280_RadioLoRaSpreadingFactors_t
;
154 * \brief Represents the bandwidth values for LORA packet type
158 SX1280_LORA_BW_0200
= 0x34,
159 SX1280_LORA_BW_0400
= 0x26,
160 SX1280_LORA_BW_0800
= 0x18,
161 SX1280_LORA_BW_1600
= 0x0A,
162 } SX1280_RadioLoRaBandwidths_t
;
165 * \brief Represents the coding rate values for LORA packet type
169 SX1280_LORA_CR_4_5
= 0x01,
170 SX1280_LORA_CR_4_6
= 0x02,
171 SX1280_LORA_CR_4_7
= 0x03,
172 SX1280_LORA_CR_4_8
= 0x04,
173 SX1280_LORA_CR_LI_4_5
= 0x05,
174 SX1280_LORA_CR_LI_4_6
= 0x06,
175 SX1280_LORA_CR_LI_4_8
= 0x07,
176 } SX1280_RadioLoRaCodingRates_t
;
180 SX1280_LORA_PACKET_VARIABLE_LENGTH
= 0x00, //!< The packet is on variable size, header included
181 SX1280_LORA_PACKET_FIXED_LENGTH
= 0x80, //!< The packet is known on both sides, no header included in the packet
182 SX1280_LORA_PACKET_EXPLICIT
= SX1280_LORA_PACKET_VARIABLE_LENGTH
,
183 SX1280_LORA_PACKET_IMPLICIT
= SX1280_LORA_PACKET_FIXED_LENGTH
,
184 } SX1280_RadioLoRaPacketLengthsModes_t
;
188 SX1280_LORA_CRC_ON
= 0x20, //!< CRC activated
189 SX1280_LORA_CRC_OFF
= 0x00, //!< CRC not used
190 } SX1280_RadioLoRaCrcModes_t
;
193 * \brief Represents the bandwidth values for FLRC packet type
197 SX1280_FLRC_BR_1_300_BW_1_2
= 0x45,
198 SX1280_FLRC_BR_1_000_BW_1_2
= 0x69,
199 SX1280_FLRC_BR_0_650_BW_0_6
= 0x86,
200 SX1280_FLRC_BR_0_520_BW_0_6
= 0xAA,
201 SX1280_FLRC_BR_0_325_BW_0_3
= 0xC7,
202 SX1280_FLRC_BR_0_260_BW_0_3
= 0xEB,
203 } SX1280_RadioFlrcBandwidths_t
;
206 * \brief Represents the coding rate values for FLRC packet type
210 SX1280_FLRC_CR_1_2
= 0x00,
211 SX1280_FLRC_CR_3_4
= 0x02,
212 SX1280_FLRC_CR_1_0
= 0x04,
213 } SX1280_RadioFlrcCodingRates_t
;
216 * \brief Represents the Gaussian filter value in FLRC packet types
220 SX1280_FLRC_BT_DIS
= 0x00,
221 SX1280_FLRC_BT_1
= 0x10,
222 SX1280_FLRC_BT_0_5
= 0x20,
223 } SX1280_RadioFlrcGaussianFilter_t
;
227 SX1280_FLRC_SYNC_NOSYNC
= 0x00,
228 SX1280_FLRC_SYNC_WORD_LEN_P32S
= 0x04,
229 } SX1280_RadioFlrcSyncWordLen_t
;
233 SX1280_FLRC_RX_DISABLE_SYNC_WORD
= 0x00,
234 SX1280_FLRC_RX_MATCH_SYNC_WORD_1
= 0x10,
235 SX1280_FLRC_RX_MATCH_SYNC_WORD_2
= 0x20,
236 SX1280_FLRC_RX_MATCH_SYNC_WORD_1_2
= 0x30,
237 SX1280_FLRC_RX_MATCH_SYNC_WORD_3
= 0x40,
238 SX1280_FLRC_RX_MATCH_SYNC_WORD_1_3
= 0x50,
239 SX1280_FLRC_RX_MATCH_SYNC_WORD_2_3
= 0x60,
240 SX1280_FLRC_RX_MATCH_SYNC_WORD_1_2_3
= 0x70,
241 } SX1280_RadioFlrcSyncWordCombination_t
;
245 SX1280_FLRC_PACKET_FIXED_LENGTH
= 0x00,
246 SX1280_FLRC_PACKET_VARIABLE_LENGTH
= 0x20,
247 } SX1280_RadioFlrcPacketType_t
;
251 SX1280_FLRC_CRC_OFF
= 0x00,
252 SX1280_FLRC_CRC_2_BYTE
= 0x10,
253 SX1280_FLRC_CRC_3_BYTE
= 0x20,
254 SX1280_FLRC_CRC_4_BYTE
= 0x30,
255 } SX1280_RadioFlrcCrc_t
;
259 // Error Packet Status
260 SX1280_FLRC_PKT_ERROR_BUSY
= 1 << 0,
261 SX1280_FLRC_PKT_ERROR_PKT_RCVD
= 1 << 1,
262 SX1280_FLRC_PKT_ERROR_HDR_RCVD
= 1 << 2,
263 SX1280_FLRC_PKT_ERROR_ABORT
= 1 << 3,
264 SX1280_FLRC_PKT_ERROR_CRC
= 1 << 4,
265 SX1280_FLRC_PKT_ERROR_LENGTH
= 1 << 5,
266 SX1280_FLRC_PKT_ERROR_SYNC
= 1 << 6,
269 typedef enum RadioCommands_u
271 SX1280_RADIO_GET_STATUS
= 0xC0,
272 SX1280_RADIO_WRITE_REGISTER
= 0x18,
273 SX1280_RADIO_READ_REGISTER
= 0x19,
274 SX1280_RADIO_WRITE_BUFFER
= 0x1A,
275 SX1280_RADIO_READ_BUFFER
= 0x1B,
276 SX1280_RADIO_SET_SLEEP
= 0x84,
277 SX1280_RADIO_SET_STANDBY
= 0x80,
278 SX1280_RADIO_SET_FS
= 0xC1,
279 SX1280_RADIO_SET_TX
= 0x83,
280 SX1280_RADIO_SET_RX
= 0x82,
281 SX1280_RADIO_SET_RXDUTYCYCLE
= 0x94,
282 SX1280_RADIO_SET_CAD
= 0xC5,
283 SX1280_RADIO_SET_TXCONTINUOUSWAVE
= 0xD1,
284 SX1280_RADIO_SET_TXCONTINUOUSPREAMBLE
= 0xD2,
285 SX1280_RADIO_SET_PACKETTYPE
= 0x8A,
286 SX1280_RADIO_GET_PACKETTYPE
= 0x03,
287 SX1280_RADIO_SET_RFFREQUENCY
= 0x86,
288 SX1280_RADIO_SET_TXPARAMS
= 0x8E,
289 SX1280_RADIO_SET_CADPARAMS
= 0x88,
290 SX1280_RADIO_SET_BUFFERBASEADDRESS
= 0x8F,
291 SX1280_RADIO_SET_MODULATIONPARAMS
= 0x8B,
292 SX1280_RADIO_SET_PACKETPARAMS
= 0x8C,
293 SX1280_RADIO_GET_RXBUFFERSTATUS
= 0x17,
294 SX1280_RADIO_GET_PACKETSTATUS
= 0x1D,
295 SX1280_RADIO_GET_RSSIINST
= 0x1F,
296 SX1280_RADIO_SET_DIOIRQPARAMS
= 0x8D,
297 SX1280_RADIO_GET_IRQSTATUS
= 0x15,
298 SX1280_RADIO_CLR_IRQSTATUS
= 0x97,
299 SX1280_RADIO_CALIBRATE
= 0x89,
300 SX1280_RADIO_SET_REGULATORMODE
= 0x96,
301 SX1280_RADIO_SET_SAVECONTEXT
= 0xD5,
302 SX1280_RADIO_SET_AUTOTX
= 0x98,
303 SX1280_RADIO_SET_AUTOFS
= 0x9E,
304 SX1280_RADIO_SET_LONGPREAMBLE
= 0x9B,
305 SX1280_RADIO_SET_UARTSPEED
= 0x9D,
306 SX1280_RADIO_SET_RANGING_ROLE
= 0xA3,
307 } SX1280_RadioCommands_t
;
311 SX1280_IRQ_RADIO_NONE
= 0x0000,
312 SX1280_IRQ_TX_DONE
= 0x0001,
313 SX1280_IRQ_RX_DONE
= 0x0002,
314 SX1280_IRQ_SYNCWORD_VALID
= 0x0004,
315 SX1280_IRQ_SYNCWORD_ERROR
= 0x0008,
316 SX1280_IRQ_HEADER_VALID
= 0x0010,
317 SX1280_IRQ_HEADER_ERROR
= 0x0020,
318 SX1280_IRQ_CRC_ERROR
= 0x0040,
319 SX1280_IRQ_RANGING_SLAVE_RESPONSE_DONE
= 0x0080,
320 SX1280_IRQ_RANGING_SLAVE_REQUEST_DISCARDED
= 0x0100,
321 SX1280_IRQ_RANGING_MASTER_RESULT_VALID
= 0x0200,
322 SX1280_IRQ_RANGING_MASTER_TIMEOUT
= 0x0400,
323 SX1280_IRQ_RANGING_SLAVE_REQUEST_VALID
= 0x0800,
324 SX1280_IRQ_CAD_DONE
= 0x1000,
325 SX1280_IRQ_CAD_DETECTED
= 0x2000,
326 SX1280_IRQ_RX_TX_TIMEOUT
= 0x4000,
327 SX1280_IRQ_PREAMBLE_DETECTED
= 0x8000,
328 SX1280_IRQ_RADIO_ALL
= 0xFFFF,
329 } SX1280_RadioIrqMasks_t
;
333 SX1280_RADIO_DIO1
= 0x02,
334 SX1280_RADIO_DIO2
= 0x04,
335 SX1280_RADIO_DIO3
= 0x08,
336 } SX1280_RadioDios_t
;
340 SX1280_RADIO_TICK_SIZE_0015_US
= 0x00,
341 SX1280_RADIO_TICK_SIZE_0062_US
= 0x01,
342 SX1280_RADIO_TICK_SIZE_1000_US
= 0x02,
343 SX1280_RADIO_TICK_SIZE_4000_US
= 0x03,
344 } SX1280_RadioTickSizes_t
;