diff --git a/examples/LR11x0/LR11x0_Channel_Activity_Detection_Blocking/LR11x0_Channel_Activity_Detection_Blocking.ino b/examples/LR11x0/LR11x0_Channel_Activity_Detection_Blocking/LR11x0_Channel_Activity_Detection_Blocking.ino index 171c87de..d6cab7c7 100644 --- a/examples/LR11x0/LR11x0_Channel_Activity_Detection_Blocking/LR11x0_Channel_Activity_Detection_Blocking.ino +++ b/examples/LR11x0/LR11x0_Channel_Activity_Detection_Blocking/LR11x0_Channel_Activity_Detection_Blocking.ino @@ -7,6 +7,10 @@ of LoRa transmission, not just the preamble. 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 @@ -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(); diff --git a/examples/LR11x0/LR11x0_Channel_Activity_Detection_Interrupt/LR11x0_Channel_Activity_Detection_Interrupt.ino b/examples/LR11x0/LR11x0_Channel_Activity_Detection_Interrupt/LR11x0_Channel_Activity_Detection_Interrupt.ino index 90f0c8aa..86578afb 100644 --- a/examples/LR11x0/LR11x0_Channel_Activity_Detection_Interrupt/LR11x0_Channel_Activity_Detection_Interrupt.ino +++ b/examples/LR11x0/LR11x0_Channel_Activity_Detection_Interrupt/LR11x0_Channel_Activity_Detection_Interrupt.ino @@ -1,18 +1,22 @@ /* - RadioLib LR11x0 Channel Activity Detection Example + RadioLib LR11x0 Channel Activity Detection Example - This example uses LR1110 to scan the current LoRa - channel and detect ongoing LoRa transmissions. - Unlike SX127x CAD, LR11x0 can detect any part - of LoRa transmission, not just the preamble. + This example uses LR1110 to scan the current LoRa + channel and detect ongoing LoRa transmissions. + Unlike SX127x CAD, LR11x0 can detect any part + of LoRa transmission, not just the preamble. - Other modules from LR11x0 family can also be used. + 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 + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -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(); diff --git a/examples/LR11x0/LR11x0_GFSK_Modem/LR11x0_GFSK_Modem.ino b/examples/LR11x0/LR11x0_GFSK_Modem/LR11x0_GFSK_Modem.ino index 45dc0507..bc0a59d0 100644 --- a/examples/LR11x0/LR11x0_GFSK_Modem/LR11x0_GFSK_Modem.ino +++ b/examples/LR11x0/LR11x0_GFSK_Modem/LR11x0_GFSK_Modem.ino @@ -1,19 +1,19 @@ /* - RadioLib LR11x0 GFSK Modem Example + RadioLib LR11x0 GFSK Modem Example - This example shows how to use GFSK modem in LR11x0 chips. + This example shows how to use GFSK modem in LR11x0 chips. - NOTE: The sketch below is just a guide on how to use - GFSK modem, so this code should not be run directly! - Instead, modify the other examples to use GFSK - modem and use the appropriate configuration - methods. + NOTE: The sketch below is just a guide on how to use + GFSK modem, so this code should not be run directly! + Instead, modify the other examples to use GFSK + modem and use the appropriate configuration + methods. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---gfsk-modem + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---gfsk-modem - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/LR11x0/LR11x0_LR_FHSS_Modem/LR11x0_LR_FHSS_Modem.ino b/examples/LR11x0/LR11x0_LR_FHSS_Modem/LR11x0_LR_FHSS_Modem.ino index a46d8a82..094fce29 100644 --- a/examples/LR11x0/LR11x0_LR_FHSS_Modem/LR11x0_LR_FHSS_Modem.ino +++ b/examples/LR11x0/LR11x0_LR_FHSS_Modem/LR11x0_LR_FHSS_Modem.ino @@ -1,19 +1,19 @@ /* - RadioLib LR11x0 LR-FHSS Modem Example + RadioLib LR11x0 LR-FHSS Modem Example - This example shows how to use LR-FHSS modem in LR11x0 chips. + This example shows how to use LR-FHSS modem in LR11x0 chips. - NOTE: The sketch below is just a guide on how to use - LR-FHSS modem, so this code should not be run directly! - Instead, modify the other examples to use LR-FHSS - modem and use the appropriate configuration - methods. + NOTE: The sketch below is just a guide on how to use + LR-FHSS modem, so this code should not be run directly! + Instead, modify the other examples to use LR-FHSS + modem and use the appropriate configuration + methods. - For default module settings, see the wiki page - https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lr-fhss-modem + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lr-fhss-modem - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library diff --git a/examples/LR11x0/LR11x0_Receive_Blocking/LR11x0_Receive_Blocking.ino b/examples/LR11x0/LR11x0_Receive_Blocking/LR11x0_Receive_Blocking.ino index 8d0efc9a..3e3c9eab 100644 --- a/examples/LR11x0/LR11x0_Receive_Blocking/LR11x0_Receive_Blocking.ino +++ b/examples/LR11x0/LR11x0_Receive_Blocking/LR11x0_Receive_Blocking.ino @@ -12,6 +12,10 @@ - preamble length 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 @@ -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(); diff --git a/examples/LR11x0/LR11x0_Receive_Interrupt/LR11x0_Receive_Interrupt.ino b/examples/LR11x0/LR11x0_Receive_Interrupt/LR11x0_Receive_Interrupt.ino index f20f2aaf..b8be9c9b 100644 --- a/examples/LR11x0/LR11x0_Receive_Interrupt/LR11x0_Receive_Interrupt.ino +++ b/examples/LR11x0/LR11x0_Receive_Interrupt/LR11x0_Receive_Interrupt.ino @@ -1,24 +1,28 @@ /* - RadioLib LR11x0 Receive with Interrupts Example + RadioLib LR11x0 Receive with Interrupts Example - This example listens for LoRa transmissions and tries to - receive them. Once a packet is received, an interrupt is - triggered. To successfully receive data, the following - settings have to be the same on both transmitter - and receiver: + This example listens for LoRa transmissions and tries to + receive them. Once a packet is received, an interrupt is + triggered. To successfully receive data, the following + settings have to be the same on both transmitter + and receiver: - carrier frequency - bandwidth - spreading factor - coding rate - sync word - Other modules from LR11x0 family can also be used. + 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 + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#lr11x0---lora-modem - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -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(); diff --git a/examples/LR11x0/LR11x0_Transmit_Blocking/LR11x0_Transmit_Blocking.ino b/examples/LR11x0/LR11x0_Transmit_Blocking/LR11x0_Transmit_Blocking.ino index 741102ac..8700369e 100644 --- a/examples/LR11x0/LR11x0_Transmit_Blocking/LR11x0_Transmit_Blocking.ino +++ b/examples/LR11x0/LR11x0_Transmit_Blocking/LR11x0_Transmit_Blocking.ino @@ -8,6 +8,10 @@ - arbitrary binary data (byte array) 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 diff --git a/examples/LR11x0/LR11x0_Transmit_Interrupt/LR11x0_Transmit_Interrupt.ino b/examples/LR11x0/LR11x0_Transmit_Interrupt/LR11x0_Transmit_Interrupt.ino index e47c68f7..0593253a 100644 --- a/examples/LR11x0/LR11x0_Transmit_Interrupt/LR11x0_Transmit_Interrupt.ino +++ b/examples/LR11x0/LR11x0_Transmit_Interrupt/LR11x0_Transmit_Interrupt.ino @@ -9,6 +9,10 @@ - arbitrary binary data (byte array) 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(); diff --git a/examples/LR11x0/LR11x0_WiFi_Scan_Blocking/LR11x0_WiFi_Scan_Blocking.ino b/examples/LR11x0/LR11x0_WiFi_Scan_Blocking/LR11x0_WiFi_Scan_Blocking.ino index b1643a33..be898e4d 100644 --- a/examples/LR11x0/LR11x0_WiFi_Scan_Blocking/LR11x0_WiFi_Scan_Blocking.ino +++ b/examples/LR11x0/LR11x0_WiFi_Scan_Blocking/LR11x0_WiFi_Scan_Blocking.ino @@ -6,6 +6,10 @@ such as the frequency, country code and SSID. 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 @@ -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(); diff --git a/examples/LR11x0/LR11x0_WiFi_Scan_Interrupt/LR11x0_WiFi_Scan_Interrupt.ino b/examples/LR11x0/LR11x0_WiFi_Scan_Interrupt/LR11x0_WiFi_Scan_Interrupt.ino index bf999ba1..af00066f 100644 --- a/examples/LR11x0/LR11x0_WiFi_Scan_Interrupt/LR11x0_WiFi_Scan_Interrupt.ino +++ b/examples/LR11x0/LR11x0_WiFi_Scan_Interrupt/LR11x0_WiFi_Scan_Interrupt.ino @@ -6,6 +6,10 @@ such as the frequency, country code and SSID. 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 @@ -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(); diff --git a/src/modules/LR11x0/LR11x0.cpp b/src/modules/LR11x0/LR11x0.cpp index c9d44f69..f7dea326 100644 --- a/src/modules/LR11x0/LR11x0.cpp +++ b/src/modules/LR11x0/LR11x0.cpp @@ -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; diff --git a/src/modules/LR11x0/LR11x0.h b/src/modules/LR11x0/LR11x0.h index 1c48b536..4f60f9e5 100644 --- a/src/modules/LR11x0/LR11x0.h +++ b/src/modules/LR11x0/LR11x0.h @@ -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.