提交 | 用户 | age
|
8b51c7
|
1 |
/*! |
Q |
2 |
* \file sx126x.h |
|
3 |
* |
|
4 |
* \brief SX126x driver implementation |
|
5 |
* |
|
6 |
* \copyright Revised BSD License, see section \ref LICENSE. |
|
7 |
* |
|
8 |
* \code |
|
9 |
* ______ _ |
|
10 |
* / _____) _ | | |
|
11 |
* ( (____ _____ ____ _| |_ _____ ____| |__ |
|
12 |
* \____ \| ___ | (_ _) ___ |/ ___) _ \ |
|
13 |
* _____) ) ____| | | || |_| ____( (___| | | | |
|
14 |
* (______/|_____)_|_|_| \__)_____)\____)_| |_| |
|
15 |
* (C)2013-2017 Semtech |
|
16 |
* |
|
17 |
* \endcode |
|
18 |
* |
|
19 |
* \author Miguel Luis ( Semtech ) |
|
20 |
* |
|
21 |
* \author Gregory Cristian ( Semtech ) |
|
22 |
*/ |
|
23 |
#ifndef __SX126x_H__ |
|
24 |
#define __SX126x_H__ |
|
25 |
|
|
26 |
#include <stdint.h> |
|
27 |
#include <stdbool.h> |
|
28 |
|
|
29 |
|
|
30 |
#define SX1261 1 |
|
31 |
#define SX1262 2 |
|
32 |
|
|
33 |
#ifdef USE_TCXO |
|
34 |
/*! |
|
35 |
* Radio complete Wake-up Time with TCXO stabilisation time |
|
36 |
*/ |
|
37 |
#define RADIO_TCXO_SETUP_TIME 5 // [ms] |
|
38 |
#else |
|
39 |
/*! |
|
40 |
* Radio complete Wake-up Time with TCXO stabilisation time |
|
41 |
*/ |
|
42 |
#define RADIO_TCXO_SETUP_TIME 0 // No Used |
|
43 |
#endif |
|
44 |
|
|
45 |
/*! |
|
46 |
* Radio complete Wake-up Time with margin for temperature compensation |
|
47 |
*/ |
|
48 |
#define RADIO_WAKEUP_TIME 3 // [ms] |
|
49 |
|
|
50 |
/*! |
|
51 |
* \brief Compensation delay for SetAutoTx/Rx functions in 15.625 microseconds |
|
52 |
*/ |
|
53 |
#define AUTO_RX_TX_OFFSET 2 |
|
54 |
|
|
55 |
/*! |
|
56 |
* \brief LFSR initial value to compute IBM type CRC |
|
57 |
*/ |
|
58 |
#define CRC_IBM_SEED 0xFFFF |
|
59 |
|
|
60 |
/*! |
|
61 |
* \brief LFSR initial value to compute CCIT type CRC |
|
62 |
*/ |
|
63 |
#define CRC_CCITT_SEED 0x1D0F |
|
64 |
|
|
65 |
/*! |
|
66 |
* \brief Polynomial used to compute IBM CRC |
|
67 |
*/ |
|
68 |
#define CRC_POLYNOMIAL_IBM 0x8005 |
|
69 |
|
|
70 |
/*! |
|
71 |
* \brief Polynomial used to compute CCIT CRC |
|
72 |
*/ |
|
73 |
#define CRC_POLYNOMIAL_CCITT 0x1021 |
|
74 |
|
|
75 |
/*! |
|
76 |
* \brief The address of the register holding the first byte defining the CRC seed |
|
77 |
* |
|
78 |
*/ |
|
79 |
#define REG_LR_CRCSEEDBASEADDR 0x06BC |
|
80 |
|
|
81 |
/*! |
|
82 |
* \brief The address of the register holding the first byte defining the CRC polynomial |
|
83 |
*/ |
|
84 |
#define REG_LR_CRCPOLYBASEADDR 0x06BE |
|
85 |
|
|
86 |
/*! |
|
87 |
* \brief The address of the register holding the first byte defining the whitening seed |
|
88 |
*/ |
|
89 |
#define REG_LR_WHITSEEDBASEADDR_MSB 0x06B8 |
|
90 |
#define REG_LR_WHITSEEDBASEADDR_LSB 0x06B9 |
|
91 |
|
|
92 |
/*! |
|
93 |
* \brief The address of the register holding the packet configuration |
|
94 |
*/ |
|
95 |
#define REG_LR_PACKETPARAMS 0x0704 |
|
96 |
|
|
97 |
/*! |
|
98 |
* \brief The address of the register holding the payload size |
|
99 |
*/ |
|
100 |
#define REG_LR_PAYLOADLENGTH 0x0702 |
|
101 |
|
|
102 |
/*! |
|
103 |
* \brief The addresses of the registers holding SyncWords values |
|
104 |
*/ |
|
105 |
#define REG_LR_SYNCWORDBASEADDRESS 0x06C0 |
|
106 |
|
|
107 |
/*! |
|
108 |
* \brief The addresses of the register holding LoRa Modem SyncWord value |
|
109 |
*/ |
|
110 |
#define REG_LR_SYNCWORD 0x0740 |
|
111 |
|
|
112 |
/*! |
|
113 |
* Syncword for Private LoRa networks |
|
114 |
*/ |
|
115 |
#define LORA_MAC_PRIVATE_SYNCWORD 0x1424 |
|
116 |
|
|
117 |
/*! |
|
118 |
* Syncword for Public LoRa networks |
|
119 |
*/ |
|
120 |
#define LORA_MAC_PUBLIC_SYNCWORD 0x3444 |
|
121 |
|
|
122 |
/*! |
|
123 |
* The address of the register giving a 4 bytes random number |
|
124 |
*/ |
|
125 |
#define RANDOM_NUMBER_GENERATORBASEADDR 0x0819 |
|
126 |
|
|
127 |
/*! |
|
128 |
* The address of the register holding RX Gain value (0x94: power saving, 0x96: rx boosted) |
|
129 |
*/ |
|
130 |
#define REG_RX_GAIN 0x08AC |
|
131 |
|
|
132 |
/*! |
|
133 |
* Change the value on the device internal trimming capacitor |
|
134 |
*/ |
|
135 |
#define REG_XTA_TRIM 0x0911 |
|
136 |
|
|
137 |
/*! |
|
138 |
* Set the current max value in the over current protection |
|
139 |
*/ |
|
140 |
#define REG_OCP 0x08E7 |
|
141 |
|
|
142 |
/*! |
|
143 |
* \brief Structure describing the radio status |
|
144 |
*/ |
|
145 |
typedef union RadioStatus_u |
|
146 |
{ |
|
147 |
uint8_t Value; |
|
148 |
struct |
|
149 |
{ //bit order is lsb -> msb |
|
150 |
uint8_t Reserved : 1; //!< Reserved |
|
151 |
uint8_t CmdStatus : 3; //!< Command status |
|
152 |
uint8_t ChipMode : 3; //!< Chip mode |
|
153 |
uint8_t CpuBusy : 1; //!< Flag for CPU radio busy |
|
154 |
}Fields; |
|
155 |
}RadioStatus_t; |
|
156 |
|
|
157 |
/*! |
|
158 |
* \brief Structure describing the error codes for callback functions |
|
159 |
*/ |
|
160 |
typedef enum |
|
161 |
{ |
|
162 |
IRQ_HEADER_ERROR_CODE = 0x01, |
|
163 |
IRQ_SYNCWORD_ERROR_CODE = 0x02, |
|
164 |
IRQ_CRC_ERROR_CODE = 0x04, |
|
165 |
}IrqErrorCode_t; |
|
166 |
|
|
167 |
enum IrqPblSyncHeaderCode_t |
|
168 |
{ |
|
169 |
IRQ_PBL_DETECT_CODE = 0x01, |
|
170 |
IRQ_SYNCWORD_VALID_CODE = 0x02, |
|
171 |
IRQ_HEADER_VALID_CODE = 0x04, |
|
172 |
}; |
|
173 |
|
|
174 |
/*! |
|
175 |
* \brief Represents the operating mode the radio is actually running |
|
176 |
*/ |
|
177 |
typedef enum |
|
178 |
{ |
|
179 |
MODE_SLEEP = 0x00, //! The radio is in sleep mode |
|
180 |
MODE_STDBY_RC, //! The radio is in standby mode with RC oscillator |
|
181 |
MODE_STDBY_XOSC, //! The radio is in standby mode with XOSC oscillator |
|
182 |
MODE_FS, //! The radio is in frequency synthesis mode |
|
183 |
MODE_TX, //! The radio is in transmit mode |
|
184 |
MODE_RX, //! The radio is in receive mode |
|
185 |
MODE_RX_DC, //! The radio is in receive duty cycle mode |
|
186 |
MODE_CAD //! The radio is in channel activity detection mode |
|
187 |
}RadioOperatingModes_t; |
|
188 |
|
|
189 |
/*! |
|
190 |
* \brief Declares the oscillator in use while in standby mode |
|
191 |
* |
|
192 |
* Using the STDBY_RC standby mode allow to reduce the energy consumption |
|
193 |
* STDBY_XOSC should be used for time critical applications |
|
194 |
*/ |
|
195 |
typedef enum |
|
196 |
{ |
|
197 |
STDBY_RC = 0x00, |
|
198 |
STDBY_XOSC = 0x01, |
|
199 |
}RadioStandbyModes_t; |
|
200 |
|
|
201 |
/*! |
|
202 |
* \brief Declares the power regulation used to power the device |
|
203 |
* |
|
204 |
* This command allows the user to specify if DC-DC or LDO is used for power regulation. |
|
205 |
* Using only LDO implies that the Rx or Tx current is doubled |
|
206 |
*/ |
|
207 |
typedef enum |
|
208 |
{ |
|
209 |
USE_LDO = 0x00, // default |
|
210 |
USE_DCDC = 0x01, |
|
211 |
}RadioRegulatorMode_t; |
|
212 |
|
|
213 |
/*! |
|
214 |
* \brief Represents the possible packet type (i.e. modem) used |
|
215 |
*/ |
|
216 |
typedef enum |
|
217 |
{ |
|
218 |
PACKET_TYPE_GFSK = 0x00, |
|
219 |
PACKET_TYPE_LORA = 0x01, |
|
220 |
PACKET_TYPE_NONE = 0x0F, |
|
221 |
}RadioPacketTypes_t; |
|
222 |
|
|
223 |
/*! |
|
224 |
* \brief Represents the ramping time for power amplifier |
|
225 |
*/ |
|
226 |
typedef enum |
|
227 |
{ |
|
228 |
RADIO_RAMP_10_US = 0x00, |
|
229 |
RADIO_RAMP_20_US = 0x01, |
|
230 |
RADIO_RAMP_40_US = 0x02, |
|
231 |
RADIO_RAMP_80_US = 0x03, |
|
232 |
RADIO_RAMP_200_US = 0x04, |
|
233 |
RADIO_RAMP_800_US = 0x05, |
|
234 |
RADIO_RAMP_1700_US = 0x06, |
|
235 |
RADIO_RAMP_3400_US = 0x07, |
|
236 |
}RadioRampTimes_t; |
|
237 |
|
|
238 |
/*! |
|
239 |
* \brief Represents the number of symbols to be used for channel activity detection operation |
|
240 |
*/ |
|
241 |
typedef enum |
|
242 |
{ |
|
243 |
LORA_CAD_01_SYMBOL = 0x00, |
|
244 |
LORA_CAD_02_SYMBOL = 0x01, |
|
245 |
LORA_CAD_04_SYMBOL = 0x02, |
|
246 |
LORA_CAD_08_SYMBOL = 0x03, |
|
247 |
LORA_CAD_16_SYMBOL = 0x04, |
|
248 |
}RadioLoRaCadSymbols_t; |
|
249 |
|
|
250 |
/*! |
|
251 |
* \brief Represents the Channel Activity Detection actions after the CAD operation is finished |
|
252 |
*/ |
|
253 |
typedef enum |
|
254 |
{ |
|
255 |
LORA_CAD_ONLY = 0x00, |
|
256 |
LORA_CAD_RX = 0x01, |
|
257 |
LORA_CAD_LBT = 0x10, |
|
258 |
}RadioCadExitModes_t; |
|
259 |
|
|
260 |
/*! |
|
261 |
* \brief Represents the modulation shaping parameter |
|
262 |
*/ |
|
263 |
typedef enum |
|
264 |
{ |
|
265 |
MOD_SHAPING_OFF = 0x00, |
|
266 |
MOD_SHAPING_G_BT_03 = 0x08, |
|
267 |
MOD_SHAPING_G_BT_05 = 0x09, |
|
268 |
MOD_SHAPING_G_BT_07 = 0x0A, |
|
269 |
MOD_SHAPING_G_BT_1 = 0x0B, |
|
270 |
}RadioModShapings_t; |
|
271 |
|
|
272 |
/*! |
|
273 |
* \brief Represents the modulation shaping parameter |
|
274 |
*/ |
|
275 |
typedef enum |
|
276 |
{ |
|
277 |
RX_BW_4800 = 0x1F, |
|
278 |
RX_BW_5800 = 0x17, |
|
279 |
RX_BW_7300 = 0x0F, |
|
280 |
RX_BW_9700 = 0x1E, |
|
281 |
RX_BW_11700 = 0x16, |
|
282 |
RX_BW_14600 = 0x0E, |
|
283 |
RX_BW_19500 = 0x1D, |
|
284 |
RX_BW_23400 = 0x15, |
|
285 |
RX_BW_29300 = 0x0D, |
|
286 |
RX_BW_39000 = 0x1C, |
|
287 |
RX_BW_46900 = 0x14, |
|
288 |
RX_BW_58600 = 0x0C, |
|
289 |
RX_BW_78200 = 0x1B, |
|
290 |
RX_BW_93800 = 0x13, |
|
291 |
RX_BW_117300 = 0x0B, |
|
292 |
RX_BW_156200 = 0x1A, |
|
293 |
RX_BW_187200 = 0x12, |
|
294 |
RX_BW_234300 = 0x0A, |
|
295 |
RX_BW_312000 = 0x19, |
|
296 |
RX_BW_373600 = 0x11, |
|
297 |
RX_BW_467000 = 0x09, |
|
298 |
}RadioRxBandwidth_t; |
|
299 |
|
|
300 |
/*! |
|
301 |
* \brief Represents the possible spreading factor values in LoRa packet types |
|
302 |
*/ |
|
303 |
typedef enum |
|
304 |
{ |
|
305 |
LORA_SF5 = 0x05, |
|
306 |
LORA_SF6 = 0x06, |
|
307 |
LORA_SF7 = 0x07, |
|
308 |
LORA_SF8 = 0x08, |
|
309 |
LORA_SF9 = 0x09, |
|
310 |
LORA_SF10 = 0x0A, |
|
311 |
LORA_SF11 = 0x0B, |
|
312 |
LORA_SF12 = 0x0C, |
|
313 |
}RadioLoRaSpreadingFactors_t; |
|
314 |
|
|
315 |
/*! |
|
316 |
* \brief Represents the bandwidth values for LoRa packet type |
|
317 |
*/ |
|
318 |
typedef enum |
|
319 |
{ |
|
320 |
LORA_BW_500 = 6, |
|
321 |
LORA_BW_250 = 5, |
|
322 |
LORA_BW_125 = 4, |
|
323 |
LORA_BW_062 = 3, |
|
324 |
LORA_BW_041 = 10, |
|
325 |
LORA_BW_031 = 2, |
|
326 |
LORA_BW_020 = 9, |
|
327 |
LORA_BW_015 = 1, |
|
328 |
LORA_BW_010 = 8, |
|
329 |
LORA_BW_007 = 0, |
|
330 |
}RadioLoRaBandwidths_t; |
|
331 |
|
|
332 |
/*! |
|
333 |
* \brief Represents the coding rate values for LoRa packet type |
|
334 |
*/ |
|
335 |
typedef enum |
|
336 |
{ |
|
337 |
LORA_CR_4_5 = 0x01, |
|
338 |
LORA_CR_4_6 = 0x02, |
|
339 |
LORA_CR_4_7 = 0x03, |
|
340 |
LORA_CR_4_8 = 0x04, |
|
341 |
}RadioLoRaCodingRates_t; |
|
342 |
|
|
343 |
/*! |
|
344 |
* \brief Represents the preamble length used to detect the packet on Rx side |
|
345 |
*/ |
|
346 |
typedef enum |
|
347 |
{ |
|
348 |
RADIO_PREAMBLE_DETECTOR_OFF = 0x00, //!< Preamble detection length off |
|
349 |
RADIO_PREAMBLE_DETECTOR_08_BITS = 0x04, //!< Preamble detection length 8 bits |
|
350 |
RADIO_PREAMBLE_DETECTOR_16_BITS = 0x05, //!< Preamble detection length 16 bits |
|
351 |
RADIO_PREAMBLE_DETECTOR_24_BITS = 0x06, //!< Preamble detection length 24 bits |
|
352 |
RADIO_PREAMBLE_DETECTOR_32_BITS = 0x07, //!< Preamble detection length 32 bit |
|
353 |
}RadioPreambleDetection_t; |
|
354 |
|
|
355 |
/*! |
|
356 |
* \brief Represents the possible combinations of SyncWord correlators activated |
|
357 |
*/ |
|
358 |
typedef enum |
|
359 |
{ |
|
360 |
RADIO_ADDRESSCOMP_FILT_OFF = 0x00, //!< No correlator turned on, i.e. do not search for SyncWord |
|
361 |
RADIO_ADDRESSCOMP_FILT_NODE = 0x01, |
|
362 |
RADIO_ADDRESSCOMP_FILT_NODE_BROAD = 0x02, |
|
363 |
}RadioAddressComp_t; |
|
364 |
|
|
365 |
/*! |
|
366 |
* \brief Radio GFSK packet length mode |
|
367 |
*/ |
|
368 |
typedef enum |
|
369 |
{ |
|
370 |
RADIO_PACKET_FIXED_LENGTH = 0x00, //!< The packet is known on both sides, no header included in the packet |
|
371 |
RADIO_PACKET_VARIABLE_LENGTH = 0x01, //!< The packet is on variable size, header included |
|
372 |
}RadioPacketLengthModes_t; |
|
373 |
|
|
374 |
/*! |
|
375 |
* \brief Represents the CRC length |
|
376 |
*/ |
|
377 |
typedef enum |
|
378 |
{ |
|
379 |
RADIO_CRC_OFF = 0x01, //!< No CRC in use |
|
380 |
RADIO_CRC_1_BYTES = 0x00, |
|
381 |
RADIO_CRC_2_BYTES = 0x02, |
|
382 |
RADIO_CRC_1_BYTES_INV = 0x04, |
|
383 |
RADIO_CRC_2_BYTES_INV = 0x06, |
|
384 |
RADIO_CRC_2_BYTES_IBM = 0xF1, |
|
385 |
RADIO_CRC_2_BYTES_CCIT = 0xF2, |
|
386 |
}RadioCrcTypes_t; |
|
387 |
|
|
388 |
/*! |
|
389 |
* \brief Radio whitening mode activated or deactivated |
|
390 |
*/ |
|
391 |
typedef enum |
|
392 |
{ |
|
393 |
RADIO_DC_FREE_OFF = 0x00, |
|
394 |
RADIO_DC_FREEWHITENING = 0x01, |
|
395 |
}RadioDcFree_t; |
|
396 |
|
|
397 |
/*! |
|
398 |
* \brief Holds the Radio lengths mode for the LoRa packet type |
|
399 |
*/ |
|
400 |
typedef enum |
|
401 |
{ |
|
402 |
LORA_PACKET_VARIABLE_LENGTH = 0x00, //!< The packet is on variable size, header included |
|
403 |
LORA_PACKET_FIXED_LENGTH = 0x01, //!< The packet is known on both sides, no header included in the packet |
|
404 |
LORA_PACKET_EXPLICIT = LORA_PACKET_VARIABLE_LENGTH, |
|
405 |
LORA_PACKET_IMPLICIT = LORA_PACKET_FIXED_LENGTH, |
|
406 |
}RadioLoRaPacketLengthsMode_t; |
|
407 |
|
|
408 |
/*! |
|
409 |
* \brief Represents the CRC mode for LoRa packet type |
|
410 |
*/ |
|
411 |
typedef enum |
|
412 |
{ |
|
413 |
LORA_CRC_ON = 0x01, //!< CRC activated |
|
414 |
LORA_CRC_OFF = 0x00, //!< CRC not used |
|
415 |
}RadioLoRaCrcModes_t; |
|
416 |
|
|
417 |
/*! |
|
418 |
* \brief Represents the IQ mode for LoRa packet type |
|
419 |
*/ |
|
420 |
typedef enum |
|
421 |
{ |
|
422 |
LORA_IQ_NORMAL = 0x00, |
|
423 |
LORA_IQ_INVERTED = 0x01, |
|
424 |
}RadioLoRaIQModes_t; |
|
425 |
|
|
426 |
/*! |
|
427 |
* \brief Represents the voltage used to control the TCXO on/off from DIO3 |
|
428 |
*/ |
|
429 |
typedef enum |
|
430 |
{ |
|
431 |
TCXO_CTRL_1_6V = 0x00, |
|
432 |
TCXO_CTRL_1_7V = 0x01, |
|
433 |
TCXO_CTRL_1_8V = 0x02, |
|
434 |
TCXO_CTRL_2_2V = 0x03, |
|
435 |
TCXO_CTRL_2_4V = 0x04, |
|
436 |
TCXO_CTRL_2_7V = 0x05, |
|
437 |
TCXO_CTRL_3_0V = 0x06, |
|
438 |
TCXO_CTRL_3_3V = 0x07, |
|
439 |
}RadioTcxoCtrlVoltage_t; |
|
440 |
|
|
441 |
/*! |
|
442 |
* \brief Represents the interruption masks available for the radio |
|
443 |
* |
|
444 |
* \remark Note that not all these interruptions are available for all packet types |
|
445 |
*/ |
|
446 |
typedef enum |
|
447 |
{ |
|
448 |
IRQ_RADIO_NONE = 0x0000, |
|
449 |
IRQ_TX_DONE = 0x0001, |
|
450 |
IRQ_RX_DONE = 0x0002, |
|
451 |
IRQ_PREAMBLE_DETECTED = 0x0004, |
|
452 |
IRQ_SYNCWORD_VALID = 0x0008, |
|
453 |
IRQ_HEADER_VALID = 0x0010, |
|
454 |
IRQ_HEADER_ERROR = 0x0020, |
|
455 |
IRQ_CRC_ERROR = 0x0040, |
|
456 |
IRQ_CAD_DONE = 0x0080, |
|
457 |
IRQ_CAD_ACTIVITY_DETECTED = 0x0100, |
|
458 |
IRQ_RX_TX_TIMEOUT = 0x0200, |
|
459 |
IRQ_RADIO_ALL = 0xFFFF, |
|
460 |
}RadioIrqMasks_t; |
|
461 |
|
|
462 |
/*! |
|
463 |
* \brief Represents all possible opcode understood by the radio |
|
464 |
*/ |
|
465 |
typedef enum RadioCommands_e |
|
466 |
{ |
|
467 |
RADIO_GET_STATUS = 0xC0, |
|
468 |
RADIO_WRITE_REGISTER = 0x0D, |
|
469 |
RADIO_READ_REGISTER = 0x1D, |
|
470 |
RADIO_WRITE_BUFFER = 0x0E, |
|
471 |
RADIO_READ_BUFFER = 0x1E, |
|
472 |
RADIO_SET_SLEEP = 0x84, |
|
473 |
RADIO_SET_STANDBY = 0x80, |
|
474 |
RADIO_SET_FS = 0xC1, |
|
475 |
RADIO_SET_TX = 0x83, |
|
476 |
RADIO_SET_RX = 0x82, |
|
477 |
RADIO_SET_RXDUTYCYCLE = 0x94, |
|
478 |
RADIO_SET_CAD = 0xC5, |
|
479 |
RADIO_SET_TXCONTINUOUSWAVE = 0xD1, |
|
480 |
RADIO_SET_TXCONTINUOUSPREAMBLE = 0xD2, |
|
481 |
RADIO_SET_PACKETTYPE = 0x8A, |
|
482 |
RADIO_GET_PACKETTYPE = 0x11, |
|
483 |
RADIO_SET_RFFREQUENCY = 0x86, |
|
484 |
RADIO_SET_TXPARAMS = 0x8E, |
|
485 |
RADIO_SET_PACONFIG = 0x95, |
|
486 |
RADIO_SET_CADPARAMS = 0x88, |
|
487 |
RADIO_SET_BUFFERBASEADDRESS = 0x8F, |
|
488 |
RADIO_SET_MODULATIONPARAMS = 0x8B, |
|
489 |
RADIO_SET_PACKETPARAMS = 0x8C, |
|
490 |
RADIO_GET_RXBUFFERSTATUS = 0x13, |
|
491 |
RADIO_GET_PACKETSTATUS = 0x14, |
|
492 |
RADIO_GET_RSSIINST = 0x15, |
|
493 |
RADIO_GET_STATS = 0x10, |
|
494 |
RADIO_RESET_STATS = 0x00, |
|
495 |
RADIO_CFG_DIOIRQ = 0x08, |
|
496 |
RADIO_GET_IRQSTATUS = 0x12, |
|
497 |
RADIO_CLR_IRQSTATUS = 0x02, |
|
498 |
RADIO_CALIBRATE = 0x89, |
|
499 |
RADIO_CALIBRATEIMAGE = 0x98, |
|
500 |
RADIO_SET_REGULATORMODE = 0x96, |
|
501 |
RADIO_GET_ERROR = 0x17, |
|
502 |
RADIO_CLR_ERROR = 0x07, |
|
503 |
RADIO_SET_TCXOMODE = 0x97, |
|
504 |
RADIO_SET_TXFALLBACKMODE = 0x93, |
|
505 |
RADIO_SET_RFSWITCHMODE = 0x9D, |
|
506 |
RADIO_SET_STOPRXTIMERONPREAMBLE = 0x9F, |
|
507 |
RADIO_SET_LORASYMBTIMEOUT = 0xA0, |
|
508 |
}RadioCommands_t; |
|
509 |
|
|
510 |
/*! |
|
511 |
* \brief The type describing the modulation parameters for every packet types |
|
512 |
*/ |
|
513 |
typedef struct |
|
514 |
{ |
|
515 |
RadioPacketTypes_t PacketType; //!< Packet to which the modulation parameters are referring to. |
|
516 |
struct |
|
517 |
{ |
|
518 |
struct |
|
519 |
{ |
|
520 |
uint32_t BitRate; |
|
521 |
uint32_t Fdev; |
|
522 |
RadioModShapings_t ModulationShaping; |
|
523 |
uint8_t Bandwidth; |
|
524 |
}Gfsk; |
|
525 |
struct |
|
526 |
{ |
|
527 |
RadioLoRaSpreadingFactors_t SpreadingFactor; //!< Spreading Factor for the LoRa modulation |
|
528 |
RadioLoRaBandwidths_t Bandwidth; //!< Bandwidth for the LoRa modulation |
|
529 |
RadioLoRaCodingRates_t CodingRate; //!< Coding rate for the LoRa modulation |
|
530 |
uint8_t LowDatarateOptimize; //!< Indicates if the modem uses the low datarate optimization |
|
531 |
}LoRa; |
|
532 |
}Params; //!< Holds the modulation parameters structure |
|
533 |
}ModulationParams_t; |
|
534 |
|
|
535 |
/*! |
|
536 |
* \brief The type describing the packet parameters for every packet types |
|
537 |
*/ |
|
538 |
typedef struct |
|
539 |
{ |
|
540 |
RadioPacketTypes_t PacketType; //!< Packet to which the packet parameters are referring to. |
|
541 |
struct |
|
542 |
{ |
|
543 |
/*! |
|
544 |
* \brief Holds the GFSK packet parameters |
|
545 |
*/ |
|
546 |
struct |
|
547 |
{ |
|
548 |
uint16_t PreambleLength; //!< The preamble Tx length for GFSK packet type in bit |
|
549 |
RadioPreambleDetection_t PreambleMinDetect; //!< The preamble Rx length minimal for GFSK packet type |
|
550 |
uint8_t SyncWordLength; //!< The synchronization word length for GFSK packet type |
|
551 |
RadioAddressComp_t AddrComp; //!< Activated SyncWord correlators |
|
552 |
RadioPacketLengthModes_t HeaderType; //!< If the header is explicit, it will be transmitted in the GFSK packet. If the header is implicit, it will not be transmitted |
|
553 |
uint8_t PayloadLength; //!< Size of the payload in the GFSK packet |
|
554 |
RadioCrcTypes_t CrcLength; //!< Size of the CRC block in the GFSK packet |
|
555 |
RadioDcFree_t DcFree; |
|
556 |
}Gfsk; |
|
557 |
/*! |
|
558 |
* \brief Holds the LoRa packet parameters |
|
559 |
*/ |
|
560 |
struct |
|
561 |
{ |
|
562 |
uint16_t PreambleLength; //!< The preamble length is the number of LoRa symbols in the preamble |
|
563 |
RadioLoRaPacketLengthsMode_t HeaderType; //!< If the header is explicit, it will be transmitted in the LoRa packet. If the header is implicit, it will not be transmitted |
|
564 |
uint8_t PayloadLength; //!< Size of the payload in the LoRa packet |
|
565 |
RadioLoRaCrcModes_t CrcMode; //!< Size of CRC block in LoRa packet |
|
566 |
RadioLoRaIQModes_t InvertIQ; //!< Allows to swap IQ for LoRa packet |
|
567 |
}LoRa; |
|
568 |
}Params; //!< Holds the packet parameters structure |
|
569 |
}PacketParams_t; |
|
570 |
|
|
571 |
/*! |
|
572 |
* \brief Represents the packet status for every packet type |
|
573 |
*/ |
|
574 |
typedef struct |
|
575 |
{ |
|
576 |
RadioPacketTypes_t packetType; //!< Packet to which the packet status are referring to. |
|
577 |
struct |
|
578 |
{ |
|
579 |
struct |
|
580 |
{ |
|
581 |
uint8_t RxStatus; |
|
582 |
int8_t RssiAvg; //!< The averaged RSSI |
|
583 |
int8_t RssiSync; //!< The RSSI measured on last packet |
|
584 |
uint32_t FreqError; |
|
585 |
}Gfsk; |
|
586 |
struct |
|
587 |
{ |
|
588 |
int8_t RssiPkt; //!< The RSSI of the last packet |
|
589 |
int8_t SnrPkt; //!< The SNR of the last packet |
|
590 |
int8_t SignalRssiPkt; |
|
591 |
uint32_t FreqError; |
|
592 |
}LoRa; |
|
593 |
}Params; |
|
594 |
}PacketStatus_t; |
|
595 |
|
|
596 |
/*! |
|
597 |
* \brief Represents the Rx internal counters values when GFSK or LoRa packet type is used |
|
598 |
*/ |
|
599 |
typedef struct |
|
600 |
{ |
|
601 |
RadioPacketTypes_t packetType; //!< Packet to which the packet status are referring to. |
|
602 |
uint16_t PacketReceived; |
|
603 |
uint16_t CrcOk; |
|
604 |
uint16_t LengthError; |
|
605 |
}RxCounter_t; |
|
606 |
|
|
607 |
/*! |
|
608 |
* \brief Represents a calibration configuration |
|
609 |
*/ |
|
610 |
typedef union |
|
611 |
{ |
|
612 |
struct |
|
613 |
{ |
|
614 |
uint8_t RC64KEnable : 1; //!< Calibrate RC64K clock |
|
615 |
uint8_t RC13MEnable : 1; //!< Calibrate RC13M clock |
|
616 |
uint8_t PLLEnable : 1; //!< Calibrate PLL |
|
617 |
uint8_t ADCPulseEnable : 1; //!< Calibrate ADC Pulse |
|
618 |
uint8_t ADCBulkNEnable : 1; //!< Calibrate ADC bulkN |
|
619 |
uint8_t ADCBulkPEnable : 1; //!< Calibrate ADC bulkP |
|
620 |
uint8_t ImgEnable : 1; |
|
621 |
uint8_t : 1; |
|
622 |
}Fields; |
|
623 |
uint8_t Value; |
|
624 |
}CalibrationParams_t; |
|
625 |
|
|
626 |
/*! |
|
627 |
* \brief Represents a sleep mode configuration |
|
628 |
*/ |
|
629 |
typedef union |
|
630 |
{ |
|
631 |
struct |
|
632 |
{ |
|
633 |
uint8_t WakeUpRTC : 1; //!< Get out of sleep mode if wakeup signal received from RTC |
|
634 |
uint8_t Reset : 1; |
|
635 |
uint8_t WarmStart : 1; |
|
636 |
uint8_t Reserved : 5; |
|
637 |
}Fields; |
|
638 |
uint8_t Value; |
|
639 |
}SleepParams_t; |
|
640 |
|
|
641 |
/*! |
|
642 |
* \brief Represents the possible radio system error states |
|
643 |
*/ |
|
644 |
typedef union |
|
645 |
{ |
|
646 |
struct |
|
647 |
{ |
|
648 |
uint8_t Rc64kCalib : 1; //!< RC 64kHz oscillator calibration failed |
|
649 |
uint8_t Rc13mCalib : 1; //!< RC 13MHz oscillator calibration failed |
|
650 |
uint8_t PllCalib : 1; //!< PLL calibration failed |
|
651 |
uint8_t AdcCalib : 1; //!< ADC calibration failed |
|
652 |
uint8_t ImgCalib : 1; //!< Image calibration failed |
|
653 |
uint8_t XoscStart : 1; //!< XOSC oscillator failed to start |
|
654 |
uint8_t PllLock : 1; //!< PLL lock failed |
|
655 |
uint8_t BuckStart : 1; //!< Buck converter failed to start |
|
656 |
uint8_t PaRamp : 1; //!< PA ramp failed |
|
657 |
uint8_t : 7; //!< Reserved |
|
658 |
}Fields; |
|
659 |
uint16_t Value; |
|
660 |
}RadioError_t; |
|
661 |
|
|
662 |
/*! |
|
663 |
* Radio hardware and global parameters |
|
664 |
*/ |
|
665 |
typedef struct SX126x_s |
|
666 |
{ |
|
667 |
// Gpio_t Reset; |
|
668 |
// Gpio_t BUSY; |
|
669 |
// Gpio_t DIO1; |
|
670 |
// Gpio_t DIO2; |
|
671 |
// Gpio_t DIO3; |
|
672 |
// Spi_t Spi; |
|
673 |
PacketParams_t PacketParams; |
|
674 |
PacketStatus_t PacketStatus; |
|
675 |
ModulationParams_t ModulationParams; |
|
676 |
}SX126x_t; |
|
677 |
|
|
678 |
/*! |
|
679 |
* Hardware IO IRQ callback function definition |
|
680 |
*/ |
|
681 |
typedef void ( DioIrqHandler )( void ); |
|
682 |
|
|
683 |
/*! |
|
684 |
* SX126x definitions |
|
685 |
*/ |
|
686 |
|
|
687 |
/*! |
|
688 |
* \brief Provides the frequency of the chip running on the radio and the frequency step |
|
689 |
* |
|
690 |
* \remark These defines are used for computing the frequency divider to set the RF frequency |
|
691 |
*/ |
|
692 |
#define XTAL_FREQ ( double )32000000 |
|
693 |
#define FREQ_DIV ( double )pow( 2.0, 25.0 ) |
|
694 |
#define FREQ_STEP ( double )( XTAL_FREQ / FREQ_DIV ) |
|
695 |
|
|
696 |
#define RX_BUFFER_SIZE 256 |
|
697 |
|
|
698 |
/*! |
|
699 |
* \brief The radio callbacks structure |
|
700 |
* Holds function pointers to be called on radio interrupts |
|
701 |
*/ |
|
702 |
typedef struct |
|
703 |
{ |
|
704 |
void ( *txDone )( void ); //!< Pointer to a function run on successful transmission |
|
705 |
void ( *rxDone )( void ); //!< Pointer to a function run on successful reception |
|
706 |
void ( *rxPreambleDetect )( void ); //!< Pointer to a function run on successful Preamble detection |
|
707 |
void ( *rxSyncWordDone )( void ); //!< Pointer to a function run on successful SyncWord reception |
|
708 |
void ( *rxHeaderDone )( bool isOk ); //!< Pointer to a function run on successful Header reception |
|
709 |
void ( *txTimeout )( void ); //!< Pointer to a function run on transmission timeout |
|
710 |
void ( *rxTimeout )( void ); //!< Pointer to a function run on reception timeout |
|
711 |
void ( *rxError )( IrqErrorCode_t errCode ); //!< Pointer to a function run on reception error |
|
712 |
void ( *cadDone )( bool cadFlag ); //!< Pointer to a function run on channel activity detected |
|
713 |
}SX126xCallbacks_t; |
|
714 |
|
|
715 |
/*! |
|
716 |
* ============================================================================ |
|
717 |
* Public functions prototypes |
|
718 |
* ============================================================================ |
|
719 |
*/ |
|
720 |
|
|
721 |
/*! |
|
722 |
* \brief Initializes the radio driver |
|
723 |
*/ |
|
724 |
void SX126xInit( DioIrqHandler dioIrq ); |
|
725 |
|
|
726 |
/*! |
|
727 |
* \brief Gets the current Operation Mode of the Radio |
|
728 |
* |
|
729 |
* \retval RadioOperatingModes_t last operating mode |
|
730 |
*/ |
|
731 |
RadioOperatingModes_t SX126xGetOperatingMode( void ); |
|
732 |
|
|
733 |
/*! |
|
734 |
* \brief Wakeup the radio if it is in Sleep mode and check that Busy is low |
|
735 |
*/ |
|
736 |
void SX126xCheckDeviceReady( void ); |
|
737 |
|
|
738 |
/*! |
|
739 |
* \brief Saves the payload to be send in the radio buffer |
|
740 |
* |
|
741 |
* \param [in] payload A pointer to the payload |
|
742 |
* \param [in] size The size of the payload |
|
743 |
*/ |
|
744 |
void SX126xSetPayload( uint8_t *payload, uint8_t size ); |
|
745 |
|
|
746 |
/*! |
|
747 |
* \brief Reads the payload received. If the received payload is longer |
|
748 |
* than maxSize, then the method returns 1 and do not set size and payload. |
|
749 |
* |
|
750 |
* \param [out] payload A pointer to a buffer into which the payload will be copied |
|
751 |
* \param [out] size A pointer to the size of the payload received |
|
752 |
* \param [in] maxSize The maximal size allowed to copy into the buffer |
|
753 |
*/ |
|
754 |
uint8_t SX126xGetPayload( uint8_t *payload, uint8_t *size, uint8_t maxSize ); |
|
755 |
|
|
756 |
/*! |
|
757 |
* \brief Sends a payload |
|
758 |
* |
|
759 |
* \param [in] payload A pointer to the payload to send |
|
760 |
* \param [in] size The size of the payload to send |
|
761 |
* \param [in] timeout The timeout for Tx operation |
|
762 |
*/ |
|
763 |
void SX126xSendPayload( uint8_t *payload, uint8_t size, uint32_t timeout ); |
|
764 |
|
|
765 |
/*! |
|
766 |
* \brief Sets the Sync Word given by index used in GFSK |
|
767 |
* |
|
768 |
* \param [in] syncWord SyncWord bytes ( 8 bytes ) |
|
769 |
* |
|
770 |
* \retval status [0: OK, 1: NOK] |
|
771 |
*/ |
|
772 |
uint8_t SX126xSetSyncWord( uint8_t *syncWord ); |
|
773 |
|
|
774 |
/*! |
|
775 |
* \brief Sets the Initial value for the LFSR used for the CRC calculation |
|
776 |
* |
|
777 |
* \param [in] seed Initial LFSR value ( 2 bytes ) |
|
778 |
* |
|
779 |
*/ |
|
780 |
void SX126xSetCrcSeed( uint16_t seed ); |
|
781 |
|
|
782 |
/*! |
|
783 |
* \brief Sets the seed used for the CRC calculation |
|
784 |
* |
|
785 |
* \param [in] seed The seed value |
|
786 |
* |
|
787 |
*/ |
|
788 |
void SX126xSetCrcPolynomial( uint16_t polynomial ); |
|
789 |
|
|
790 |
/*! |
|
791 |
* \brief Sets the Initial value of the LFSR used for the whitening in GFSK protocols |
|
792 |
* |
|
793 |
* \param [in] seed Initial LFSR value |
|
794 |
*/ |
|
795 |
void SX126xSetWhiteningSeed( uint16_t seed ); |
|
796 |
|
|
797 |
/*! |
|
798 |
* \brief Gets a 32 bits random value generated by the radio |
|
799 |
* |
|
800 |
* \remark The radio must be in reception mode before executing this function |
|
801 |
* |
|
802 |
* \retval randomValue 32 bits random value |
|
803 |
*/ |
|
804 |
uint32_t SX126xGetRandom( void ); |
|
805 |
|
|
806 |
/*! |
|
807 |
* \brief Sets the radio in sleep mode |
|
808 |
* |
|
809 |
* \param [in] sleepConfig The sleep configuration describing data |
|
810 |
* retention and RTC wake-up |
|
811 |
*/ |
|
812 |
void SX126xSetSleep( SleepParams_t sleepConfig ); |
|
813 |
|
|
814 |
/*! |
|
815 |
* \brief Sets the radio in configuration mode |
|
816 |
* |
|
817 |
* \param [in] mode The standby mode to put the radio into |
|
818 |
*/ |
|
819 |
void SX126xSetStandby( RadioStandbyModes_t mode ); |
|
820 |
|
|
821 |
/*! |
|
822 |
* \brief Sets the radio in FS mode |
|
823 |
*/ |
|
824 |
void SX126xSetFs( void ); |
|
825 |
|
|
826 |
/*! |
|
827 |
* \brief Sets the radio in transmission mode |
|
828 |
* |
|
829 |
* \param [in] timeout Structure describing the transmission timeout value |
|
830 |
*/ |
|
831 |
void SX126xSetTx( uint32_t timeout ); |
|
832 |
|
|
833 |
/*! |
|
834 |
* \brief Sets the radio in reception mode |
|
835 |
* |
|
836 |
* \param [in] timeout Structure describing the reception timeout value |
|
837 |
*/ |
|
838 |
void SX126xSetRx( uint32_t timeout ); |
|
839 |
|
|
840 |
/*! |
|
841 |
* \brief Sets the radio in reception mode with Boosted LNA gain |
|
842 |
* |
|
843 |
* \param [in] timeout Structure describing the reception timeout value |
|
844 |
*/ |
|
845 |
void SX126xSetRxBoosted( uint32_t timeout ); |
|
846 |
|
|
847 |
/*! |
|
848 |
* \brief Sets the Rx duty cycle management parameters |
|
849 |
* |
|
850 |
* \param [in] rxTime Structure describing reception timeout value |
|
851 |
* \param [in] sleepTime Structure describing sleep timeout value |
|
852 |
*/ |
|
853 |
void SX126xSetRxDutyCycle( uint32_t rxTime, uint32_t sleepTime ); |
|
854 |
|
|
855 |
/*! |
|
856 |
* \brief Sets the radio in CAD mode |
|
857 |
*/ |
|
858 |
void SX126xSetCad( void ); |
|
859 |
|
|
860 |
/*! |
|
861 |
* \brief Sets the radio in continuous wave transmission mode |
|
862 |
*/ |
|
863 |
void SX126xSetTxContinuousWave( void ); |
|
864 |
|
|
865 |
/*! |
|
866 |
* \brief Sets the radio in continuous preamble transmission mode |
|
867 |
*/ |
|
868 |
void SX126xSetTxInfinitePreamble( void ); |
|
869 |
|
|
870 |
/*! |
|
871 |
* \brief Decide which interrupt will stop the internal radio rx timer. |
|
872 |
* |
|
873 |
* \param [in] enable [0: Timer stop after header/syncword detection |
|
874 |
* 1: Timer stop after preamble detection] |
|
875 |
*/ |
|
876 |
void SX126xSetStopRxTimerOnPreambleDetect( bool enable ); |
|
877 |
|
|
878 |
/*! |
|
879 |
* \brief Set the number of symbol the radio will wait to validate a reception |
|
880 |
* |
|
881 |
* \param [in] SymbNum number of LoRa symbols |
|
882 |
*/ |
|
883 |
void SX126xSetLoRaSymbNumTimeout( uint8_t SymbNum ); |
|
884 |
|
|
885 |
/*! |
|
886 |
* \brief Sets the power regulators operating mode |
|
887 |
* |
|
888 |
* \param [in] mode [0: LDO, 1:DC_DC] |
|
889 |
*/ |
|
890 |
void SX126xSetRegulatorMode( RadioRegulatorMode_t mode ); |
|
891 |
|
|
892 |
/*! |
|
893 |
* \brief Calibrates the given radio block |
|
894 |
* |
|
895 |
* \param [in] calibParam The description of blocks to be calibrated |
|
896 |
*/ |
|
897 |
void SX126xCalibrate( CalibrationParams_t calibParam ); |
|
898 |
|
|
899 |
/*! |
|
900 |
* \brief Calibrates the Image rejection depending of the frequency |
|
901 |
* |
|
902 |
* \param [in] freq The operating frequency |
|
903 |
*/ |
|
904 |
void SX126xCalibrateImage( uint32_t freq ); |
|
905 |
|
|
906 |
/*! |
|
907 |
* \brief Activate the extention of the timeout when long preamble is used |
|
908 |
* |
|
909 |
* \param [in] enable The radio will extend the timeout to cope with long preamble |
|
910 |
*/ |
|
911 |
void SX126xSetLongPreamble( uint8_t enable ); |
|
912 |
|
|
913 |
/*! |
|
914 |
* \brief Sets the transmission parameters |
|
915 |
* |
|
916 |
* \param [in] paDutyCycle Duty Cycle for the PA |
|
917 |
* \param [in] hpMax 0 for sx1261, 7 for sx1262 |
|
918 |
* \param [in] deviceSel 1 for sx1261, 0 for sx1262 |
|
919 |
* \param [in] paLut 0 for 14dBm LUT, 1 for 22dBm LUT |
|
920 |
*/ |
|
921 |
void SX126xSetPaConfig( uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel, uint8_t paLut ); |
|
922 |
|
|
923 |
/*! |
|
924 |
* \brief Defines into which mode the chip goes after a TX / RX done |
|
925 |
* |
|
926 |
* \param [in] fallbackMode The mode in which the radio goes |
|
927 |
*/ |
|
928 |
void SX126xSetRxTxFallbackMode( uint8_t fallbackMode ); |
|
929 |
|
|
930 |
/*! |
|
931 |
* \brief Write data to the radio memory |
|
932 |
* |
|
933 |
* \param [in] address The address of the first byte to write in the radio |
|
934 |
* \param [in] buffer The data to be written in radio's memory |
|
935 |
* \param [in] size The number of bytes to write in radio's memory |
|
936 |
*/ |
|
937 |
void SX126xWriteRegisters( uint16_t address, uint8_t *buffer, uint16_t size ); |
|
938 |
|
|
939 |
/*! |
|
940 |
* \brief Read data from the radio memory |
|
941 |
* |
|
942 |
* \param [in] address The address of the first byte to read from the radio |
|
943 |
* \param [out] buffer The buffer that holds data read from radio |
|
944 |
* \param [in] size The number of bytes to read from radio's memory |
|
945 |
*/ |
|
946 |
void SX126xReadRegisters( uint16_t address, uint8_t *buffer, uint16_t size ); |
|
947 |
|
|
948 |
/*! |
|
949 |
* \brief Write data to the buffer holding the payload in the radio |
|
950 |
* |
|
951 |
* \param [in] offset The offset to start writing the payload |
|
952 |
* \param [in] buffer The data to be written (the payload) |
|
953 |
* \param [in] size The number of byte to be written |
|
954 |
*/ |
|
955 |
void SX126xWriteBuffer( uint8_t offset, uint8_t *buffer, uint8_t size ); |
|
956 |
|
|
957 |
/*! |
|
958 |
* \brief Read data from the buffer holding the payload in the radio |
|
959 |
* |
|
960 |
* \param [in] offset The offset to start reading the payload |
|
961 |
* \param [out] buffer A pointer to a buffer holding the data from the radio |
|
962 |
* \param [in] size The number of byte to be read |
|
963 |
*/ |
|
964 |
void SX126xReadBuffer( uint8_t offset, uint8_t *buffer, uint8_t size ); |
|
965 |
|
|
966 |
/*! |
|
967 |
* \brief Sets the IRQ mask and DIO masks |
|
968 |
* |
|
969 |
* \param [in] irqMask General IRQ mask |
|
970 |
* \param [in] dio1Mask DIO1 mask |
|
971 |
* \param [in] dio2Mask DIO2 mask |
|
972 |
* \param [in] dio3Mask DIO3 mask |
|
973 |
*/ |
|
974 |
void SX126xSetDioIrqParams( uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask, uint16_t dio3Mask ); |
|
975 |
|
|
976 |
/*! |
|
977 |
* \brief Returns the current IRQ status |
|
978 |
* |
|
979 |
* \retval irqStatus IRQ status |
|
980 |
*/ |
|
981 |
uint16_t SX126xGetIrqStatus( void ); |
|
982 |
|
|
983 |
/*! |
|
984 |
* \brief Indicates if DIO2 is used to control an RF Switch |
|
985 |
* |
|
986 |
* \param [in] enable true of false |
|
987 |
*/ |
|
988 |
void SX126xSetDio2AsRfSwitchCtrl( uint8_t enable ); |
|
989 |
|
|
990 |
/*! |
|
991 |
* \brief Indicates if the Radio main clock is supplied from a tcxo |
|
992 |
* |
|
993 |
* \param [in] tcxoVoltage voltage used to control the TCXO |
|
994 |
* \param [in] timeout time given to the TCXO to go to 32MHz |
|
995 |
*/ |
|
996 |
void SX126xSetDio3AsTcxoCtrl( RadioTcxoCtrlVoltage_t tcxoVoltage, uint32_t timeout ); |
|
997 |
|
|
998 |
/*! |
|
999 |
* \brief Sets the RF frequency |
|
1000 |
* |
|
1001 |
* \param [in] frequency RF frequency [Hz] |
|
1002 |
*/ |
|
1003 |
void SX126xSetRfFrequency( uint32_t frequency ); |
|
1004 |
|
|
1005 |
/*! |
|
1006 |
* \brief Sets the radio for the given protocol |
|
1007 |
* |
|
1008 |
* \param [in] packetType [PACKET_TYPE_GFSK, PACKET_TYPE_LORA] |
|
1009 |
* |
|
1010 |
* \remark This method has to be called before SetRfFrequency, |
|
1011 |
* SetModulationParams and SetPacketParams |
|
1012 |
*/ |
|
1013 |
void SX126xSetPacketType( RadioPacketTypes_t packetType ); |
|
1014 |
|
|
1015 |
/*! |
|
1016 |
* \brief Gets the current radio protocol |
|
1017 |
* |
|
1018 |
* \retval packetType [PACKET_TYPE_GFSK, PACKET_TYPE_LORA] |
|
1019 |
*/ |
|
1020 |
RadioPacketTypes_t SX126xGetPacketType( void ); |
|
1021 |
|
|
1022 |
/*! |
|
1023 |
* \brief Sets the transmission parameters |
|
1024 |
* |
|
1025 |
* \param [in] power RF output power [-18..13] dBm |
|
1026 |
* \param [in] rampTime Transmission ramp up time |
|
1027 |
*/ |
|
1028 |
void SX126xSetTxParams( int8_t power, RadioRampTimes_t rampTime ); |
|
1029 |
|
|
1030 |
/*! |
|
1031 |
* \brief Set the modulation parameters |
|
1032 |
* |
|
1033 |
* \param [in] modParams A structure describing the modulation parameters |
|
1034 |
*/ |
|
1035 |
void SX126xSetModulationParams( ModulationParams_t *modParams ); |
|
1036 |
|
|
1037 |
/*! |
|
1038 |
* \brief Sets the packet parameters |
|
1039 |
* |
|
1040 |
* \param [in] packetParams A structure describing the packet parameters |
|
1041 |
*/ |
|
1042 |
void SX126xSetPacketParams( PacketParams_t *packetParams ); |
|
1043 |
|
|
1044 |
/*! |
|
1045 |
* \brief Sets the Channel Activity Detection (CAD) parameters |
|
1046 |
* |
|
1047 |
* \param [in] cadSymbolNum The number of symbol to use for CAD operations |
|
1048 |
* [LORA_CAD_01_SYMBOL, LORA_CAD_02_SYMBOL, |
|
1049 |
* LORA_CAD_04_SYMBOL, LORA_CAD_08_SYMBOL, |
|
1050 |
* LORA_CAD_16_SYMBOL] |
|
1051 |
* \param [in] cadDetPeak Limit for detection of SNR peak used in the CAD |
|
1052 |
* \param [in] cadDetMin Set the minimum symbol recognition for CAD |
|
1053 |
* \param [in] cadExitMode Operation to be done at the end of CAD action |
|
1054 |
* [LORA_CAD_ONLY, LORA_CAD_RX, LORA_CAD_LBT] |
|
1055 |
* \param [in] cadTimeout Defines the timeout value to abort the CAD activity |
|
1056 |
*/ |
|
1057 |
void SX126xSetCadParams( RadioLoRaCadSymbols_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, RadioCadExitModes_t cadExitMode, uint32_t cadTimeout ); |
|
1058 |
|
|
1059 |
/*! |
|
1060 |
* \brief Sets the data buffer base address for transmission and reception |
|
1061 |
* |
|
1062 |
* \param [in] txBaseAddress Transmission base address |
|
1063 |
* \param [in] rxBaseAddress Reception base address |
|
1064 |
*/ |
|
1065 |
void SX126xSetBufferBaseAddress( uint8_t txBaseAddress, uint8_t rxBaseAddress ); |
|
1066 |
|
|
1067 |
/*! |
|
1068 |
* \brief Gets the current radio status |
|
1069 |
* |
|
1070 |
* \retval status Radio status |
|
1071 |
*/ |
|
1072 |
RadioStatus_t SX126xGetStatus( void ); |
|
1073 |
|
|
1074 |
/*! |
|
1075 |
* \brief Returns the instantaneous RSSI value for the last packet received |
|
1076 |
* |
|
1077 |
* \retval rssiInst Instantaneous RSSI |
|
1078 |
*/ |
|
1079 |
int8_t SX126xGetRssiInst( void ); |
|
1080 |
|
|
1081 |
/*! |
|
1082 |
* \brief Gets the last received packet buffer status |
|
1083 |
* |
|
1084 |
* \param [out] payloadLength Last received packet payload length |
|
1085 |
* \param [out] rxStartBuffer Last received packet buffer address pointer |
|
1086 |
*/ |
|
1087 |
void SX126xGetRxBufferStatus( uint8_t *payloadLength, uint8_t *rxStartBuffer ); |
|
1088 |
|
|
1089 |
/*! |
|
1090 |
* \brief Gets the last received packet payload length |
|
1091 |
* |
|
1092 |
* \param [out] pktStatus A structure of packet status |
|
1093 |
*/ |
|
1094 |
void SX126xGetPacketStatus( PacketStatus_t *pktStatus ); |
|
1095 |
|
|
1096 |
/*! |
|
1097 |
* \brief Returns the possible system errors |
|
1098 |
* |
|
1099 |
* \retval sysErrors Value representing the possible sys failures |
|
1100 |
*/ |
|
1101 |
RadioError_t SX126xGetDeviceErrors( void ); |
|
1102 |
|
|
1103 |
/*! |
|
1104 |
* \brief Clear all the errors in the device |
|
1105 |
*/ |
|
1106 |
void SX126xClearDeviceErrors( void ); |
|
1107 |
|
|
1108 |
/*! |
|
1109 |
* \brief Clears the IRQs |
|
1110 |
* |
|
1111 |
* \param [in] irq IRQ(s) to be cleared |
|
1112 |
*/ |
|
1113 |
void SX126xClearIrqStatus( uint16_t irq ); |
|
1114 |
|
|
1115 |
#endif // __SX126x_H__ |