35 #ifndef MBED_LORA_RADIO_DRV_STM32WL_LORARADIO_H_ 36 #define MBED_LORA_RADIO_DRV_STM32WL_LORARADIO_H_ 38 #include "platform/mbed_critical.h" 39 #include "drivers/DigitalOut.h" 40 #include "platform/PlatformMutex.h" 41 #include "lorawan/LoRaRadio.h" 48 #ifdef MBED_CONF_STM32WL_LORA_DRIVER_BUFFER_SIZE 49 #define MAX_DATA_BUFFER_SIZE_STM32WL MBED_CONF_STM32WL_LORA_DRIVER_BUFFER_SIZE 51 #define MAX_DATA_BUFFER_SIZE_STM32WL 255 59 STM32WL_LoRaRadio(PinName rf_switch_ctrl1 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL1,
60 PinName rf_switch_ctrl2 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL2,
61 PinName rf_switch_ctrl3 = MBED_CONF_STM32WL_LORA_DRIVER_RF_SWITCH_CTL3);
81 virtual void sleep(
void);
124 uint32_t datarate, uint8_t coderate,
125 uint32_t bandwidth_afc, uint16_t preamble_len,
126 uint16_t symb_timeout,
bool fix_len,
128 bool crc_on,
bool freq_hop_on, uint8_t hop_period,
129 bool iq_inverted,
bool rx_continuous);
161 uint32_t bandwidth, uint32_t datarate,
162 uint8_t coderate, uint16_t preamble_len,
163 bool fix_len,
bool crc_on,
bool freq_hop_on,
164 uint8_t hop_period,
bool iq_inverted, uint32_t timeout);
174 virtual void send(uint8_t *buffer, uint8_t size);
210 virtual uint32_t
random(
void);
265 int16_t rssi_threshold,
266 uint32_t max_carrier_sense_time);
292 virtual void lock(
void);
297 virtual void unlock(
void);
299 static void HAL_SUBGHZ_TxCpltCallback(
void);
300 static void HAL_SUBGHZ_RxCpltCallback(
void);
301 static void HAL_SUBGHZ_CRCErrorCallback(
void);
302 static void HAL_SUBGHZ_CADStatusCallback(
void);
303 static void HAL_SUBGHZ_RxTxTimeoutCallback(
void);
306 static void clear_irq_status(uint16_t irq);
307 static uint16_t get_irq_status(
void);
308 static void read_opmode_command(uint8_t cmd, uint8_t *buffer, uint16_t size);
309 static void write_opmode_command(uint8_t cmd, uint8_t *buffer, uint16_t size);
310 static void read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset);
311 static void get_rx_buffer_status(uint8_t *payload_len, uint8_t *rx_buffer_ptr);
313 static uint8_t get_modem();
314 static uint8_t read_register(uint16_t addr);
329 void SUBGRF_SetTcxoMode(radio_TCXO_ctrl_voltage_t voltage, uint32_t timeout);
330 void set_device_ready(
void);
332 uint8_t get_fsk_bw_reg_val(uint32_t bandwidth);
333 void write_to_register(uint16_t addr, uint8_t data);
334 void write_to_register(uint16_t addr, uint8_t *data, uint8_t size);
336 void read_register(uint16_t addr, uint8_t *buffer, uint8_t size);
337 void write_fifo(uint8_t *buffer, uint8_t size);
339 void rf_irq_task(
void);
340 void set_modem(uint8_t modem);
343 uint8_t get_frequency_support(
void);
349 void set_cad_params(lora_cad_symbols_t nb_symbols, uint8_t det_peak,
350 uint8_t det_min, cad_exit_modes_t exit_mode,
352 void set_buffer_base_addr(uint8_t tx_base_addr, uint8_t rx_base_addr);
355 void clear_device_errors(
void);
357 void set_crc_seed(uint16_t seed);
358 void set_crc_polynomial(uint16_t polynomial);
359 void set_whitening_seed(uint16_t seed);
360 void set_pa_config(uint8_t pa_DC, uint8_t hp_max, uint8_t device_type,
362 void set_tx_power(int8_t power);
363 void calibrate_image(uint32_t freq);
364 void configure_dio_irq(uint16_t irq_mask, uint16_t dio1_mask,
365 uint16_t dio2_mask, uint16_t dio3_mask);
366 void cold_start_wakeup();
368 void SUBGRF_SetSwitch(uint8_t paSelect,
RFState_t rxtx);
369 uint8_t SUBGRF_SetRfTxPower(int8_t power);
370 void SUBGRF_SetTxParams(uint8_t paSelect, int8_t power, radio_ramp_time_t rampTime);
371 void Radio_SMPS_Set(uint8_t level);
372 void set_antenna_switch(RBI_Switch_TypeDef state);
373 uint32_t RadioGetWakeupTime(
void);
376 uint8_t _standby_mode;
378 uint8_t _reception_mode;
379 uint32_t _tx_timeout;
380 uint32_t _rx_timeout;
381 uint8_t _rx_timeout_in_symbols;
383 uint8_t _antSwitchPaSelect;
384 bool _image_calibrated;
385 bool _force_image_calibration;
386 bool _network_mode_public;
virtual uint8_t get_status(void)
Get radio status.
virtual bool perform_carrier_sense(radio_modems_t modem, uint32_t freq, int16_t rssi_threshold, uint32_t max_carrier_sense_time)
Perform carrier sensing.
The type describing the packet parameters for every packet types.
virtual void receive(uint32_t timeout)
For backwards compatibility.
virtual void start_cad(void)
Sets the radio in CAD mode.
STM32WL driver implementation.
virtual void receive(void)
Sets the radio to receive.
virtual void send(uint8_t *buffer, uint8_t size)
Sends the buffer of size.
Represents the possible radio system error states.
virtual void init_radio(radio_events_t *events)
Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps if any...
enum modem_type radio_modems_t
Type of modem.
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max)
Sets the maximum payload length.
virtual void lock(void)
Acquire exclusive access.
Represents the packet status for every packet type.
virtual void radio_reset()
Resets the radio module.
Reporting functions for upper layers.
virtual void set_channel(uint32_t freq)
Sets the carrier frequency.
virtual void standby(void)
Sets the radio in standby mode.
virtual void set_rx_config(radio_modems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidth_afc, uint16_t preamble_len, uint16_t symb_timeout, bool fix_len, uint8_t payload_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, bool rx_continuous)
Sets the reception parameters.
virtual void unlock(void)
Release exclusive access.
RFState_t
Radio driver internal state machine states definition.
virtual void set_public_network(bool enable)
Sets the network to public or private.
virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preamble_len, bool fix_len, bool crc_on, bool freq_hop_on, uint8_t hop_period, bool iq_inverted, uint32_t timeout)
Sets the transmission parameters.
A digital output, used for setting the state of a pin.
virtual bool check_rf_frequency(uint32_t frequency)
Check if the given RF is in range.
virtual void sleep(void)
Put the RF module in sleep mode.
virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
Computes the packet time on air for the given payload.
Interface for the radios, containing the main functions that a radio needs, and five callback functio...
virtual uint32_t random(void)
Generates a 32 bits random value based on the RSSI readings.
The type describing the modulation parameters for every packet types.
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time)
Sets the radio in continuous wave transmission mode.