28 #ifndef MBED_LORA_RADIO_DRV_SX126X_SX126X_DS_H_ 29 #define MBED_LORA_RADIO_DRV_SX126X_SX126X_DS_H_ 31 #include "LoRaRadio.h" 37 #define XTAL_FREQ 32000000 38 #define FREQ_DIV 33554432 39 #define FREQ_STEP 0.95367431640625 // ((double)(XTAL_FREQ / (double)FREQ_DIV)) 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;
174 uint8_t rc64k_enable : 1;
175 uint8_t rc13m_enable : 1;
176 uint8_t pll_enable : 1;
177 uint8_t adc_pulse_enable : 1;
178 uint8_t adc_bulkN_enable : 1;
179 uint8_t adc_bulkP_enable : 1;
180 uint8_t img_enable : 1;
193 uint8_t rc64k_calib : 1;
194 uint8_t rc13m_calib : 1;
195 uint8_t pll_calib : 1;
196 uint8_t adc_calib : 1;
197 uint8_t img_calib : 1;
198 uint8_t xosc_start : 1;
199 uint8_t pll_lock : 1;
200 uint8_t buck_start : 1;
202 uint8_t reserved : 7;
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,
348 const uint8_t lora_bandwidhts [] = {LORA_BW_125, LORA_BW_250, LORA_BW_500};
358 } lora_coding_tates_t;
376 RADIO_ADDRESSCOMP_FILT_NODE = 0x01,
377 RADIO_ADDRESSCOMP_FILT_NODE_BROAD = 0x02,
391 typedef enum radio_crc_types_e {
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,
520 uint8_t reserved : 1;
521 uint8_t cmd_status : 3;
522 uint8_t chip_mode : 3;
523 uint8_t cpu_busy : 1;
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,
563 radio_mod_shaping_t modulation_shaping;
565 uint32_t operational_frequency;
573 uint32_t operational_frequency;
595 radio_whitening_mode_t whitening_mode;
625 int8_t signal_rssi_pkt;
radio_irq_masks_t
Represents the interruption masks available for the radio.
Preamble detection length 32 bit.
Preamble detection length 16 bits.
The type describing the packet parameters for every packet types.
radio_rx_bandwidth_t
Represents the modulation shaping parameter.
int8_t snr_pkt
The SNR of the last packet.
The packet is known on both sides, no header included in the packet.
The radio is in sleep mode.
Represents the possible radio system error states.
Preamble detection length 8 bits.
enum modem_type radio_modems_t
Type of modem.
lora_bandwidths_t bandwidth
Bandwidth for the LoRa modulation.
lora_IQ_mode_t
Represents the IQ mode for LoRa packet type.
radio_crc_types_t crc_length
Size of the CRC block in the GFSK packet.
uint8_t low_datarate_optimization
Indicates if the modem uses the low datarate optimization.
radio_ramp_time_t
Represents the ramping time for power amplifier.
lora_crc_mode_t
Represents the CRC mode for LoRa packet type.
lora_coding_tates_t coding_rate
Coding rate for the LoRa modulation.
lora_spread_factors_t
Represents the possible spreading factor values in LoRa packet types.
int8_t rssi_sync
The RSSI measured on last packet.
Preamble detection length 24 bits.
radio_whitening_mode_t
Radio whitening mode activated or deactivated.
No correlator turned on, i.e. do not search for SyncWord.
The radio is in receive duty cycle mode.
radio_operating_mode_t
Represents the operating mode the radio is actually running.
The radio is in frequency synthesis mode.
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.
Represents the packet status for every packet type.
cad_exit_modes_t
Represents the Channel Activity Detection actions after the CAD operation is finished.
lora_bandwidths_t
Represents the bandwidth values for LoRa packet type.
radio_mod_shaping_t
Represents the modulation shaping parameter.
radio_address_filter_t
Represents the possible combinations of SyncWord correlators activated.
uint8_t syncword_length
The synchronization word length for GFSK packet type.
struct packet_params::@15::@16 gfsk
Holds the GFSK packet parameters.
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...
The packet is known on both sides, no header included in the packet.
The radio is in standby mode with RC oscillator.
The radio is in deep-sleep mode.
enum radio_crc_types_e radio_crc_types_t
Represents the CRC length.
int8_t rssi_pkt
The RSSI of the last packet.
uint16_t preamble_length
The preamble Tx length for GFSK packet type in bit.
lora_pkt_length_t header_type
If the header is explicit, it will be transmitted in the LoRa packet. If the header is implicit...
The radio is in receive mode.
Preamble detection length off.
radio_modems_t modem_type
Packet to which the packet status are referring to.
radio_preamble_detection_t
Represents the preamble length used to detect the packet on Rx side.
lora_spread_factors_t spreading_factor
Spreading Factor for the LoRa modulation.
Represents a calibration configuration.
uint8_t payload_length
Size of the payload in the GFSK packet.
radio_regulator_mode_t
Declares the power regulation used to power the device.
int8_t rssi_avg
The averaged RSSI.
struct packet_params packet_params_t
The type describing the packet parameters for every packet types.
radio_pkt_length_t
Radio packet length mode.
The radio is in transmit mode.
struct packet_params::@15::@17 lora
Holds the LoRa packet parameters.
struct packet_params::@15 params
Holds the packet parameters structure.
The packet is on variable size, header included.
lora_crc_mode_t crc_mode
Size of CRC block in LoRa packet.
radio_address_filter_t addr_comp
Activated SyncWord correlators.
radio_preamble_detection_t preamble_min_detect
The preamble Rx length minimal for GFSK packet type.
irq_error_t
Structure describing the error codes for callback functions.
The packet is on variable size, header included.
lora_pkt_length_t
Holds the lengths mode of a LoRa packet type.
radio_modems_t modem_type
Packet to which the packet status are referring to.
radio_modems_t modem_type
Packet to which the packet parameters are referring to.
radio_standby_mode_t
Declares the oscillator in use while in standby mode.
The radio is in standby mode with XOSC oscillator.
Represents the Rx internal counters values when GFSK or LoRa packet type is used. ...
radio_modems_t modem_type
Packet to which the modulation parameters are referring to.
Structure describing the radio status.
The type describing the modulation parameters for every packet types.