SingingCat 0
application
sx126x.h
Go to the documentation of this file.
1
32#ifndef SX126X_H
33#define SX126X_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*
40 * -----------------------------------------------------------------------------
41 * --- DEPENDENCIES ------------------------------------------------------------
42 */
43
44#include <stdint.h>
45#include <stdbool.h>
46#include "networkif.h"
47/*
48 * -----------------------------------------------------------------------------
49 * --- PUBLIC MACROS -----------------------------------------------------------
50 */
51
52/*
53 * -----------------------------------------------------------------------------
54 * --- PUBLIC CONSTANTS --------------------------------------------------------
55 */
56
61#define SX126X_MAX_TIMEOUT_IN_RTC_STEP 0x00FFFFFE
62
66#define SX126X_MAX_TIMEOUT_IN_MS (SX126X_MAX_TIMEOUT_IN_RTC_STEP / 64)
67
72#define SX126X_RX_SINGLE_MODE 0x00000000
73
77#define SX126X_RX_CONTINUOUS 0x00FFFFFF
78
79#define SX126X_CHIP_MODES_POS (4U)
80#define SX126X_CHIP_MODES_MASK (0x07UL << SX126X_CHIP_MODES_POS)
81
82#define SX126X_CMD_STATUS_POS (1U)
83#define SX126X_CMD_STATUS_MASK (0x07UL << SX126X_CMD_STATUS_POS)
84
85#define SX126X_GFSK_RX_STATUS_PKT_SENT_POS (0U)
86#define SX126X_GFSK_RX_STATUS_PKT_SENT_MASK (0x01UL << SX126X_GFSK_RX_STATUS_PKT_SENT_POS)
87
88#define SX126X_GFSK_RX_STATUS_PKT_RECEIVED_POS (1U)
89#define SX126X_GFSK_RX_STATUS_PKT_RECEIVED_MASK (0x01UL << SX126X_GFSK_RX_STATUS_PKT_RECEIVED_POS)
90
91#define SX126X_GFSK_RX_STATUS_ABORT_ERROR_POS (2U)
92#define SX126X_GFSK_RX_STATUS_ABORT_ERROR_MASK (0x01UL << SX126X_GFSK_RX_STATUS_ABORT_ERROR_POS)
93
94#define SX126X_GFSK_RX_STATUS_LENGTH_ERROR_POS (3U)
95#define SX126X_GFSK_RX_STATUS_LENGTH_ERROR_MASK (0x01UL << SX126X_GFSK_RX_STATUS_LENGTH_ERROR_POS)
96
97#define SX126X_GFSK_RX_STATUS_CRC_ERROR_POS (4U)
98#define SX126X_GFSK_RX_STATUS_CRC_ERROR_MASK (0x01UL << SX126X_GFSK_RX_STATUS_CRC_ERROR_POS)
99
100#define SX126X_GFSK_RX_STATUS_ADRS_ERROR_POS (5U)
101#define SX126X_GFSK_RX_STATUS_ADRS_ERROR_MASK (0x01UL << SX126X_GFSK_RX_STATUS_ADRS_ERROR_POS)
102
103/*
104 * -----------------------------------------------------------------------------
105 * --- PUBLIC TYPES ------------------------------------------------------------
106 */
107
111typedef enum sx126x_status_e {
112 SX126X_STATUS_OK = 0,
113 SX126X_STATUS_UNSUPPORTED_FEATURE,
114 SX126X_STATUS_UNKNOWN_VALUE,
115 SX126X_STATUS_ERROR,
117
122 SX126X_SLEEP_CFG_COLD_START = (0 << 2),
123 SX126X_SLEEP_CFG_WARM_START = (1 << 2),
125
130 SX126X_STANDBY_CFG_RC = 0x00,
131 SX126X_STANDBY_CFG_XOSC = 0x01,
133
134typedef uint8_t sx126x_standby_cfg_t;
135
139typedef enum sx126x_reg_mods_e {
140 SX126X_REG_MODE_LDO = 0x00, // default
141 SX126X_REG_MODE_DCDC = 0x01,
143
148 uint8_t pa_duty_cycle;
149 uint8_t hp_max;
150 uint8_t device_sel;
151 uint8_t pa_lut;
153
158 SX126X_FALLBACK_STDBY_RC = 0x20,
159 SX126X_FALLBACK_STDBY_XOSC = 0x30,
160 SX126X_FALLBACK_FS = 0x40,
162
167 SX126X_IRQ_NONE = (0 << 0),
168 SX126X_IRQ_TX_DONE = (1 << 0),
169 SX126X_IRQ_RX_DONE = (1 << 1),
170 SX126X_IRQ_PREAMBLE_DETECTED = (1 << 2),
171 SX126X_IRQ_SYNC_WORD_VALID = (1 << 3),
172 SX126X_IRQ_HEADER_VALID = (1 << 4),
173 SX126X_IRQ_HEADER_ERROR = (1 << 5),
174 SX126X_IRQ_CRC_ERROR = (1 << 6),
175 SX126X_IRQ_CAD_DONE = (1 << 7),
176 SX126X_IRQ_CAD_DETECTED = (1 << 8),
177 SX126X_IRQ_TIMEOUT = (1 << 9),
178 SX126X_IRQ_ALL = SX126X_IRQ_TX_DONE | SX126X_IRQ_RX_DONE | SX126X_IRQ_PREAMBLE_DETECTED |
179 SX126X_IRQ_SYNC_WORD_VALID | SX126X_IRQ_HEADER_VALID | SX126X_IRQ_HEADER_ERROR |
180 SX126X_IRQ_CRC_ERROR | SX126X_IRQ_CAD_DONE | SX126X_IRQ_CAD_DETECTED | SX126X_IRQ_TIMEOUT,
181};
182
183typedef uint16_t sx126x_irq_mask_t;
184
189 SX126X_CAL_RC64K = (1 << 0),
190 SX126X_CAL_RC13M = (1 << 1),
191 SX126X_CAL_PLL = (1 << 2),
192 SX126X_CAL_ADC_PULSE = (1 << 3),
193 SX126X_CAL_ADC_BULK_N = (1 << 4),
194 SX126X_CAL_ADC_BULK_P = (1 << 5),
195 SX126X_CAL_IMAGE = (1 << 6),
196 SX126X_CAL_ALL = SX126X_CAL_RC64K | SX126X_CAL_RC13M | SX126X_CAL_PLL | SX126X_CAL_ADC_PULSE |
197 SX126X_CAL_ADC_BULK_N | SX126X_CAL_ADC_BULK_P | SX126X_CAL_IMAGE,
198};
199
200typedef uint8_t sx126x_cal_mask_t;
201
206 SX126X_TCXO_CTRL_1_6V = 0x00,
207 SX126X_TCXO_CTRL_1_7V = 0x01,
208 SX126X_TCXO_CTRL_1_8V = 0x02,
209 SX126X_TCXO_CTRL_2_2V = 0x03,
210 SX126X_TCXO_CTRL_2_4V = 0x04,
211 SX126X_TCXO_CTRL_2_7V = 0x05,
212 SX126X_TCXO_CTRL_3_0V = 0x06,
213 SX126X_TCXO_CTRL_3_3V = 0x07,
215
219typedef enum sx126x_pkt_types_e {
220 SX126X_PKT_TYPE_GFSK = 0x00,
221 SX126X_PKT_TYPE_LORA = 0x01,
223
227typedef enum sx126x_ramp_time_e {
228 SX126X_RAMP_10_US = 0x00,
229 SX126X_RAMP_20_US = 0x01,
230 SX126X_RAMP_40_US = 0x02,
231 SX126X_RAMP_80_US = 0x03,
232 SX126X_RAMP_200_US = 0x04,
233 SX126X_RAMP_800_US = 0x05,
234 SX126X_RAMP_1700_US = 0x06,
235 SX126X_RAMP_3400_US = 0x07,
237
242 SX126X_GFSK_PULSE_SHAPE_OFF = 0x00,
243 SX126X_GFSK_PULSE_SHAPE_BT_03 = 0x08,
244 SX126X_GFSK_PULSE_SHAPE_BT_05 = 0x09,
245 SX126X_GFSK_PULSE_SHAPE_BT_07 = 0x0A,
246 SX126X_GFSK_PULSE_SHAPE_BT_1 = 0x0B,
248
252typedef enum sx126x_gfsk_bw_e {
253 SX126X_GFSK_BW_4800 = 0x1F,
254 SX126X_GFSK_BW_5800 = 0x17,
255 SX126X_GFSK_BW_7300 = 0x0F,
256 SX126X_GFSK_BW_9700 = 0x1E,
257 SX126X_GFSK_BW_11700 = 0x16,
258 SX126X_GFSK_BW_14600 = 0x0E,
259 SX126X_GFSK_BW_19500 = 0x1D,
260 SX126X_GFSK_BW_23400 = 0x15,
261 SX126X_GFSK_BW_29300 = 0x0D,
262 SX126X_GFSK_BW_39000 = 0x1C,
263 SX126X_GFSK_BW_46900 = 0x14,
264 SX126X_GFSK_BW_58600 = 0x0C,
265 SX126X_GFSK_BW_78200 = 0x1B,
266 SX126X_GFSK_BW_93800 = 0x13,
267 SX126X_GFSK_BW_117300 = 0x0B,
268 SX126X_GFSK_BW_156200 = 0x1A,
269 SX126X_GFSK_BW_187200 = 0x12,
270 SX126X_GFSK_BW_234300 = 0x0A,
271 SX126X_GFSK_BW_312000 = 0x19,
272 SX126X_GFSK_BW_373600 = 0x11,
273 SX126X_GFSK_BW_467000 = 0x09,
275
280 uint32_t br_in_bps;
281 uint32_t fdev_in_hz;
282 sx126x_gfsk_pulse_shape_t pulse_shape;
283 sx126x_gfsk_bw_t bw_dsb_param;
285
289typedef enum sx126x_lora_sf_e {
290 SX126X_LORA_SF5 = 0x05,
291 SX126X_LORA_SF6 = 0x06,
292 SX126X_LORA_SF7 = 0x07,
293 SX126X_LORA_SF8 = 0x08,
294 SX126X_LORA_SF9 = 0x09,
295 SX126X_LORA_SF10 = 0x0A,
296 SX126X_LORA_SF11 = 0x0B,
297 SX126X_LORA_SF12 = 0x0C,
299
303typedef enum sx126x_lora_bw_e {
304 SX126X_LORA_BW_500 = 6,
305 SX126X_LORA_BW_250 = 5,
306 SX126X_LORA_BW_125 = 4,
307 SX126X_LORA_BW_062 = 3,
308 SX126X_LORA_BW_041 = 10,
309 SX126X_LORA_BW_031 = 2,
310 SX126X_LORA_BW_020 = 9,
311 SX126X_LORA_BW_015 = 1,
312 SX126X_LORA_BW_010 = 8,
313 SX126X_LORA_BW_007 = 0,
315
319typedef enum sx126x_lora_cr_e {
320 SX126X_LORA_CR_4_5 = 0x01,
321 SX126X_LORA_CR_4_6 = 0x02,
322 SX126X_LORA_CR_4_7 = 0x03,
323 SX126X_LORA_CR_4_8 = 0x04,
325
333 uint8_t ldro;
335
340 SX126X_GFSK_PREAMBLE_DETECTOR_OFF = 0x00,
341 SX126X_GFSK_PREAMBLE_DETECTOR_MIN_8BITS = 0x04,
342 SX126X_GFSK_PREAMBLE_DETECTOR_MIN_16BITS = 0x05,
343 SX126X_GFSK_PREAMBLE_DETECTOR_MIN_24BITS = 0x06,
344 SX126X_GFSK_PREAMBLE_DETECTOR_MIN_32BITS = 0x07,
346
351 SX126X_GFSK_ADDRESS_FILTERING_DISABLE = 0x00,
352 SX126X_GFSK_ADDRESS_FILTERING_NODE_ADDRESS = 0x01,
353 SX126X_GFSK_ADDRESS_FILTERING_NODE_AND_BROADCAST_ADDRESSES = 0x02,
355
363
368 SX126X_GFSK_CRC_OFF = 0x01,
369 SX126X_GFSK_CRC_1_BYTE = 0x00,
370 SX126X_GFSK_CRC_2_BYTES = 0x02,
371 SX126X_GFSK_CRC_1_BYTE_INV = 0x04,
372 SX126X_GFSK_CRC_2_BYTES_INV = 0x06,
374
379 SX126X_GFSK_DC_FREE_OFF = 0x00,
380 SX126X_GFSK_DC_FREE_WHITENING = 0x01,
382
390
401
415
421typedef enum sx126x_cad_symbs_e {
422 SX126X_CAD_01_SYMB = 0x00,
423 SX126X_CAD_02_SYMB = 0x01,
424 SX126X_CAD_04_SYMB = 0x02,
425 SX126X_CAD_08_SYMB = 0x03,
426 SX126X_CAD_16_SYMB = 0x04,
428
435 SX126X_CAD_ONLY = 0x00,
436 SX126X_CAD_RX = 0x01,
437 SX126X_CAD_LBT = 0x10,
439
443typedef struct sx126x_cad_param_s {
448 uint32_t cad_timeout;
450
455 SX126X_CHIP_MODE_UNUSED = 0,
456 SX126X_CHIP_MODE_RFU = 1,
457 SX126X_CHIP_MODE_STBY_RC = 2,
458 SX126X_CHIP_MODE_STBY_XOSC = 3,
459 SX126X_CHIP_MODE_FS = 4,
460 SX126X_CHIP_MODE_RX = 5,
461 SX126X_CHIP_MODE_TX = 6,
463
468 SX126X_CMD_STATUS_RESERVED = 0,
469 SX126X_CMD_STATUS_RFU = 1,
470 SX126X_CMD_STATUS_DATA_AVAILABLE = 2,
471 SX126X_CMD_STATUS_CMD_TIMEOUT = 3,
472 SX126X_CMD_STATUS_CMD_PROCESS_ERROR = 4,
473 SX126X_CMD_STATUS_CMD_EXEC_FAILURE = 5,
474 SX126X_CMD_STATUS_CMD_TX_DONE = 6,
476
480typedef struct sx126x_chip_status_s {
484
492
494 bool pkt_sent;
495 bool pkt_received;
496 bool abort_error;
497 bool length_error;
498 bool crc_error;
499 bool adrs_error;
501
506 sx126x_rx_status_gfsk_t rx_status;
507 int8_t rssi_sync;
508 int8_t rssi_avg;
510
519
523typedef struct sx126x_stats_gfsk_s {
524 uint16_t nb_pkt_received;
525 uint16_t nb_pkt_crc_error;
526 uint16_t nb_pkt_len_error;
528
532typedef struct sx126x_stats_lora_s {
533 uint16_t nb_pkt_received;
534 uint16_t nb_pkt_crc_error;
535 uint16_t nb_pkt_header_error;
537
542 SX126X_ERRORS_RC64K_CALIBRATION = (1 << 0),
543 SX126X_ERRORS_RC13M_CALIBRATION = (1 << 1),
544 SX126X_ERRORS_PLL_CALIBRATION = (1 << 2),
545 SX126X_ERRORS_ADC_CALIBRATION = (1 << 3),
546 SX126X_ERRORS_IMG_CALIBRATION = (1 << 4),
547 SX126X_ERRORS_XOSC_START = (1 << 5),
548 SX126X_ERRORS_PLL_LOCK = (1 << 6),
549 SX126X_ERRORS_PA_RAMP = (1 << 8),
550};
551
552typedef uint16_t sx126x_errors_mask_t;
553
554/*
555 * -----------------------------------------------------------------------------
556 * --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
557 */
558
559//
560// Operational Modes Functions
561//
562
572
581sx126x_status_t sx126x_set_standby(struct network_context *nctx, const sx126x_standby_cfg_t cfg);
582
591
608sx126x_status_t sx126x_set_tx(struct network_context *nctx, const uint32_t timeout_in_ms);
609
631sx126x_status_t sx126x_set_tx_with_timeout_in_rtc_step(struct network_context *nctx, const uint32_t timeout_in_rtc_step);
632
653sx126x_status_t sx126x_set_rx(struct network_context *nctx, const uint32_t timeout_in_ms);
654
681sx126x_status_t sx126x_set_rx_with_timeout_in_rtc_step(struct network_context *nctx, const uint32_t timeout_in_rtc_step);
682
696
706sx126x_status_t sx126x_set_rx_duty_cycle(struct network_context *nctx, const uint32_t rx_time_in_ms, const uint32_t sleep_time_in_ms);
707
725sx126x_status_t sx126x_set_rx_duty_cycle_with_timings_in_rtc_step(struct network_context *nctx, const uint32_t rx_time_in_rtc_step, const uint32_t sleep_time_in_rtc_step);
726
739
750
761
774
788sx126x_status_t sx126x_cal(struct network_context *nctx, const sx126x_cal_mask_t param);
789
798sx126x_status_t sx126x_cal_img(struct network_context *nctx, const uint32_t freq_in_hz);
799
812
824
825//
826// Registers and Buffer Access
827//
828
839sx126x_status_t sx126x_write_register(struct network_context *nctx, const uint16_t address, const uint8_t *buffer, const uint8_t size);
840
851sx126x_status_t sx126x_read_register(struct network_context *nctx, const uint16_t address, uint8_t *buffer, const uint8_t size);
852
865sx126x_status_t sx126x_write_buffer(struct network_context *nctx, const uint8_t offset, const uint8_t *buffer, const uint8_t size);
866
879sx126x_status_t sx126x_read_buffer(struct network_context *nctx, const uint8_t offset, uint8_t *buffer, const uint8_t size);
880
881//
882// DIO and IRQ Control Functions
883//
884
908sx126x_status_t sx126x_set_dio_irq_params(struct network_context *nctx, const uint16_t irq_mask, const uint16_t dio1_mask, const uint16_t dio2_mask, const uint16_t dio3_mask);
909
920sx126x_status_t sx126x_get_irq_status(struct network_context *nctx, sx126x_irq_mask_t *irq);
921
932sx126x_status_t sx126x_clear_irq_status(struct network_context *nctx, const sx126x_irq_mask_t irq_mask);
933
943sx126x_status_t sx126x_get_and_clear_irq_status(struct network_context *nctx, sx126x_irq_mask_t *irq);
944
953sx126x_status_t sx126x_set_dio2_as_rf_sw_ctrl(struct network_context *nctx, const bool enable);
954
969sx126x_status_t sx126x_set_dio3_as_tcxo_ctrl(struct network_context *nctx, const sx126x_tcxo_ctrl_voltages_t tcxo_voltage, const uint32_t timeout);
970
971//
972// RF Modulation and Packet-Related Functions
973//
974
985sx126x_status_t sx126x_set_rf_freq(struct network_context *nctx, const uint32_t freq_in_hz);
986
997sx126x_status_t sx126x_set_rf_freq_in_pll_steps(struct network_context *nctx, const uint32_t freq);
998
1009
1019
1029sx126x_status_t sx126x_set_tx_params(struct network_context *nctx, const int8_t pwr_in_dbm, const sx126x_ramp_time_t ramp_time);
1030
1043
1055
1068
1080
1092
1102sx126x_status_t sx126x_set_buffer_base_address(struct network_context *nctx, const uint8_t tx_base_address, const uint8_t rx_base_address);
1103
1104sx126x_status_t sx126x_set_lora_symb_nb_timeout(struct network_context *nctx, const uint8_t nb_of_symbs);
1105
1106//
1107// Communication Status Information
1108//
1109
1119
1132
1142
1152
1165sx126x_status_t sx126x_get_rssi_inst(struct network_context *nctx, int16_t *rssi_in_dbm);
1166
1176
1186
1195
1196//
1197// Miscellaneous
1198//
1199
1208
1217
1226sx126x_status_t sx126x_get_device_errors(struct network_context *nctx, sx126x_errors_mask_t *errors);
1227
1236
1245sx126x_status_t sx126x_get_gfsk_bw_param(const uint32_t bw, uint8_t *param);
1246
1255
1267
1277
1289
1299
1320sx126x_status_t sx126x_get_random_numbers(struct network_context *nctx, uint32_t *numbers, unsigned int n);
1321
1329uint32_t sx126x_convert_freq_in_hz_to_pll_step(uint32_t freq_in_hz);
1330
1338uint32_t sx126x_convert_timeout_in_ms_to_rtc_step(uint32_t timeout_in_ms);
1339
1340//
1341// Registers access
1342//
1343
1355sx126x_status_t sx126x_cfg_rx_boosted(struct network_context *nctx, const bool state);
1356
1366sx126x_status_t sx126x_set_gfsk_sync_word(struct network_context *nctx, const uint8_t *sync_word, const uint8_t sync_word_len);
1367
1380sx126x_status_t sx126x_set_lora_sync_word(struct network_context *nctx, const uint8_t sync_word);
1381
1391
1400sx126x_status_t sx126x_set_gfsk_crc_polynomial(struct network_context *nctx, const uint16_t polynomial);
1401
1411
1424
1436
1447sx126x_status_t sx126x_set_ocp_value(struct network_context *nctx, const uint8_t ocp_in_step_of_2_5_ma);
1448
1461sx126x_status_t sx126x_set_trimming_capacitor_values(struct network_context *nctx, const uint8_t trimming_cap_xta, const uint8_t trimming_cap_xtb);
1462
1463#ifdef __cplusplus
1464}
1465#endif
1466
1467#endif // SX126X_H
1468
1469/* --- EOF ------------------------------------------------------------------ */
SX126X CAD parameters structure definition.
Definition: sx126x.h:443
sx126x_cad_symbs_t cad_symb_nb
CAD number of symbols.
Definition: sx126x.h:444
sx126x_cad_exit_modes_t cad_exit_mode
CAD exit mode.
Definition: sx126x.h:447
uint8_t cad_detect_min
CAD minimum detection.
Definition: sx126x.h:446
uint8_t cad_detect_peak
CAD peak detection.
Definition: sx126x.h:445
uint32_t cad_timeout
CAD timeout value.
Definition: sx126x.h:448
SX126X chip status structure definition.
Definition: sx126x.h:480
sx126x_chip_modes_t chip_mode
Current chip mode.
Definition: sx126x.h:482
sx126x_cmd_status_t cmd_status
Previous command status.
Definition: sx126x.h:481
SX126X GFSK modulation parameters structure definition.
Definition: sx126x.h:279
SX126X LoRa modulation parameters structure definition.
Definition: sx126x.h:329
sx126x_lora_sf_t sf
LoRa Spreading Factor.
Definition: sx126x.h:330
sx126x_lora_cr_t cr
LoRa Coding Rate.
Definition: sx126x.h:332
uint8_t ldro
Low DataRate Optimization configuration.
Definition: sx126x.h:333
sx126x_lora_bw_t bw
LoRa Bandwidth.
Definition: sx126x.h:331
SX126X power amplifier configuration parameters structure definition.
Definition: sx126x.h:147
SX126X GFSK packet parameters structure definition.
Definition: sx126x.h:405
sx126x_gfsk_pkt_len_modes_t header_type
Header type.
Definition: sx126x.h:410
sx126x_gfsk_preamble_detector_t preamble_detector
Preamble detection length.
Definition: sx126x.h:407
uint8_t pld_len_in_bytes
Payload length in bytes.
Definition: sx126x.h:411
uint16_t preamble_len_in_bits
Preamble length in bits.
Definition: sx126x.h:406
sx126x_gfsk_dc_free_t dc_free
Whitening configuration.
Definition: sx126x.h:413
uint8_t sync_word_len_in_bits
Sync word length in bits.
Definition: sx126x.h:408
sx126x_gfsk_crc_types_t crc_type
CRC type configuration.
Definition: sx126x.h:412
sx126x_gfsk_address_filtering_t address_filtering
Address filtering configuration.
Definition: sx126x.h:409
SX126X LoRa packet parameters structure definition.
Definition: sx126x.h:394
uint16_t preamble_len_in_symb
Preamble length in symbols.
Definition: sx126x.h:395
bool crc_is_on
CRC activation.
Definition: sx126x.h:398
bool invert_iq_is_on
IQ polarity setup.
Definition: sx126x.h:399
uint8_t pld_len_in_bytes
Payload length in bytes.
Definition: sx126x.h:397
sx126x_lora_pkt_len_modes_t header_type
Header type.
Definition: sx126x.h:396
SX126X GFSK packet status structure definition.
Definition: sx126x.h:505
int8_t rssi_sync
The RSSI measured on last packet.
Definition: sx126x.h:507
int8_t rssi_avg
The averaged RSSI.
Definition: sx126x.h:508
SX126X LoRa packet status structure definition.
Definition: sx126x.h:514
int8_t signal_rssi_pkt_in_dbm
Estimation of RSSI (after despreading)
Definition: sx126x.h:517
int8_t rssi_pkt_in_dbm
RSSI of the last packet.
Definition: sx126x.h:515
int8_t snr_pkt_in_db
SNR of the last packet.
Definition: sx126x.h:516
SX126X RX buffer status structure definition.
Definition: sx126x.h:488
uint8_t buffer_start_pointer
Position of the first byte in the buffer.
Definition: sx126x.h:490
uint8_t pld_len_in_bytes
Number of bytes available in the buffer.
Definition: sx126x.h:489
SX126X GFSK reception statistics structure definition.
Definition: sx126x.h:523
SX126X LoRa reception statistics structure definition.
Definition: sx126x.h:532
sx126x_status_t sx126x_set_rf_freq_in_pll_steps(struct network_context *nctx, const uint32_t freq)
Set the RF frequency for future radio operations - parameter in PLL steps.
Definition: sx126x.c:551
sx126x_status_t sx126x_set_fs(struct network_context *nctx)
Set the chip in frequency synthesis mode.
sx126x_lora_sf_e
SX126X LoRa spreading factor enumeration definition.
Definition: sx126x.h:289
sx126x_status_t sx126x_set_dio3_as_tcxo_ctrl(struct network_context *nctx, const sx126x_tcxo_ctrl_voltages_t tcxo_voltage, const uint32_t timeout)
Configure the embedded TCXO switch control.
Definition: sx126x.c:526
enum sx126x_lora_bw_e sx126x_lora_bw_t
SX126X LoRa bandwidth enumeration definition.
sx126x_status_t sx126x_set_rx_with_timeout_in_rtc_step(struct network_context *nctx, const uint32_t timeout_in_rtc_step)
Set the chip in reception mode.
Definition: sx126x.c:290
sx126x_status_t sx126x_get_rssi_inst(struct network_context *nctx, int16_t *rssi_in_dbm)
Get the instantaneous RSSI value.
Definition: sx126x.c:774
enum sx126x_gfsk_pulse_shape_e sx126x_gfsk_pulse_shape_t
SX126X GFSK modulation shaping enumeration definition.
sx126x_gfsk_pkt_len_modes_e
SX126X GFSK packet length enumeration definition.
Definition: sx126x.h:359
@ SX126X_GFSK_PKT_VAR_LEN
The packet length is variable, header included.
Definition: sx126x.h:361
@ SX126X_GFSK_PKT_FIX_LEN
The packet length is known on both sides, no header included.
Definition: sx126x.h:360
enum sx126x_cmd_status_e sx126x_cmd_status_t
SX126X command status enumeration definition.
sx126x_status_t sx126x_set_gfsk_mod_params(struct network_context *nctx, const sx126x_mod_params_gfsk_t *params)
Set the modulation parameters for GFSK packets.
sx126x_status_t sx126x_set_pkt_type(struct network_context *nctx, const sx126x_pkt_type_t pkt_type)
Set the packet type.
Definition: sx126x.c:564
sx126x_status_t sx126x_cfg_rx_boosted(struct network_context *nctx, const bool state)
Configure the boost mode in reception.
Definition: sx126x.c:1015
sx126x_status_t sx126x_set_rx_tx_fallback_mode(struct network_context *nctx, const sx126x_fallback_modes_t fallback_mode)
Set chip mode to be used after successful transmission or reception.
Definition: sx126x.c:386
sx126x_cad_exit_modes_e
SX126X LoRa CAD exit modes enumeration definition.
Definition: sx126x.h:434
struct sx126x_mod_params_gfsk_s sx126x_mod_params_gfsk_t
SX126X GFSK modulation parameters structure definition.
sx126x_status_t sx126x_set_pa_cfg(struct network_context *nctx, const sx126x_pa_cfg_params_t *params)
Configure the PA (Power Amplifier)
Definition: sx126x.c:373
sx126x_status_t sx126x_set_standby(struct network_context *nctx, const sx126x_standby_cfg_t cfg)
Set the chip in stand-by mode.
Definition: sx126x.c:248
enum sx126x_gfsk_dc_free_e sx126x_gfsk_dc_free_t
SX126X GFSK whitening control enumeration definition.
enum sx126x_status_e sx126x_status_t
SX126X APIs return status enumeration definition.
sx126x_status_t sx126x_get_lora_pkt_status(struct network_context *nctx, sx126x_pkt_status_lora_t *pkt_status)
Get the status of the last LoRa packet received.
Definition: sx126x.c:755
struct sx126x_pkt_status_gfsk_s sx126x_pkt_status_gfsk_t
SX126X GFSK packet status structure definition.
struct sx126x_chip_status_s sx126x_chip_status_t
SX126X chip status structure definition.
sx126x_status_t sx126x_get_status(struct network_context *nctx, sx126x_chip_status_t *radio_status)
Get the chip status.
Definition: sx126x.c:718
sx126x_status_t sx126x_set_lora_mod_params(struct network_context *nctx, const sx126x_mod_params_lora_t *params)
Set the modulation parameters for LoRa packets.
Definition: sx126x.c:600
sx126x_status_t sx126x_set_rf_freq(struct network_context *nctx, const uint32_t freq_in_hz)
Set the RF frequency for future radio operations.
Definition: sx126x.c:545
sx126x_status_t sx126x_set_tx(struct network_context *nctx, const uint32_t timeout_in_ms)
Set the chip in transmission mode.
Definition: sx126x.c:258
sx126x_status_t sx126x_get_gfsk_stats(struct network_context *nctx, sx126x_stats_gfsk_t *stats)
Get the statistics about GFSK communication.
sx126x_cad_symbs_e
SX126X LoRa CAD number of symbols enumeration definition.
Definition: sx126x.h:421
sx126x_status_t sx126x_stop_rtc(struct network_context *nctx)
Stop the RTC and clear the related event.
enum sx126x_lora_cr_e sx126x_lora_cr_t
SX126X LoRa coding rate enumeration definition.
sx126x_status_t sx126x_set_rx_duty_cycle(struct network_context *nctx, const uint32_t rx_time_in_ms, const uint32_t sleep_time_in_ms)
Set the chip in reception mode with duty cycling.
sx126x_status_t sx126x_set_gfsk_crc_polynomial(struct network_context *nctx, const uint16_t polynomial)
Configure the polynomial used to compute CRC in GFSK packet.
sx126x_fallback_modes_e
SX126X fallback modes enumeration definition.
Definition: sx126x.h:157
struct sx126x_pa_cfg_params_s sx126x_pa_cfg_params_t
SX126X power amplifier configuration parameters structure definition.
uint32_t sx126x_get_lora_bw_in_hz(sx126x_lora_bw_t bw)
Get the actual value in Hertz of a given LoRa bandwidth.
Definition: sx126x.c:850
sx16x_gfsk_crc_types_e
SX126X GFSK CRC type enumeration definition.
Definition: sx126x.h:367
sx126x_irq_masks_e
SX126X interrupt masks enumeration definition.
Definition: sx126x.h:166
sx126x_status_t sx126x_read_register(struct network_context *nctx, const uint16_t address, uint8_t *buffer, const uint8_t size)
Read data from register memory space.
Definition: sx126x.c:412
uint32_t sx126x_convert_timeout_in_ms_to_rtc_step(uint32_t timeout_in_ms)
Get the number of RTC steps for a given timeout in millisecond.
Definition: sx126x.c:1007
sx126x_status_t sx126x_cfg_tx_clamp(struct network_context *nctx)
Configure the Tx PA clamp.
Definition: sx126x.c:1041
sx126x_status_t sx126x_get_irq_status(struct network_context *nctx, sx126x_irq_mask_t *irq)
Get system interrupt status.
Definition: sx126x.c:474
sx126x_status_e
SX126X APIs return status enumeration definition.
Definition: sx126x.h:111
uint32_t sx126x_get_gfsk_time_on_air_in_ms(const sx126x_pkt_params_gfsk_t *pkt_p, const sx126x_mod_params_gfsk_t *mod_p)
Get the time on air in ms for GFSK transmission.
sx126x_gfsk_bw_e
SX126X GFSK Rx bandwidth enumeration definition.
Definition: sx126x.h:252
sx126x_lora_cr_e
SX126X LoRa coding rate enumeration definition.
Definition: sx126x.h:319
struct sx126x_cad_param_s sx126x_cad_params_t
SX126X CAD parameters structure definition.
enum sx126x_lora_pkt_len_modes_e sx126x_lora_pkt_len_modes_t
SX126X LoRa packet length enumeration definition.
struct sx126x_mod_params_lora_s sx126x_mod_params_lora_t
SX126X LoRa modulation parameters structure definition.
sx126x_gfsk_preamble_detector_e
SX126X GFSK preamble length Rx detection size enumeration definition.
Definition: sx126x.h:339
sx126x_status_t sx126x_set_tx_infinite_preamble(struct network_context *nctx)
Set the chip in Tx infinite preamble (modulated signal).
struct sx126x_pkt_params_lora_s sx126x_pkt_params_lora_t
SX126X LoRa packet parameters structure definition.
sx126x_status_t sx126x_reset_stats(struct network_context *nctx)
Reset all the statistics for both Lora and GFSK communications.
Definition: sx126x.c:809
sx126x_cal_mask_e
Calibration settings.
Definition: sx126x.h:188
sx126x_status_t sx126x_set_ocp_value(struct network_context *nctx, const uint8_t ocp_in_step_of_2_5_ma)
Configure the Over Current Protection (OCP) value.
sx126x_status_t sx126x_write_register(struct network_context *nctx, const uint16_t address, const uint8_t *buffer, const uint8_t size)
Write data into register memory space.
Definition: sx126x.c:400
struct sx126x_pkt_params_gfsk_s sx126x_pkt_params_gfsk_t
SX126X GFSK packet parameters structure definition.
sx126x_status_t sx126x_set_reg_mode(struct network_context *nctx, const sx126x_reg_mod_t mode)
Configure the regulator mode to be used.
Definition: sx126x.c:328
sx126x_status_t sx126x_cal_img(struct network_context *nctx, const uint32_t freq_in_hz)
Perform device operating frequency band image rejection calibration.
Definition: sx126x.c:348
sx126x_status_t sx126x_get_device_errors(struct network_context *nctx, sx126x_errors_mask_t *errors)
Get the list of all active errors.
Definition: sx126x.c:825
sx126x_status_t sx126x_set_gfsk_sync_word(struct network_context *nctx, const uint8_t *sync_word, const uint8_t sync_word_len)
Configure the sync word used in GFSK packet.
enum sx126x_gfsk_preamble_detector_e sx126x_gfsk_preamble_detector_t
SX126X GFSK preamble length Rx detection size enumeration definition.
uint32_t sx126x_get_lora_time_on_air_in_ms(const sx126x_pkt_params_lora_t *pkt_p, const sx126x_mod_params_lora_t *mod_p)
Get the time on air in ms for LoRa transmission.
Definition: sx126x.c:927
enum sx126x_pkt_types_e sx126x_pkt_type_t
SX126X packet types enumeration definition.
sx126x_status_t sx126x_set_trimming_capacitor_values(struct network_context *nctx, const uint8_t trimming_cap_xta, const uint8_t trimming_cap_xtb)
Configure the internal trimming capacitor values.
enum sx126x_gfsk_pkt_len_modes_e sx126x_gfsk_pkt_len_modes_t
SX126X GFSK packet length enumeration definition.
sx126x_errors_e
SX126X errors enumeration definition.
Definition: sx126x.h:541
sx126x_status_t sx126x_set_gfsk_whitening_seed(struct network_context *nctx, const uint16_t seed)
Configure the whitening seed used in GFSK packet.
enum sx126x_gfsk_bw_e sx126x_gfsk_bw_t
SX126X GFSK Rx bandwidth enumeration definition.
sx126x_status_t sx126x_wakeup(struct network_context *nctx)
Wake the radio up from sleep mode.
enum sx126x_ramp_time_e sx126x_ramp_time_t
SX126X power amplifier ramp-up timings enumeration definition.
sx126x_status_t sx126x_cal(struct network_context *nctx, const sx126x_cal_mask_t param)
Perform the calibration of the requested blocks.
Definition: sx126x.c:338
sx126x_status_t sx126x_set_gfsk_pkt_params(struct network_context *nctx, const sx126x_pkt_params_gfsk_t *params)
Set the packet parameters for GFSK packets.
sx126x_standby_cfgs_e
SX126X standby modes enumeration definition.
Definition: sx126x.h:129
sx126x_status_t sx126x_get_pkt_type(struct network_context *nctx, sx126x_pkt_type_t *pkt_type)
Get the current packet type.
Definition: sx126x.c:574
sx126x_status_t sx126x_get_and_clear_irq_status(struct network_context *nctx, sx126x_irq_mask_t *irq)
Clears any radio irq status flags that are set and returns the flags that were cleared.
Definition: sx126x.c:502
sx126x_status_t sx126x_get_gfsk_pkt_status(struct network_context *nctx, sx126x_pkt_status_gfsk_t *pkt_status)
Get the status of the last GFSK packet received.
enum sx126x_standby_cfgs_e sx126x_standby_cfgs_t
SX126X standby modes enumeration definition.
enum sx126x_chip_modes_e sx126x_chip_modes_t
SX126X chip mode enumeration definition.
sx126x_reg_mods_e
SX126X power regulator modes enumeration definition.
Definition: sx126x.h:139
sx126x_status_t sx126x_reset(struct network_context *nctx)
Perform a hard reset of the chip.
Definition: sx126x.c:821
enum sx126x_gfsk_address_filtering_e sx126x_gfsk_address_filtering_t
SX126X GFSK address filtering configuration enumeration definition.
sx126x_status_t sx126x_set_rx_duty_cycle_with_timings_in_rtc_step(struct network_context *nctx, const uint32_t rx_time_in_rtc_step, const uint32_t sleep_time_in_rtc_step)
Set the chip in reception mode with duty cycling.
Definition: sx126x.c:302
enum sx126x_tcxo_ctrl_voltages_e sx126x_tcxo_ctrl_voltages_t
SX126X TCXO control voltages enumeration definition.
sx126x_gfsk_dc_free_e
SX126X GFSK whitening control enumeration definition.
Definition: sx126x.h:378
sx126x_status_t sx126x_write_buffer(struct network_context *nctx, const uint8_t offset, const uint8_t *buffer, const uint8_t size)
Write data into radio Tx buffer memory space.
Definition: sx126x.c:426
sx126x_status_t sx126x_read_buffer(struct network_context *nctx, const uint8_t offset, uint8_t *buffer, const uint8_t size)
Read data from radio Rx buffer memory space.
Definition: sx126x.c:437
sx126x_sleep_cfgs_e
SX126X sleep mode configurations definition.
Definition: sx126x.h:121
enum sx126x_cad_exit_modes_e sx126x_cad_exit_modes_t
SX126X LoRa CAD exit modes enumeration definition.
sx126x_lora_pkt_len_modes_e
SX126X LoRa packet length enumeration definition.
Definition: sx126x.h:386
@ SX126X_LORA_PKT_EXPLICIT
Header included in the packet.
Definition: sx126x.h:387
@ SX126X_LORA_PKT_IMPLICIT
Header not included in the packet.
Definition: sx126x.h:388
sx126x_status_t sx126x_get_rx_buffer_status(struct network_context *nctx, sx126x_rx_buffer_status_t *rx_buffer_status)
Get the current Rx buffer status for both LoRa and GFSK Rx operations.
Definition: sx126x.c:737
sx126x_status_t sx126x_set_sleep(struct network_context *nctx, const sx126x_sleep_cfgs_t cfg)
Set the chip in sleep mode.
enum sx126x_fallback_modes_e sx126x_fallback_modes_t
SX126X fallback modes enumeration definition.
sx126x_status_t sx126x_set_dio_irq_params(struct network_context *nctx, const uint16_t irq_mask, const uint16_t dio1_mask, const uint16_t dio2_mask, const uint16_t dio3_mask)
Set which interrupt signals are redirected to the dedicated DIO pin.
Definition: sx126x.c:453
uint32_t sx126x_get_gfsk_time_on_air_numerator(const sx126x_pkt_params_gfsk_t *pkt_p)
Compute the numerator for GFSK time-on-air computation.
sx126x_status_t sx126x_clear_device_errors(struct network_context *nctx)
Clear all active errors.
Definition: sx126x.c:842
struct sx126x_rx_buffer_status_s sx126x_rx_buffer_status_t
SX126X RX buffer status structure definition.
sx126x_status_t sx126x_set_gfsk_crc_seed(struct network_context *nctx, uint16_t seed)
Configure the seed used to compute CRC in GFSK packet.
sx126x_status_t sx126x_set_dio2_as_rf_sw_ctrl(struct network_context *nctx, const bool enable)
Configure the embedded RF switch control.
Definition: sx126x.c:516
enum sx16x_gfsk_crc_types_e sx126x_gfsk_crc_types_t
SX126X GFSK CRC type enumeration definition.
sx126x_status_t sx126x_get_random_numbers(struct network_context *nctx, uint32_t *numbers, unsigned int n)
Generate one or more 32-bit random numbers.
Definition: sx126x.c:936
sx126x_status_t sx126x_set_buffer_base_address(struct network_context *nctx, const uint8_t tx_base_address, const uint8_t rx_base_address)
Set buffer start addresses for both Tx and Rx operations.
Definition: sx126x.c:675
sx126x_lora_bw_e
SX126X LoRa bandwidth enumeration definition.
Definition: sx126x.h:303
sx126x_status_t sx126x_stop_timer_on_preamble(struct network_context *nctx, const bool enable)
Configure the event on which the Rx timeout is stopped.
uint32_t sx126x_convert_freq_in_hz_to_pll_step(uint32_t freq_in_hz)
Get the number of PLL steps for a given frequency in Hertz.
Definition: sx126x.c:993
struct sx126x_stats_lora_s sx126x_stats_lora_t
SX126X LoRa reception statistics structure definition.
struct sx126x_stats_gfsk_s sx126x_stats_gfsk_t
SX126X GFSK reception statistics structure definition.
sx126x_status_t sx126x_set_tx_params(struct network_context *nctx, const int8_t pwr_in_dbm, const sx126x_ramp_time_t ramp_time)
Set the parameters for TX power and power amplifier ramp time.
Definition: sx126x.c:587
sx126x_status_t sx126x_get_lora_stats(struct network_context *nctx, sx126x_stats_lora_t *stats)
Get the statistics about LoRa communication.
Definition: sx126x.c:791
sx126x_gfsk_address_filtering_e
SX126X GFSK address filtering configuration enumeration definition.
Definition: sx126x.h:350
enum sx126x_cad_symbs_e sx126x_cad_symbs_t
SX126X LoRa CAD number of symbols enumeration definition.
sx126x_status_t sx126x_set_tx_cw(struct network_context *nctx)
Set the chip in Tx continuous wave (RF tone).
enum sx126x_reg_mods_e sx126x_reg_mod_t
SX126X power regulator modes enumeration definition.
sx126x_ramp_time_e
SX126X power amplifier ramp-up timings enumeration definition.
Definition: sx126x.h:227
sx126x_status_t sx126x_get_gfsk_bw_param(const uint32_t bw, uint8_t *param)
Get the parameter corresponding to a GFSK Rx bandwith immediately above the minimum requested one.
uint32_t sx126x_get_lora_time_on_air_numerator(const sx126x_pkt_params_lora_t *pkt_p, const sx126x_mod_params_lora_t *mod_p)
Compute the numerator for LoRa time-on-air computation.
Definition: sx126x.c:889
sx126x_status_t sx126x_set_cad(struct network_context *nctx)
Set the chip in CAD (Channel Activity Detection) mode.
Definition: sx126x.c:320
sx126x_pkt_types_e
SX126X packet types enumeration definition.
Definition: sx126x.h:219
sx126x_status_t sx126x_set_lora_pkt_params(struct network_context *nctx, const sx126x_pkt_params_lora_t *params)
Set the packet parameters for LoRa packets.
Definition: sx126x.c:624
sx126x_status_t sx126x_set_rx(struct network_context *nctx, const uint32_t timeout_in_ms)
Set the chip in reception mode.
Definition: sx126x.c:280
sx126x_cmd_status_e
SX126X command status enumeration definition.
Definition: sx126x.h:467
enum sx126x_lora_sf_e sx126x_lora_sf_t
SX126X LoRa spreading factor enumeration definition.
sx126x_gfsk_pulse_shape_e
SX126X GFSK modulation shaping enumeration definition.
Definition: sx126x.h:241
sx126x_status_t sx126x_set_lora_sync_word(struct network_context *nctx, const uint8_t sync_word)
Configure the sync word used in LoRa packet.
Definition: sx126x.c:1023
sx126x_status_t sx126x_set_cad_params(struct network_context *nctx, const sx126x_cad_params_t *params)
Set the parameters for CAD operation.
Definition: sx126x.c:659
sx126x_status_t sx126x_set_tx_with_timeout_in_rtc_step(struct network_context *nctx, const uint32_t timeout_in_rtc_step)
Set the chip in transmission mode.
Definition: sx126x.c:268
sx126x_status_t sx126x_clear_irq_status(struct network_context *nctx, const sx126x_irq_mask_t irq_mask)
Clear selected system interrupts.
Definition: sx126x.c:491
enum sx126x_sleep_cfgs_e sx126x_sleep_cfgs_t
SX126X sleep mode configurations definition.
struct sx126x_pkt_status_lora_s sx126x_pkt_status_lora_t
SX126X LoRa packet status structure definition.
sx126x_chip_modes_e
SX126X chip mode enumeration definition.
Definition: sx126x.h:454
sx126x_tcxo_ctrl_voltages_e
SX126X TCXO control voltages enumeration definition.
Definition: sx126x.h:205