11 #ifndef MBED_LORA_RADIO_DRV_STM32WL_RADIO_DRIVER_H_ 12 #define MBED_LORA_RADIO_DRV_STM32WL_RADIO_DRIVER_H_ 14 #include "LoRaRadio.h" 20 #define RBI_CONF_RFO_LP_HP 0 21 #define RBI_CONF_RFO_LP 1 22 #define RBI_CONF_RFO_HP 2 27 RBI_SWITCH_RFO_LP = 2,
28 RBI_SWITCH_RFO_HP = 3,
37 #define IS_TCXO_SUPPORTED 1U 42 #define SMPS_DRIVE_SETTING_DEFAULT SMPS_DRV_40 49 #define SMPS_DRIVE_SETTING_MAX SMPS_DRV_60 54 #define REG_XTA_TRIM 0x0911 59 #define REG_XTB_TRIM 0x0912 64 #define REG_OCP 0x08E7 69 #define REG_TX_CLAMP 0x08D8 77 #define SUBGHZ_GBSYNCR REG_BIT_SYNC 79 #define SUBGHZ_GPKTCTL1AR REG_LR_WHITSEEDBASEADDR_MSB 81 #define SUBGHZ_GWHITEINIRL REG_LR_WHITSEEDBASEADDR_LSB 83 #define SUBGHZ_GCRCINIRH REG_LR_CRCSEEDBASEADDR 85 #define SUBGHZ_GCRCINIRL 0x06BD 87 #define SUBGHZ_GCRCPOLRH REG_LR_CRCPOLYBASEADDR 89 #define SUBGHZ_GCRCPOLRL 0x06BF 91 #define SUBGHZ_GSYNCR7 REG_LR_SYNCWORDBASEADDRESS 93 #define SUBGHZ_GSYNCR6 0x06C1 95 #define SUBGHZ_GSYNCR5 0x06C2 97 #define SUBGHZ_GSYNCR4 0x06C3 99 #define SUBGHZ_GSYNCR3 0x06C4 101 #define SUBGHZ_GSYNCR2 0x06C5 103 #define SUBGHZ_GSYNCR1 0x06C6 105 #define SUBGHZ_GSYNCR0 0x06C7 107 #define SUBGHZ_LSYNCRH REG_LR_SYNCWORD 109 #define SUBGHZ_LSYNCRL 0x0741 111 #define SUBGHZ_RNGR3 RANDOM_NUMBER_GENERATORBASEADDR 113 #define SUBGHZ_RNGR2 0x081A 115 #define SUBGHZ_RNGR1 0x081B 117 #define SUBGHZ_RNGR0 0x081C 119 #define SUBGHZ_RXGAINCR REG_RX_GAIN 121 #define SUBGHZ_PAOCPR REG_OCP 123 #define SUBGHZ_HSEINTRIMR REG_XTA_TRIM 125 #define SUBGHZ_HSEOUTTRIMR REG_XTB_TRIM 127 #define SUBGHZ_SMPSC0R 0x0916 129 #define SUBGHZ_PCR 0x091A 131 #define SUBGHZ_SMPSC2R 0x0923 133 #define SMPS_CLK_DET_ENABLE ((uint8_t) (1<<6)) 135 #define SMPS_DRV_20 ((uint8_t) ((0x0)<<1)) 136 #define SMPS_DRV_40 ((uint8_t) ((0x1)<<1)) 137 #define SMPS_DRV_60 ((uint8_t) ((0x2)<<1)) 138 #define SMPS_DRV_100 ((uint8_t) ((0x3)<<1)) 139 #define SMPS_DRV_MASK ((uint8_t) ((0x3)<<1)) 146 #define XTAL_FREQ 32000000 147 #define FREQ_DIV 33554432 148 #define FREQ_STEP 0.95367431640625 // ((double)(XTAL_FREQ / (double)FREQ_DIV)) 149 #define FREQ_ERR 0.47683715820312 155 #define MATCHING_FREQ_915 0 156 #define MATCHING_FREQ_780 1 157 #define MATCHING_FREQ_490 2 158 #define MATCHING_FREQ_434 3 159 #define MATCHING_FREQ_280 4 160 #define MATCHING_FREQ_169 5 161 #define MATCHING_FREQ_868 6 166 #define AUTO_RX_TX_OFFSET 2 171 #define CRC_IBM_SEED 0xFFFF 176 #define CRC_CCITT_SEED 0x1D0F 181 #define CRC_POLYNOMIAL_IBM 0x8005 186 #define CRC_POLYNOMIAL_CCITT 0x1021 192 #define REG_LR_CRCSEEDBASEADDR 0x06BC 197 #define REG_LR_CRCPOLYBASEADDR 0x06BE 202 #define REG_LR_WHITSEEDBASEADDR_MSB 0x06B8 203 #define REG_LR_WHITSEEDBASEADDR_LSB 0x06B9 208 #define REG_LR_PACKETPARAMS 0x0704 213 #define REG_LR_PAYLOADLENGTH 0x0702 218 #define REG_LR_SYNCWORDBASEADDRESS 0x06C0 223 #define REG_LR_SYNCWORD 0x0740 228 #define LORA_MAC_PRIVATE_SYNCWORD 0x1424 233 #define LORA_MAC_PUBLIC_SYNCWORD 0x3444 238 #define RANDOM_NUMBER_GENERATORBASEADDR 0x0819 243 #define REG_RX_GAIN 0x08AC 248 #define REG_FREQUENCY_ERRORBASEADDR 0x076B 253 #define REG_XTA_TRIM 0x0911 258 #define REG_OCP 0x08E7 266 uint16_t packet_received;
268 uint16_t length_error;
276 uint8_t rc64k_enable : 1;
277 uint8_t rc13m_enable : 1;
278 uint8_t pll_enable : 1;
279 uint8_t adc_pulse_enable : 1;
280 uint8_t adc_bulkN_enable : 1;
281 uint8_t adc_bulkP_enable : 1;
282 uint8_t img_enable : 1;
295 uint8_t rc64k_calib : 1;
296 uint8_t rc13m_calib : 1;
297 uint8_t pll_calib : 1;
298 uint8_t adc_calib : 1;
299 uint8_t img_calib : 1;
300 uint8_t xosc_start : 1;
301 uint8_t pll_lock : 1;
302 uint8_t buck_start : 1;
304 uint8_t reserved : 7;
352 RADIO_RAMP_10_US = 0x00,
353 RADIO_RAMP_20_US = 0x01,
354 RADIO_RAMP_40_US = 0x02,
355 RADIO_RAMP_80_US = 0x03,
356 RADIO_RAMP_200_US = 0x04,
357 RADIO_RAMP_800_US = 0x05,
358 RADIO_RAMP_1700_US = 0x06,
359 RADIO_RAMP_3400_US = 0x07,
366 LORA_CAD_01_SYMBOL = 0x00,
367 LORA_CAD_02_SYMBOL = 0x01,
368 LORA_CAD_04_SYMBOL = 0x02,
369 LORA_CAD_08_SYMBOL = 0x03,
370 LORA_CAD_16_SYMBOL = 0x04,
377 LORA_CAD_ONLY = 0x00,
386 MOD_SHAPING_OFF = 0x00,
387 MOD_SHAPING_G_BT_03 = 0x08,
388 MOD_SHAPING_G_BT_05 = 0x09,
389 MOD_SHAPING_G_BT_07 = 0x0A,
390 MOD_SHAPING_G_BT_1 = 0x0B,
450 const uint8_t lora_bandwidths [] = {LORA_BW_125, LORA_BW_250, LORA_BW_500};
478 RADIO_ADDRESSCOMP_FILT_NODE = 0x01,
479 RADIO_ADDRESSCOMP_FILT_NODE_BROAD = 0x02,
493 typedef enum radio_crc_types_e {
495 RADIO_CRC_1_BYTES = 0x00,
496 RADIO_CRC_2_BYTES = 0x02,
497 RADIO_CRC_1_BYTES_INV = 0x04,
498 RADIO_CRC_2_BYTES_INV = 0x06,
499 RADIO_CRC_2_BYTES_IBM = 0xF1,
500 RADIO_CRC_2_BYTES_CCIT = 0xF2,
507 RADIO_DC_FREE_OFF = 0x00,
508 RADIO_DC_FREEWHITENING = 0x01,
533 LORA_IQ_NORMAL = 0x00,
534 LORA_IQ_INVERTED = 0x01,
541 TCXO_CTRL_1_6V = 0x00,
542 TCXO_CTRL_1_7V = 0x01,
543 TCXO_CTRL_1_8V = 0x02,
544 TCXO_CTRL_2_2V = 0x03,
545 TCXO_CTRL_2_4V = 0x04,
546 TCXO_CTRL_2_7V = 0x05,
547 TCXO_CTRL_3_0V = 0x06,
548 TCXO_CTRL_3_3V = 0x07,
557 IRQ_RADIO_NONE = 0x0000,
558 IRQ_TX_DONE = 0x0001,
559 IRQ_RX_DONE = 0x0002,
560 IRQ_PREAMBLE_DETECTED = 0x0004,
561 IRQ_SYNCWORD_VALID = 0x0008,
562 IRQ_HEADER_VALID = 0x0010,
563 IRQ_HEADER_ERROR = 0x0020,
564 IRQ_CRC_ERROR = 0x0040,
565 IRQ_CAD_DONE = 0x0080,
566 IRQ_CAD_ACTIVITY_DETECTED = 0x0100,
567 IRQ_RX_TX_TIMEOUT = 0x0200,
568 IRQ_RADIO_ALL = 0xFFFF,
579 uint8_t reserved : 1;
580 uint8_t cmd_status : 3;
581 uint8_t chip_mode : 3;
582 uint8_t cpu_busy : 1;
590 IRQ_HEADER_ERROR_CODE = 0x01,
591 IRQ_SYNCWORD_ERROR_CODE = 0x02,
592 IRQ_CRC_ERROR_CODE = 0x04,
597 IRQ_PBL_DETECT_CODE = 0x01,
598 IRQ_SYNCWORD_VALID_CODE = 0x02,
599 IRQ_HEADER_VALID_CODE = 0x04,
603 IRQ_RX_TIMEOUT = 0x00,
604 IRQ_TX_TIMEOUT = 0x01,
608 RECEPTION_MODE_SINGLE = 0,
609 RECEPTION_MODE_CONTINUOUS,
622 radio_mod_shaping_t modulation_shaping;
624 uint32_t operational_frequency;
628 lora_spread_factors_t spreading_factor;
629 lora_bandwidths_t bandwidth;
631 uint8_t low_datarate_optimization;
632 uint32_t operational_frequency;
654 radio_whitening_mode_t whitening_mode;
684 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.
Represents a calibration configuration.
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_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.
radio_ramp_time_t
Represents the ramping time for power amplifier.
lora_crc_mode_t
Represents the CRC mode for LoRa packet type.
lora_spread_factors_t
Represents the possible spreading factor values in LoRa packet types.
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.
lora_coding_states_t
Represents the coding rate values for LoRa packet type.
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_coding_states_t coding_rate
Coding rate for the LoRa modulation.
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.
uint16_t preamble_length
The preamble Tx length for GFSK packet type in bit.
The radio is in receive mode.
Preamble detection length off.
radio_preamble_detection_t
Represents the preamble length used to detect the packet on Rx side.
uint8_t payload_length
Size of the payload in the GFSK packet.
RFState_t
Radio driver internal state machine states definition.
radio_regulator_mode_t
Declares the power regulation used to power the device.
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 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. ...
Structure describing the radio status.
The type describing the modulation parameters for every packet types.