[LR11x0] Fix RF switch call in examples (#1295)

This commit is contained in:
jgromes 2024-10-27 19:29:42 +00:00
parent 9f4d4ea15e
commit 0156c9004e
12 changed files with 96 additions and 36 deletions

View file

@ -65,10 +65,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -79,6 +75,9 @@ void setup() {
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
}
void loop() {

View file

@ -60,10 +60,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -75,6 +71,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called
// when LoRa packet or timeout is detected
radio.setIrqAction(setFlag);

View file

@ -41,6 +41,26 @@ LR1110 radio = new Module(10, 2, 3, 9);
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS almanac
LR11x0GnssAlmanacStatus_t almStatus;
@ -58,6 +78,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();

View file

@ -37,6 +37,26 @@ LR1110 radio = new Module(10, 2, 3, 9);
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS scan result
LR11x0GnssResult_t gnssResult;
@ -57,6 +77,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();

View file

@ -37,6 +37,26 @@ LR1110 radio = new Module(10, 2, 3, 9);
Radio radio = new RadioModule();
*/
// set RF switch configuration for Wio WM1110
// Wio WM1110 uses DIO5 and DIO6 for RF switching
// NOTE: other boards may be different!
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { HIGH, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
// structure to save information about the GNSS scan result
LR11x0GnssResult_t gnssResult;
@ -54,6 +74,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// check the firmware version
Serial.print(F("[LR1110] Checking firmware version ... "));
state = radio.isGnssScanCapable();

View file

@ -74,10 +74,6 @@ void setFlag(void) {
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();
@ -89,6 +85,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called
// when new packet is received
radio.setIrqAction(setFlag);

View file

@ -70,10 +70,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -84,6 +80,9 @@ void setup() {
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
}
void loop() {

View file

@ -66,10 +66,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -81,6 +77,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called
// when new packet is received
radio.setPacketReceivedAction(setFlag);

View file

@ -61,10 +61,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -76,6 +72,9 @@ void setup() {
delay(1000);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
}
// counter to keep track of transmitted packets

View file

@ -65,10 +65,6 @@ 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();
@ -80,6 +76,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called
// when packet transmission is finished
radio.setPacketSentAction(setFlag);

View file

@ -63,10 +63,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -77,6 +73,9 @@ void setup() {
Serial.println(state);
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
}
void loop() {

View file

@ -63,10 +63,6 @@ static const Module::RfSwitchMode_t rfswitch_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();
@ -78,6 +74,9 @@ void setup() {
while (true) { delay(10); }
}
// set RF switch control configuration
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);
// set the function that will be called
// when WiFi scan is complete
radio.setIrqAction(setFlag);