28#ifndef MBED_LORA_RADIO_DRV_SX126X_SX126X_DS_H_
29#define MBED_LORA_RADIO_DRV_SX126X_SX126X_DS_H_
37#define XTAL_FREQ 32000000
38#define FREQ_DIV 33554432
39#define FREQ_STEP 0.95367431640625
40#define FREQ_ERR 0.47683715820312
53#define MATCHING_FREQ_915 0
54#define MATCHING_FREQ_780 1
55#define MATCHING_FREQ_490 2
56#define MATCHING_FREQ_434 3
57#define MATCHING_FREQ_280 4
58#define MATCHING_FREQ_169 5
59#define MATCHING_FREQ_868 6
64#define AUTO_RX_TX_OFFSET 2
69#define CRC_IBM_SEED 0xFFFF
74#define CRC_CCITT_SEED 0x1D0F
79#define CRC_POLYNOMIAL_IBM 0x8005
84#define CRC_POLYNOMIAL_CCITT 0x1021
90#define REG_LR_CRCSEEDBASEADDR 0x06BC
95#define REG_LR_CRCPOLYBASEADDR 0x06BE
100#define REG_LR_WHITSEEDBASEADDR_MSB 0x06B8
101#define REG_LR_WHITSEEDBASEADDR_LSB 0x06B9
106#define REG_LR_PACKETPARAMS 0x0704
111#define REG_LR_PAYLOADLENGTH 0x0702
116#define REG_LR_SYNCWORDBASEADDRESS 0x06C0
121#define REG_LR_SYNCWORD 0x0740
126#define LORA_MAC_PRIVATE_SYNCWORD 0x1424
131#define LORA_MAC_PUBLIC_SYNCWORD 0x3444
136#define RANDOM_NUMBER_GENERATORBASEADDR 0x0819
141#define REG_RX_GAIN 0x08AC
146#define REG_FREQUENCY_ERRORBASEADDR 0x076B
151#define REG_XTA_TRIM 0x0911
156#define REG_OCP 0x08E7
164 uint16_t packet_received;
166 uint16_t length_error;
180 uint8_t img_enable : 1;
250 RADIO_RAMP_10_US = 0x00,
251 RADIO_RAMP_20_US = 0x01,
252 RADIO_RAMP_40_US = 0x02,
253 RADIO_RAMP_80_US = 0x03,
254 RADIO_RAMP_200_US = 0x04,
255 RADIO_RAMP_800_US = 0x05,
256 RADIO_RAMP_1700_US = 0x06,
257 RADIO_RAMP_3400_US = 0x07,
264 LORA_CAD_01_SYMBOL = 0x00,
265 LORA_CAD_02_SYMBOL = 0x01,
266 LORA_CAD_04_SYMBOL = 0x02,
267 LORA_CAD_08_SYMBOL = 0x03,
268 LORA_CAD_16_SYMBOL = 0x04,
275 LORA_CAD_ONLY = 0x00,
284 MOD_SHAPING_OFF = 0x00,
285 MOD_SHAPING_G_BT_03 = 0x08,
286 MOD_SHAPING_G_BT_05 = 0x09,
287 MOD_SHAPING_G_BT_07 = 0x0A,
288 MOD_SHAPING_G_BT_1 = 0x0B,
348const uint8_t lora_bandwidhts [] = {LORA_BW_125, LORA_BW_250, LORA_BW_500};
376 RADIO_ADDRESSCOMP_FILT_NODE = 0x01,
377 RADIO_ADDRESSCOMP_FILT_NODE_BROAD = 0x02,
393 RADIO_CRC_1_BYTES = 0x00,
394 RADIO_CRC_2_BYTES = 0x02,
395 RADIO_CRC_1_BYTES_INV = 0x04,
396 RADIO_CRC_2_BYTES_INV = 0x06,
397 RADIO_CRC_2_BYTES_IBM = 0xF1,
398 RADIO_CRC_2_BYTES_CCIT = 0xF2,
405 RADIO_DC_FREE_OFF = 0x00,
406 RADIO_DC_FREEWHITENING = 0x01,
431 LORA_IQ_NORMAL = 0x00,
432 LORA_IQ_INVERTED = 0x01,
439 TCXO_CTRL_1_6V = 0x00,
440 TCXO_CTRL_1_7V = 0x01,
441 TCXO_CTRL_1_8V = 0x02,
442 TCXO_CTRL_2_2V = 0x03,
443 TCXO_CTRL_2_4V = 0x04,
444 TCXO_CTRL_2_7V = 0x05,
445 TCXO_CTRL_3_0V = 0x06,
446 TCXO_CTRL_3_3V = 0x07,
455 IRQ_RADIO_NONE = 0x0000,
456 IRQ_TX_DONE = 0x0001,
457 IRQ_RX_DONE = 0x0002,
458 IRQ_PREAMBLE_DETECTED = 0x0004,
459 IRQ_SYNCWORD_VALID = 0x0008,
460 IRQ_HEADER_VALID = 0x0010,
461 IRQ_HEADER_ERROR = 0x0020,
462 IRQ_CRC_ERROR = 0x0040,
463 IRQ_CAD_DONE = 0x0080,
464 IRQ_CAD_ACTIVITY_DETECTED = 0x0100,
465 IRQ_RX_TX_TIMEOUT = 0x0200,
466 IRQ_RADIO_ALL = 0xFFFF,
470 RADIO_GET_STATUS = 0xC0,
471 RADIO_WRITE_REGISTER = 0x0D,
472 RADIO_READ_REGISTER = 0x1D,
473 RADIO_WRITE_BUFFER = 0x0E,
474 RADIO_READ_BUFFER = 0x1E,
475 RADIO_SET_SLEEP = 0x84,
476 RADIO_SET_STANDBY = 0x80,
480 RADIO_SET_RXDUTYCYCLE = 0x94,
481 RADIO_SET_CAD = 0xC5,
482 RADIO_SET_TXCONTINUOUSWAVE = 0xD1,
483 RADIO_SET_TXCONTINUOUSPREAMBLE = 0xD2,
484 RADIO_SET_PACKETTYPE = 0x8A,
485 RADIO_GET_PACKETTYPE = 0x11,
486 RADIO_SET_RFFREQUENCY = 0x86,
487 RADIO_SET_TXPARAMS = 0x8E,
488 RADIO_SET_PACONFIG = 0x95,
489 RADIO_SET_CADPARAMS = 0x88,
490 RADIO_SET_BUFFERBASEADDRESS = 0x8F,
491 RADIO_SET_MODULATIONPARAMS = 0x8B,
492 RADIO_SET_PACKETPARAMS = 0x8C,
493 RADIO_GET_RXBUFFERSTATUS = 0x13,
494 RADIO_GET_PACKETSTATUS = 0x14,
495 RADIO_GET_RSSIINST = 0x15,
496 RADIO_GET_STATS = 0x10,
497 RADIO_RESET_STATS = 0x00,
498 RADIO_CFG_DIOIRQ = 0x08,
499 RADIO_GET_IRQSTATUS = 0x12,
500 RADIO_CLR_IRQSTATUS = 0x02,
501 RADIO_CALIBRATE = 0x89,
502 RADIO_CALIBRATEIMAGE = 0x98,
503 RADIO_SET_REGULATORMODE = 0x96,
504 RADIO_GET_ERROR = 0x17,
505 RADIO_CLR_ERROR = 0x07,
506 RADIO_SET_TCXOMODE = 0x97,
507 RADIO_SET_TXFALLBACKMODE = 0x93,
508 RADIO_SET_RFSWITCHMODE = 0x9D,
509 RADIO_SET_STOPRXTIMERONPREAMBLE = 0x9F,
510 RADIO_SET_LORASYMBTIMEOUT = 0xA0,
531 IRQ_HEADER_ERROR_CODE = 0x01,
532 IRQ_SYNCWORD_ERROR_CODE = 0x02,
533 IRQ_CRC_ERROR_CODE = 0x04,
538 IRQ_PBL_DETECT_CODE = 0x01,
539 IRQ_SYNCWORD_VALID_CODE = 0x02,
540 IRQ_HEADER_VALID_CODE = 0x04,
544 IRQ_RX_TIMEOUT = 0x00,
545 IRQ_TX_TIMEOUT = 0x01,
549 RECEPTION_MODE_SINGLE = 0,
550 RECEPTION_MODE_CONTINUOUS,
565 uint32_t operational_frequency;
573 uint32_t operational_frequency;
625 int8_t signal_rssi_pkt;
radio_mod_shaping_t
Represents the modulation shaping parameter.
lora_spread_factors_t
Represents the possible spreading factor values in LoRa packet types.
enum radio_crc_types_e radio_crc_types_t
Represents the CRC length.
lora_pkt_length_t
Holds the lengths mode of a LoRa packet type.
lora_bandwidths_t
Represents the bandwidth values for LoRa packet type.
radio_preamble_detection_t
Represents the preamble length used to detect the packet on Rx side.
radio_pkt_length_t
Radio packet length mode.
lora_crc_mode_t
Represents the CRC mode for LoRa packet type.
lora_IQ_mode_t
Represents the IQ mode for LoRa packet type.
radio_whitening_mode_t
Radio whitening mode activated or deactivated.
radio_address_filter_t
Represents the possible combinations of SyncWord correlators activated.
enum modem_type radio_modems_t
Type of modem.
The type describing the modulation parameters for every packet types.
lora_coding_tates_t coding_rate
Coding rate for the LoRa modulation.
lora_bandwidths_t bandwidth
Bandwidth for the LoRa modulation.
lora_spread_factors_t spreading_factor
Spreading Factor for the LoRa modulation.
radio_modems_t modem_type
Packet to which the modulation parameters are referring to.
uint8_t low_datarate_optimization
Indicates if the modem uses the low datarate optimization.
The type describing the packet parameters for every packet types.
radio_crc_types_t crc_length
Size of the CRC block in the GFSK packet.
radio_preamble_detection_t preamble_min_detect
The preamble Rx length minimal for GFSK packet type.
lora_IQ_mode_t invert_IQ
Allows to swap IQ for LoRa packet.
radio_pkt_length_t header_type
If the header is explicit, it will be transmitted in the GFSK packet. If the header is implicit,...
lora_pkt_length_t header_type
If the header is explicit, it will be transmitted in the LoRa packet. If the header is implicit,...
uint8_t syncword_length
The synchronization word length for GFSK packet type.
uint8_t payload_length
Size of the payload in the GFSK packet.
radio_address_filter_t addr_comp
Activated SyncWord correlators.
struct packet_params::@6::@7 gfsk
Holds the GFSK packet parameters.
lora_crc_mode_t crc_mode
Size of CRC block in LoRa packet.
uint16_t preamble_length
The preamble Tx length for GFSK packet type in bit.
struct packet_params::@6::@8 lora
Holds the LoRa packet parameters.
radio_modems_t modem_type
Packet to which the packet parameters are referring to.
struct packet_params::@6 params
Holds the packet parameters structure.
Represents the packet status for every packet type.
int8_t rssi_sync
The RSSI measured on last packet.
int8_t rssi_pkt
The RSSI of the last packet.
int8_t snr_pkt
The SNR of the last packet.
int8_t rssi_avg
The averaged RSSI.
radio_modems_t modem_type
Packet to which the packet status are referring to.
Represents the Rx internal counters values when GFSK or LoRa packet type is used.
radio_modems_t modem_type
Packet to which the packet status are referring to.
radio_mod_shaping_t
Represents the modulation shaping parameter.
lora_coding_tates_t
Represents the coding rate values for LoRa packet type.
struct packet_params packet_params_t
The type describing the packet parameters for every packet types.
lora_spread_factors_t
Represents the possible spreading factor values in LoRa packet types.
enum radio_crc_types_e radio_crc_types_t
Represents the CRC length.
radio_standby_mode_t
Declares the oscillator in use while in standby mode.
lora_pkt_length_t
Holds the lengths mode of a LoRa packet type.
@ LORA_PACKET_FIXED_LENGTH
The packet is known on both sides, no header included in the packet.
@ LORA_PACKET_VARIABLE_LENGTH
The packet is on variable size, header included.
lora_bandwidths_t
Represents the bandwidth values for LoRa packet type.
radio_operating_mode_t
Represents the operating mode the radio is actually running.
@ MODE_TX
The radio is in frequency synthesis mode.
@ MODE_CAD
The radio is in receive duty cycle mode.
@ MODE_STDBY_XOSC
The radio is in standby mode with RC oscillator.
@ MODE_STDBY_RC
The radio is in deep-sleep mode.
@ MODE_RX
The radio is in transmit mode.
@ MODE_DEEP_SLEEP
The radio is in sleep mode.
@ MODE_FS
The radio is in standby mode with XOSC oscillator.
@ MODE_RX_DC
The radio is in receive mode.
irq_error_t
Structure describing the error codes for callback functions.
radio_preamble_detection_t
Represents the preamble length used to detect the packet on Rx side.
@ RADIO_PREAMBLE_DETECTOR_OFF
Preamble detection length off.
@ RADIO_PREAMBLE_DETECTOR_32_BITS
Preamble detection length 32 bit.
@ RADIO_PREAMBLE_DETECTOR_16_BITS
Preamble detection length 16 bits.
@ RADIO_PREAMBLE_DETECTOR_08_BITS
Preamble detection length 8 bits.
@ RADIO_PREAMBLE_DETECTOR_24_BITS
Preamble detection length 24 bits.
radio_crc_types_e
Represents the CRC length.
@ RADIO_CRC_OFF
No CRC in use.
radio_pkt_length_t
Radio packet length mode.
@ RADIO_PACKET_VARIABLE_LENGTH
The packet is on variable size, header included.
@ RADIO_PACKET_FIXED_LENGTH
The packet is known on both sides, no header included in the packet.
radio_ramp_time_t
Represents the ramping time for power amplifier.
radio_rx_bandwidth_t
Represents the modulation shaping parameter.
lora_crc_mode_t
Represents the CRC mode for LoRa packet type.
@ LORA_CRC_OFF
CRC not used.
@ LORA_CRC_ON
CRC activated.
lora_IQ_mode_t
Represents the IQ mode for LoRa packet type.
radio_regulator_mode_t
Declares the power regulation used to power the device.
radio_TCXO_ctrl_voltage_t
Represents the volatge used to control the TCXO on/off from DIO3.
lora_cad_symbols_t
Represents the number of symbols to be used for channel activity detection operation.
radio_irq_masks_t
Represents the interruption masks available for the radio.
cad_exit_modes_t
Represents the Channel Activity Detection actions after the CAD operation is finished.
radio_whitening_mode_t
Radio whitening mode activated or deactivated.
radio_address_filter_t
Represents the possible combinations of SyncWord correlators activated.
@ RADIO_ADDRESSCOMP_FILT_OFF
No correlator turned on, i.e. do not search for SyncWord.
Represents a calibration configuration.
uint8_t rc64k_enable
Calibrate RC64K clock.
uint8_t pll_enable
Calibrate PLL.
uint8_t adc_bulkN_enable
Calibrate ADC bulkN.
uint8_t rc13m_enable
Calibrate RC13M clock.
uint8_t adc_bulkP_enable
Calibrate ADC bulkP.
uint8_t adc_pulse_enable
Calibrate ADC Pulse.
Represents the possible radio system error states.
uint8_t xosc_start
XOSC oscillator failed to start.
uint8_t pll_lock
PLL lock failed.
uint8_t pll_calib
PLL calibration failed.
uint8_t adc_calib
ADC calibration failed.
uint8_t rc64k_calib
RC 64kHz oscillator calibration failed.
uint8_t pa_ramp
PA ramp failed.
uint8_t buck_start
Buck converter failed to start.
uint8_t img_calib
Image calibration failed.
uint8_t rc13m_calib
RC 13MHz oscillator calibration failed.
Structure describing the radio status.
uint8_t cpu_busy
Flag for CPU radio busy.
uint8_t reserved
Reserved.
uint8_t chip_mode
Chip mode.
uint8_t cmd_status
Command status.