11#ifndef MBED_LORA_RADIO_DRV_STM32WL_RADIO_DRIVER_H_
12#define MBED_LORA_RADIO_DRV_STM32WL_RADIO_DRIVER_H_
20#define RBI_CONF_RFO_LP_HP 0
21#define RBI_CONF_RFO_LP 1
22#define RBI_CONF_RFO_HP 2
31#define RBI_CONF_RFO_HP_LPFIX 3
36 RBI_SWITCH_RFO_LP = 2,
37 RBI_SWITCH_RFO_HP = 3,
46#define IS_TCXO_SUPPORTED 1U
51#define SMPS_DRIVE_SETTING_DEFAULT SMPS_DRV_40
58#define SMPS_DRIVE_SETTING_MAX SMPS_DRV_60
63#define REG_XTA_TRIM 0x0911
68#define REG_XTB_TRIM 0x0912
78#define REG_TX_CLAMP 0x08D8
86#define SUBGHZ_GBSYNCR REG_BIT_SYNC
88#define SUBGHZ_GPKTCTL1AR REG_LR_WHITSEEDBASEADDR_MSB
90#define SUBGHZ_GWHITEINIRL REG_LR_WHITSEEDBASEADDR_LSB
92#define SUBGHZ_GCRCINIRH REG_LR_CRCSEEDBASEADDR
94#define SUBGHZ_GCRCINIRL 0x06BD
96#define SUBGHZ_GCRCPOLRH REG_LR_CRCPOLYBASEADDR
98#define SUBGHZ_GCRCPOLRL 0x06BF
100#define SUBGHZ_GSYNCR7 REG_LR_SYNCWORDBASEADDRESS
102#define SUBGHZ_GSYNCR6 0x06C1
104#define SUBGHZ_GSYNCR5 0x06C2
106#define SUBGHZ_GSYNCR4 0x06C3
108#define SUBGHZ_GSYNCR3 0x06C4
110#define SUBGHZ_GSYNCR2 0x06C5
112#define SUBGHZ_GSYNCR1 0x06C6
114#define SUBGHZ_GSYNCR0 0x06C7
116#define SUBGHZ_LSYNCRH REG_LR_SYNCWORD
118#define SUBGHZ_LSYNCRL 0x0741
120#define SUBGHZ_RNGR3 RANDOM_NUMBER_GENERATORBASEADDR
122#define SUBGHZ_RNGR2 0x081A
124#define SUBGHZ_RNGR1 0x081B
126#define SUBGHZ_RNGR0 0x081C
128#define SUBGHZ_RXGAINCR REG_RX_GAIN
130#define SUBGHZ_PAOCPR REG_OCP
132#define SUBGHZ_HSEINTRIMR REG_XTA_TRIM
134#define SUBGHZ_HSEOUTTRIMR REG_XTB_TRIM
136#define SUBGHZ_SMPSC0R 0x0916
138#define SUBGHZ_PCR 0x091A
140#define SUBGHZ_SMPSC2R 0x0923
142#define SMPS_CLK_DET_ENABLE ((uint8_t) (1<<6))
144#define SMPS_DRV_20 ((uint8_t) ((0x0)<<1))
145#define SMPS_DRV_40 ((uint8_t) ((0x1)<<1))
146#define SMPS_DRV_60 ((uint8_t) ((0x2)<<1))
147#define SMPS_DRV_100 ((uint8_t) ((0x3)<<1))
148#define SMPS_DRV_MASK ((uint8_t) ((0x3)<<1))
155#define XTAL_FREQ 32000000
156#define FREQ_DIV 33554432
157#define FREQ_STEP 0.95367431640625
158#define FREQ_ERR 0.47683715820312
164#define MATCHING_FREQ_915 0
165#define MATCHING_FREQ_780 1
166#define MATCHING_FREQ_490 2
167#define MATCHING_FREQ_434 3
168#define MATCHING_FREQ_280 4
169#define MATCHING_FREQ_169 5
170#define MATCHING_FREQ_868 6
175#define AUTO_RX_TX_OFFSET 2
180#define CRC_IBM_SEED 0xFFFF
185#define CRC_CCITT_SEED 0x1D0F
190#define CRC_POLYNOMIAL_IBM 0x8005
195#define CRC_POLYNOMIAL_CCITT 0x1021
201#define REG_LR_CRCSEEDBASEADDR 0x06BC
206#define REG_LR_CRCPOLYBASEADDR 0x06BE
211#define REG_LR_WHITSEEDBASEADDR_MSB 0x06B8
212#define REG_LR_WHITSEEDBASEADDR_LSB 0x06B9
217#define REG_LR_PACKETPARAMS 0x0704
222#define REG_LR_PAYLOADLENGTH 0x0702
227#define REG_LR_SYNCWORDBASEADDRESS 0x06C0
232#define REG_LR_SYNCWORD 0x0740
237#define LORA_MAC_PRIVATE_SYNCWORD 0x1424
242#define LORA_MAC_PUBLIC_SYNCWORD 0x3444
247#define RANDOM_NUMBER_GENERATORBASEADDR 0x0819
252#define REG_RX_GAIN 0x08AC
257#define REG_FREQUENCY_ERRORBASEADDR 0x076B
262#define REG_XTA_TRIM 0x0911
267#define REG_OCP 0x08E7
275 uint16_t packet_received;
277 uint16_t length_error;
291 uint8_t img_enable : 1;
304 uint8_t rc64k_calib : 1;
305 uint8_t rc13m_calib : 1;
306 uint8_t pll_calib : 1;
307 uint8_t adc_calib : 1;
308 uint8_t img_calib : 1;
309 uint8_t xosc_start : 1;
310 uint8_t pll_lock : 1;
311 uint8_t buck_start : 1;
313 uint8_t reserved : 7;
361 RADIO_RAMP_10_US = 0x00,
362 RADIO_RAMP_20_US = 0x01,
363 RADIO_RAMP_40_US = 0x02,
364 RADIO_RAMP_80_US = 0x03,
365 RADIO_RAMP_200_US = 0x04,
366 RADIO_RAMP_800_US = 0x05,
367 RADIO_RAMP_1700_US = 0x06,
368 RADIO_RAMP_3400_US = 0x07,
375 LORA_CAD_01_SYMBOL = 0x00,
376 LORA_CAD_02_SYMBOL = 0x01,
377 LORA_CAD_04_SYMBOL = 0x02,
378 LORA_CAD_08_SYMBOL = 0x03,
379 LORA_CAD_16_SYMBOL = 0x04,
386 LORA_CAD_ONLY = 0x00,
395 MOD_SHAPING_OFF = 0x00,
396 MOD_SHAPING_G_BT_03 = 0x08,
397 MOD_SHAPING_G_BT_05 = 0x09,
398 MOD_SHAPING_G_BT_07 = 0x0A,
399 MOD_SHAPING_G_BT_1 = 0x0B,
459const uint8_t lora_bandwidths [] = {LORA_BW_125, LORA_BW_250, LORA_BW_500};
487 RADIO_ADDRESSCOMP_FILT_NODE = 0x01,
488 RADIO_ADDRESSCOMP_FILT_NODE_BROAD = 0x02,
504 RADIO_CRC_1_BYTES = 0x00,
505 RADIO_CRC_2_BYTES = 0x02,
506 RADIO_CRC_1_BYTES_INV = 0x04,
507 RADIO_CRC_2_BYTES_INV = 0x06,
508 RADIO_CRC_2_BYTES_IBM = 0xF1,
509 RADIO_CRC_2_BYTES_CCIT = 0xF2,
516 RADIO_DC_FREE_OFF = 0x00,
517 RADIO_DC_FREEWHITENING = 0x01,
542 LORA_IQ_NORMAL = 0x00,
543 LORA_IQ_INVERTED = 0x01,
550 TCXO_CTRL_1_6V = 0x00,
551 TCXO_CTRL_1_7V = 0x01,
552 TCXO_CTRL_1_8V = 0x02,
553 TCXO_CTRL_2_2V = 0x03,
554 TCXO_CTRL_2_4V = 0x04,
555 TCXO_CTRL_2_7V = 0x05,
556 TCXO_CTRL_3_0V = 0x06,
557 TCXO_CTRL_3_3V = 0x07,
566 IRQ_RADIO_NONE = 0x0000,
567 IRQ_TX_DONE = 0x0001,
568 IRQ_RX_DONE = 0x0002,
569 IRQ_PREAMBLE_DETECTED = 0x0004,
570 IRQ_SYNCWORD_VALID = 0x0008,
571 IRQ_HEADER_VALID = 0x0010,
572 IRQ_HEADER_ERROR = 0x0020,
573 IRQ_CRC_ERROR = 0x0040,
574 IRQ_CAD_DONE = 0x0080,
575 IRQ_CAD_ACTIVITY_DETECTED = 0x0100,
576 IRQ_RX_TX_TIMEOUT = 0x0200,
577 IRQ_RADIO_ALL = 0xFFFF,
588 uint8_t reserved : 1;
589 uint8_t cmd_status : 3;
590 uint8_t chip_mode : 3;
591 uint8_t cpu_busy : 1;
599 IRQ_HEADER_ERROR_CODE = 0x01,
600 IRQ_SYNCWORD_ERROR_CODE = 0x02,
601 IRQ_CRC_ERROR_CODE = 0x04,
606 IRQ_PBL_DETECT_CODE = 0x01,
607 IRQ_SYNCWORD_VALID_CODE = 0x02,
608 IRQ_HEADER_VALID_CODE = 0x04,
612 IRQ_RX_TIMEOUT = 0x00,
613 IRQ_TX_TIMEOUT = 0x01,
617 RECEPTION_MODE_SINGLE = 0,
618 RECEPTION_MODE_CONTINUOUS,
633 uint32_t operational_frequency;
640 uint8_t low_datarate_optimization;
641 uint32_t operational_frequency;
693 int8_t signal_rssi_pkt;
radio_mod_shaping_t
Represents the modulation shaping parameter.
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.
RFState_t
Radio driver internal state machine states definition.
@ RFSWITCH_TX
The radio is in TX.
@ RFSWITCH_RX
The radio is in RX.
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_OFF
No CRC in use.
lora_coding_states_t
Represents the coding rate values for LoRa packet type.
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.
enum modem_type radio_modems_t
Type of modem.
The type describing the modulation parameters for every packet types.
lora_coding_states_t coding_rate
Coding rate for the LoRa modulation.
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,...
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.
Represents the Rx internal counters values when GFSK or LoRa packet type is used.
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_crc_types_e
Represents the CRC length.
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.
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.
Structure describing the radio status.