25 #ifndef MBED_LORA_RADIO_DRV_SX126X_LORARADIO_H_ 26 #define MBED_LORA_RADIO_DRV_SX126X_LORARADIO_H_ 30 #include "mbed_critical.h" 32 #include "InterruptIn.h" 33 #include "DigitalOut.h" 34 #include "DigitalInOut.h" 35 #include "DigitalIn.h" 38 #include "platform/PlatformMutex.h" 39 #ifdef MBED_CONF_RTOS_PRESENT 40 #include "rtos/Thread.h" 41 #include "rtos/ThisThread.h" 43 #include "sx126x_ds.h" 44 #include "lorawan/LoRaRadio.h" 46 #ifdef MBED_CONF_SX126X_LORA_DRIVER_BUFFER_SIZE 47 #define MAX_DATA_BUFFER_SIZE_SX126X MBED_CONF_SX126X_LORA_DRIVER_BUFFER_SIZE 49 #define MAX_DATA_BUFFER_SIZE_SX126X 255 63 PinName device_select,
64 PinName crystal_select,
85 virtual void sleep(
void);
128 uint32_t datarate, uint8_t coderate,
129 uint32_t bandwidth_afc, uint16_t preamble_len,
130 uint16_t symb_timeout,
bool fix_len,
132 bool crc_on,
bool freq_hop_on, uint8_t hop_period,
133 bool iq_inverted,
bool rx_continuous);
165 uint32_t bandwidth, uint32_t datarate,
166 uint8_t coderate, uint16_t preamble_len,
167 bool fix_len,
bool crc_on,
bool freq_hop_on,
168 uint8_t hop_period,
bool iq_inverted, uint32_t timeout);
178 virtual void send(uint8_t *buffer, uint8_t size);
205 virtual uint32_t
random(
void);
260 int16_t rssi_threshold,
261 uint32_t max_carrier_sense_time);
287 virtual void lock(
void);
292 virtual void unlock(
void);
327 uint8_t _data_buffer[MAX_DATA_BUFFER_SIZE_SX126X];
329 #ifdef MBED_CONF_RTOS_PRESENT 339 void read_opmode_command(uint8_t cmd, uint8_t *buffer, uint16_t size);
340 void write_opmode_command(uint8_t cmd, uint8_t *buffer, uint16_t size);
341 void set_dio2_as_rfswitch_ctrl(uint8_t enable);
342 void set_dio3_as_tcxo_ctrl(radio_TCXO_ctrl_voltage_t voltage, uint32_t timeout);
343 uint8_t get_device_variant(
void);
344 void set_device_ready(
void);
346 uint8_t get_fsk_bw_reg_val(uint32_t bandwidth);
347 void write_to_register(uint16_t addr, uint8_t data);
348 void write_to_register(uint16_t addr, uint8_t *data, uint8_t size);
349 uint8_t read_register(uint16_t addr);
350 void read_register(uint16_t addr, uint8_t *buffer, uint8_t size);
351 void write_fifo(uint8_t *buffer, uint8_t size);
352 void read_fifo(uint8_t *buffer, uint8_t size, uint8_t offset);
353 void rf_irq_task(
void);
354 void set_modem(uint8_t modem);
356 uint16_t get_irq_status(
void);
357 uint8_t get_frequency_support(
void);
363 void handle_dio1_irq();
367 void set_cad_params(lora_cad_symbols_t nb_symbols, uint8_t det_peak,
368 uint8_t det_min, cad_exit_modes_t exit_mode,
370 void set_buffer_base_addr(uint8_t tx_base_addr, uint8_t rx_base_addr);
371 void get_rx_buffer_status(uint8_t *payload_len, uint8_t *rx_buffer_ptr);
374 void clear_device_errors(
void);
375 void clear_irq_status(uint16_t irq);
376 void set_crc_seed(uint16_t seed);
377 void set_crc_polynomial(uint16_t polynomial);
378 void set_whitening_seed(uint16_t seed);
379 void set_pa_config(uint8_t pa_DC, uint8_t hp_max, uint8_t device_type,
381 void set_tx_power(int8_t power);
382 void calibrate_image(uint32_t freq);
383 void configure_dio_irq(uint16_t irq_mask, uint16_t dio1_mask,
384 uint16_t dio2_mask, uint16_t dio3_mask);
385 void cold_start_wakeup();
388 uint8_t _active_modem;
389 uint8_t _standby_mode;
390 uint8_t _operation_mode;
391 uint8_t _reception_mode;
392 uint32_t _tx_timeout;
393 uint32_t _rx_timeout;
394 uint8_t _rx_timeout_in_symbols;
396 bool _image_calibrated;
397 bool _force_image_calibration;
398 bool _network_mode_public;
virtual void set_channel(uint32_t freq)
Sets the carrier frequency.
The Thread class allow defining, creating, and controlling thread functions in the system...
The type describing the packet parameters for every packet types.
virtual uint8_t get_status(void)
Get radio status.
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max)
Sets the maximum payload length.
Represents the possible radio system error states.
enum modem_type radio_modems_t
Type of modem.
virtual bool check_rf_frequency(uint32_t frequency)
Check if the given RF is in range.
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.
virtual void start_cad(void)
Sets the radio in CAD mode.
virtual void radio_reset()
Resets the radio module.
virtual void unlock(void)
Release exclusive access.
An analog input, used for reading the voltage on a pin.
virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
Computes the packet time on air for the given payload.
A digital input/output, used for setting or reading a bi-directional pin.
Represents the packet status for every packet type.
virtual void init_radio(radio_events_t *events)
Registers radio events with the Mbed LoRaWAN stack and undergoes initialization steps if any...
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.
virtual void send(uint8_t *buffer, uint8_t size)
Sends the buffer of size.
virtual uint32_t random(void)
Generates a 32 bits random value based on the RSSI readings.
Reporting functions for upper layers.
virtual void standby(void)
Sets the radio in standby mode.
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time)
Sets the radio in continuous wave transmission mode.
virtual void set_public_network(bool enable)
Sets the network to public or private.
virtual void receive(void)
Sets the radio to receive.
A digital interrupt input, used to call a function on a rising or falling edge.
A digital output, used for setting the state of a pin.
A SPI Master, used for communicating with SPI slave devices.
virtual void sleep(void)
Put the RF module in sleep mode.
A digital input, used for reading the state of a pin.
virtual void lock(void)
Acquire exclusive access.
Interface for the radios, containing the main functions that a radio needs, and five callback functio...
The type describing the modulation parameters for every packet types.
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.