| SX126x-Arduino 2.0.1

radio.h
Go to the documentation of this file.
1
23 #ifndef __RADIO_H__
24 #define __RADIO_H__
25
26 extern "C"
27 {
31 typedef enum
32 {
33 MODEM_FSK = 0,
34 MODEM_LORA,
35 } RadioModems_t;
36
40 typedef enum
41 {
42 RF_IDLE = 0,
43 RF_RX_RUNNING,
44 RF_TX_RUNNING,
45 RF_CAD,
46 } RadioState_t;
47
51 typedef struct
52 {
56 void (*TxDone)(void);
60 void (*TxTimeout)(void);
71 void (*RxDone)(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr);
75 void (*RxTimeout)(void);
79 void (*RxError)(void);
83 void (*PreAmpDetect)(void);
89 void (*FhssChangeChannel)(uint8_t currentChannel);
90
96 void (*CadDone)(bool channelActivityDetected);
97 } RadioEvents_t;
98
102 struct Radio_s
103 {
109 void (*Init)(RadioEvents_t *events);
115 void (*ReInit)(RadioEvents_t *events);
121 RadioState_t (*GetStatus)(void);
127 void (*SetModem)(RadioModems_t modem);
133 void (*SetChannel)(uint32_t freq);
144 bool (*IsChannelFree)(RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t maxCarrierSenseTime);
155 uint32_t (*Random)(void);
195 void (*SetRxConfig)(RadioModems_t modem, uint32_t bandwidth,
196 uint32_t datarate, uint8_t coderate,
197 uint32_t bandwidthAfc, uint16_t preambleLen,
198 uint16_t symbTimeout, bool fixLen,
199 uint8_t payloadLen,
200 bool crcOn, bool freqHopOn, uint8_t hopPeriod,
201 bool iqInverted, bool rxContinuous);
237 void (*SetTxConfig)(RadioModems_t modem, int8_t power, uint32_t fdev,
238 uint32_t bandwidth, uint32_t datarate,
239 uint8_t coderate, uint16_t preambleLen,
240 bool fixLen, bool crcOn, bool freqHopOn,
241 uint8_t hopPeriod, bool iqInverted, uint32_t timeout);
248 bool (*CheckRfFrequency)(uint32_t frequency);
259 uint32_t (*TimeOnAir)(RadioModems_t modem, uint8_t pktLen);
267 void (*Send)(uint8_t *buffer, uint8_t size);
271 void (*Sleep)(void);
275 void (*Standby)(void);
281 void (*Rx)(uint32_t timeout);
285 void (*SetCadParams)(uint8_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, uint8_t cadExitMode, uint32_t cadTimeout);
289 void (*StartCad)(void);
297 void (*SetTxContinuousWave)(uint32_t freq, int8_t power, uint16_t time);
303 int16_t (*Rssi)(RadioModems_t modem);
310 void (*Write)(uint16_t addr, uint8_t data);
317 uint8_t (*Read)(uint16_t addr);
325 void (*WriteBuffer)(uint16_t addr, uint8_t *buffer, uint8_t size);
333 void (*ReadBuffer)(uint16_t addr, uint8_t *buffer, uint8_t size);
340 void (*SetMaxPayloadLength)(RadioModems_t modem, uint8_t max);
348 void (*SetPublicNetwork)(bool enable);
354 uint32_t (*GetWakeupTime)(void);
358 void (*BgIrqProcess)(void);
362 void (*IrqProcess)(void);
363 /*
364 * \brief Process radio irq after CPU wakeup from deep sleep
365 */
366 void (*IrqProcessAfterDeepSleep)(void);
367 /*
368 * The next functions are available only on SX126x radios.
369 */
378 void (*RxBoosted)(uint32_t timeout);
387 void (*SetRxDutyCycle)(uint32_t rxTime, uint32_t sleepTime);
388 };
389
396 extern const struct Radio_s Radio;
397 };
398 #endif // __RADIO_H__
MODEM_FSK
@ MODEM_FSK
Definition: radio.h:33
Radio_s::RxBoosted
void(* RxBoosted)(uint32_t timeout)
Sets the radio in reception mode with Max LNA gain for the given time.
Definition: radio.h:378
Radio_s::GetWakeupTime
uint32_t(* GetWakeupTime)(void)
Gets the time required for the board plus radio to get out of sleep.[ms].
Definition: radio.h:354
Radio_s::SetRxConfig
void(* SetRxConfig)(RadioModems_t modem, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint32_t bandwidthAfc, uint16_t preambleLen, uint16_t symbTimeout, bool fixLen, uint8_t payloadLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, bool rxContinuous)
Sets the reception parameters.
Definition: radio.h:195
Radio_s::CheckRfFrequency
bool(* CheckRfFrequency)(uint32_t frequency)
Checks if the given RF frequency is supported by the hardware.
Definition: radio.h:248
Radio_s::Init
void(* Init)(RadioEvents_t *events)
Initializes the radio.
Definition: radio.h:109
RadioEvents_t
Radio driver callback functions.
Definition: radio.h:52
Radio_s::Write
void(* Write)(uint16_t addr, uint8_t data)
Writes the radio register at the specified address.
Definition: radio.h:310
Radio_s::SetMaxPayloadLength
void(* SetMaxPayloadLength)(RadioModems_t modem, uint8_t max)
Sets the maximum payload length.
Definition: radio.h:340
RF_RX_RUNNING
@ RF_RX_RUNNING
The radio is in reception state.
Definition: radio.h:43
RF_TX_RUNNING
@ RF_TX_RUNNING
The radio is in transmission state.
Definition: radio.h:44
TxTimeout
uint32_t TxTimeout
Definition: radio.cpp:450
Radio_s::SetTxContinuousWave
void(* SetTxContinuousWave)(uint32_t freq, int8_t power, uint16_t time)
Sets the radio in continuous wave transmission mode.
Definition: radio.h:297
Radio_s
Radio driver definition.
Definition: radio.h:103
Radio_s::Rx
void(* Rx)(uint32_t timeout)
Sets the radio in reception mode for the given time.
Definition: radio.h:281
Radio_s::BgIrqProcess
void(* BgIrqProcess)(void)
Process radio irq in background task (nRF52 & ESP32)
Definition: radio.h:358
Radio_s::SetTxConfig
void(* SetTxConfig)(RadioModems_t modem, int8_t power, uint32_t fdev, uint32_t bandwidth, uint32_t datarate, uint8_t coderate, uint16_t preambleLen, bool fixLen, bool crcOn, bool freqHopOn, uint8_t hopPeriod, bool iqInverted, uint32_t timeout)
Sets the transmission parameters.
Definition: radio.h:237
Radio_s::SetPublicNetwork
void(* SetPublicNetwork)(bool enable)
Sets the network to public or private. Updates the sync byte.
Definition: radio.h:348
Radio_s::SetModem
void(* SetModem)(RadioModems_t modem)
Configures the radio with the given modem.
Definition: radio.h:127
Radio
const struct Radio_s Radio
Radio driver.
Definition: radio.cpp:364
RF_CAD
@ RF_CAD
The radio is doing channel activity detection.
Definition: radio.h:45
Radio_s::Read
uint8_t(* Read)(uint16_t addr)
Reads the radio register at the specified address.
Definition: radio.h:317
Radio_s::Random
uint32_t(* Random)(void)
Generates a 32 bits random value based on the RSSI readings.
Definition: radio.h:155
Radio_s::TimeOnAir
uint32_t(* TimeOnAir)(RadioModems_t modem, uint8_t pktLen)
Computes the packet time on air in ms for the given payload.
Definition: radio.h:259
RxTimeout
uint32_t RxTimeout
Definition: radio.cpp:451
Radio_s::SetRxDutyCycle
void(* SetRxDutyCycle)(uint32_t rxTime, uint32_t sleepTime)
Sets the Rx duty cycle management parameters.
Definition: radio.h:387
RadioState_t
RadioState_t
Definition: radio.h:41
Radio_s::Standby
void(* Standby)(void)
Sets the radio in standby mode.
Definition: radio.h:275
RF_IDLE
@ RF_IDLE
The radio is idle.
Definition: radio.h:42
Radio_s::WriteBuffer
void(* WriteBuffer)(uint16_t addr, uint8_t *buffer, uint8_t size)
Writes multiple radio registers starting at address.
Definition: radio.h:325
Radio_s::SetCadParams
void(* SetCadParams)(uint8_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, uint8_t cadExitMode, uint32_t cadTimeout)
Set Channel Activity Detection parameters.
Definition: radio.h:285
Radio_s::IrqProcess
void(* IrqProcess)(void)
Process radio irq.
Definition: radio.h:362
Radio_s::IrqProcessAfterDeepSleep
void(* IrqProcessAfterDeepSleep)(void)
Definition: radio.h:366
Radio_s::ReadBuffer
void(* ReadBuffer)(uint16_t addr, uint8_t *buffer, uint8_t size)
Reads multiple radio registers starting at address.
Definition: radio.h:333
Radio_s::Rssi
int16_t(* Rssi)(RadioModems_t modem)
Reads the current RSSI value.
Definition: radio.h:303
RadioModems_t
RadioModems_t
Definition: radio.h:32
Radio_s::Send
void(* Send)(uint8_t *buffer, uint8_t size)
Sends the buffer of size. Prepares the packet to be sent and sets the radio in transmission.
Definition: radio.h:267
Radio_s::Sleep
void(* Sleep)(void)
Sets the radio in sleep mode.
Definition: radio.h:271
Radio_s::StartCad
void(* StartCad)(void)
Start a Channel Activity Detection.
Definition: radio.h:289
MODEM_LORA
@ MODEM_LORA
Definition: radio.h:34
Radio_s::GetStatus
RadioState_t(* GetStatus)(void)
Definition: radio.h:121
Radio_s::ReInit
void(* ReInit)(RadioEvents_t *events)
Re-Initializes the radio after CPU wakeup from deep sleep.
Definition: radio.h:115
Radio_s::SetChannel
void(* SetChannel)(uint32_t freq)
Sets the channel frequency.
Definition: radio.h:133
Radio_s::IsChannelFree
bool(* IsChannelFree)(RadioModems_t modem, uint32_t freq, int16_t rssiThresh, uint32_t maxCarrierSenseTime)
Checks if the channel is free for the given time.
Definition: radio.h:144