[LR11x0] Implemented RF switch control

This commit is contained in:
jgromes 2024-05-26 17:03:45 +02:00
parent 3af427fefb
commit a465f64969
12 changed files with 320 additions and 78 deletions

View file

@ -8,6 +8,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
Using blocking CAD is not recommended, as it will lead
to significant amount of timeouts, inefficient use of processor
time and can some miss packets!
@ -30,13 +34,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -8,6 +8,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem
@ -25,13 +29,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -13,6 +13,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
Using blocking receive is not recommended, as it will lead
to significant amount of timeouts, inefficient use of processor
time and can some miss packets!
@ -35,13 +39,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -14,6 +14,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem
@ -31,13 +35,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -9,6 +9,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem
@ -26,13 +30,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();
@ -44,17 +69,6 @@ void setup() {
delay(1000);
while (true);
}
// some modules have an external RF switch
// controlled via two pins (RX enable, TX enable)
// to enable automatic control of the switch,
// call the following method
// RX enable: 4
// TX enable: 5
/*
radio.setRfSwitchPins(4, 5);
*/
}
// counter to keep track of transmitted packets

View file

@ -10,6 +10,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem
@ -27,9 +31,26 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
// save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE;
@ -37,6 +58,10 @@ int transmissionState = RADIOLIB_ERR_NONE;
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -7,6 +7,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
Using blocking scan is not recommended, as depending
on the scan settings, the program may be blocked
for several seconds! Instead, interrupt scan is recommended.
@ -28,13 +32,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -7,6 +7,10 @@
Other modules from LR11x0 family can also be used.
This example assumes Seeed Studio Wio WM1110 is used.
For other LR11x0 modules, some configuration such as
RF switch control may have to be adjusted.
Using blocking scan is not recommended, as depending
on the scan settings, the program may be blocked
for several seconds! Instead, interrupt scan is recommended.
@ -28,13 +32,34 @@
// BUSY pin: 9
LR1110 radio = new Module(10, 2, 3, 9);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//LR1110 radio = RadioShield.ModuleA;
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5, 6, 7 and 8 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_LR11X0_DIO7, RADIOLIB_LR11X0_DIO8,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7 DIO8
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW, LOW, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH, LOW, LOW } },
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW, HIGH, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, HIGH } },
END_OF_MODE_TABLE,
};
void setup() {
Serial.begin(9600);
// set RF switch control configuration
// this has to be done prior to calling begin()
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// initialize LR1110 with default settings
Serial.print(F("[LR1110] Initializing ... "));
int state = radio.begin();

View file

@ -1385,6 +1385,28 @@ int16_t LR11x0::setRxBoostedGainMode(bool en) {
return(this->SPIcommand(RADIOLIB_LR11X0_CMD_SET_RX_BOOSTED, true, buff, sizeof(buff)));
}
void LR11x0::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
// find which pins are used
uint8_t enable = 0;
for(size_t i = 0; i < Module::RFSWITCH_MAX_PINS; i++) {
if((pins[i] == RADIOLIB_NC) || (pins[i] > RADIOLIB_LR11X0_DIO10)) {
continue;
}
enable |= 1UL << pins[i];
}
// now get the configuration
uint8_t modes[7] = { 0 };
for(size_t i = 0; i < 7; i++) {
for(size_t j = 0; j < Module::RFSWITCH_MAX_PINS; j++) {
modes[i] |= (table[i].values[j] > 0) ? (1UL << j) : 0;
}
}
// set it
this->setDioAsRfSwitch(enable, modes[0], modes[1], modes[2], modes[3], modes[4], modes[5], modes[6]);
}
int16_t LR11x0::setLrFhssConfig(uint8_t bw, uint8_t cr, uint8_t hdrCount, uint16_t hopSeed) {
// check active modem
uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE;

View file

@ -240,6 +240,11 @@
#define RADIOLIB_LR11X0_RFSW_DIO8_DISABLED (0x00UL << 3) // 4 0 DIO8 disabled (default)
#define RADIOLIB_LR11X0_RFSW_DIO10_ENABLED (0x01UL << 4) // 4 0 RF switch: DIO10 enabled
#define RADIOLIB_LR11X0_RFSW_DIO10_DISABLED (0x00UL << 4) // 4 0 DIO10 disabled (default)
#define RADIOLIB_LR11X0_DIO5 (0)
#define RADIOLIB_LR11X0_DIO6 (1)
#define RADIOLIB_LR11X0_DIO7 (2)
#define RADIOLIB_LR11X0_DIO8 (3)
#define RADIOLIB_LR11X0_DIO10 (4)
// RADIOLIB_LR11X0_CMD_SET_DIO_IRQ_PARAMS
#define RADIOLIB_LR11X0_IRQ_TX_DONE (0x01UL << 2) // 31 0 interrupt: packet transmitted
@ -710,6 +715,29 @@ class LR11x0: public PhysicalLayer {
*/
explicit LR11x0(Module* mod);
/*!
\brief Custom operation modes for LR11x0.
Needed because LR11x0 has several modems (sub-GHz, 2.4 GHz etc.) in one package
*/
enum OpMode_t {
/*! End of table marker, use \ref END_OF_MODE_TABLE constant instead */
MODE_END_OF_TABLE = Module::MODE_END_OF_TABLE,
/*! Standby/idle mode */
MODE_STBY = Module::MODE_IDLE,
/*! Receive mode */
MODE_RX = Module::MODE_RX,
/*! Low power transmission mode */
MODE_TX = Module::MODE_TX,
/*! High power transmission mode */
MODE_TX_HP,
/*! High frequency transmission mode */
MODE_TX_HF,
/*! GNSS scanning mode */
MODE_GNSS,
/*! WiFi scanning mode */
MODE_WIFI,
};
/*!
\brief Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
*/
@ -1266,6 +1294,9 @@ class LR11x0: public PhysicalLayer {
*/
int16_t setRxBoostedGainMode(bool en);
/*! \copydoc Module::setRfSwitchTable */
void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
/*!
\brief Sets LR-FHSS configuration.
\param bw LR-FHSS bandwidth, one of RADIOLIB_LR11X0_LR_FHSS_BW_* values.