Skip to content

Commit

Permalink
[LR11x0] Fix RF switch call in examples (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Oct 27, 2024
1 parent 9f4d4ea commit 0156c90
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
23 changes: 23 additions & 0 deletions examples/LR11x0/LR11x0_GNSS_Satellites/LR11x0_GNSS_Satellites.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions examples/LR11x0/LR11x0_PingPong/LR11x0_PingPong.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 0156c90

Please sign in to comment.