Skip to content

Commit 4a820d6

Browse files
committed
[ESP32-x3] give some boot time diagnostic messages over UART on M2, M5 and XR1
1 parent c5cf46e commit 4a820d6

File tree

4 files changed

+59
-38
lines changed

4 files changed

+59
-38
lines changed

software/firmware/source/SoftRF/src/driver/radio/radiolib.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ static const Module::RfSwitchMode_t rfswitch_table_lilygo[] = {
324324
// mode DIO5 DIO6 HF_RX HF_TX
325325
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
326326
{ LR11x0::MODE_RX, { LOW, HIGH, HIGH, LOW } },
327-
{ LR11x0::MODE_TX, { LOW, LOW, LOW, LOW } },
328-
{ LR11x0::MODE_TX_HP, { LOW, LOW, LOW, LOW } },
327+
{ LR11x0::MODE_TX, { HIGH, LOW, LOW, LOW } },
328+
{ LR11x0::MODE_TX_HP, { HIGH, LOW, LOW, LOW } },
329329
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, HIGH } },
330330
{ LR11x0::MODE_GNSS, { LOW, LOW, LOW, LOW } },
331331
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, LOW } },

software/firmware/source/SoftRF/src/platform/ESP32.cpp

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,9 @@ static void ESP32_setup()
664664
* LilyGO T3-S3-EP | ESP32-S3-MINI | XMC_XM25QH32B
665665
* LilyGO T3-S3-OL | ESP32-S3FH4R2 |
666666
* Elecrow TN-M2 | ESP32-S3-N4R8 | ZBIT_ZB25VQ32B
667-
* Elecrow TN-M5 | ESP32-S3-N4R8 |
667+
* RadioMaster XR1 | ESP32-C3 (QFN32) | XMC_XM25QH32B
668+
* RadioMaster XR1 | | 0x464016 (TBD)
669+
* Elecrow TN-M5 | ESP32-S3-N4R8 | 0x464016 (TBD)
668670
* Ebyte EoRa-HUB | ESP32-S3FH4R2 |
669671
* WT99P4C5-S1 CPU | WT0132P4-A1 | ZBIT_ZB25VQ128ASIG
670672
* WT99P4C5-S1 NCU | ESP32-C5-WROOM-1 | XMC_XM25QH64B
@@ -812,11 +814,11 @@ static void ESP32_setup()
812814
switch (flash_id)
813815
{
814816
case MakeFlashId(ZBIT_ID, ZBIT_ZB25VQ32B): /* C3FH4 or 4X with emb. flash */
815-
/* https://github.com/lyusupov/SoftRF/issues/191 */
816-
case MakeFlashId(TBD_ID, TBD_25Q32):
817817
esp32_board = ESP32_RADIOMASTER_XR1;
818818
break;
819819
case MakeFlashId(ST_ID, XMC_XM25QH32B):
820+
/* https://github.com/lyusupov/SoftRF/issues/191 */
821+
case MakeFlashId(TBD_ID, TBD_25Q32):
820822
if (wafer_ver == 4)
821823
esp32_board = ESP32_RADIOMASTER_XR1;
822824
else
@@ -2511,44 +2513,49 @@ static void ESP32_post_init()
25112513
#endif /* EXCLUDE_VOICE_MESSAGE */
25122514
#endif /* CONFIG_IDF_TARGET_ESP32S3 */
25132515

2514-
Serial.println();
2515-
Serial.println(F("Data output device(s):"));
2516+
Stream *Diag;
2517+
if (esp32_board == ESP32_RADIOMASTER_XR1) { Diag = &Serial_GNSS_Out; } else if
2518+
(esp32_board == ESP32_ELECROW_TN_M2 || esp32_board == ESP32_ELECROW_TN_M5)
2519+
{ Diag = &SerialOutput; } else { Diag = &Serial; }
2520+
2521+
Diag->println();
2522+
Diag->println(F("Data output device(s):"));
25162523

2517-
Serial.print(F("NMEA - "));
2524+
Diag->print(F("NMEA - "));
25182525
switch (settings->nmea_out)
25192526
{
2520-
case NMEA_UART : Serial.println(F("UART")); break;
2521-
case NMEA_USB : Serial.println(F("USB CDC")); break;
2522-
case NMEA_UDP : Serial.println(F("UDP")); break;
2523-
case NMEA_TCP : Serial.println(F("TCP")); break;
2524-
case NMEA_BLUETOOTH : Serial.println(F("Bluetooth")); break;
2527+
case NMEA_UART : Diag->println(F("UART")); break;
2528+
case NMEA_USB : Diag->println(F("USB CDC")); break;
2529+
case NMEA_UDP : Diag->println(F("UDP")); break;
2530+
case NMEA_TCP : Diag->println(F("TCP")); break;
2531+
case NMEA_BLUETOOTH : Diag->println(F("Bluetooth")); break;
25252532
case NMEA_OFF :
2526-
default : Serial.println(F("NULL")); break;
2533+
default : Diag->println(F("NULL")); break;
25272534
}
25282535

2529-
Serial.print(F("GDL90 - "));
2536+
Diag->print(F("GDL90 - "));
25302537
switch (settings->gdl90)
25312538
{
2532-
case GDL90_UART : Serial.println(F("UART")); break;
2533-
case GDL90_USB : Serial.println(F("USB CDC")); break;
2534-
case GDL90_UDP : Serial.println(F("UDP")); break;
2535-
case GDL90_BLUETOOTH : Serial.println(F("Bluetooth")); break;
2539+
case GDL90_UART : Diag->println(F("UART")); break;
2540+
case GDL90_USB : Diag->println(F("USB CDC")); break;
2541+
case GDL90_UDP : Diag->println(F("UDP")); break;
2542+
case GDL90_BLUETOOTH : Diag->println(F("Bluetooth")); break;
25362543
case GDL90_OFF :
2537-
default : Serial.println(F("NULL")); break;
2544+
default : Diag->println(F("NULL")); break;
25382545
}
25392546

2540-
Serial.print(F("D1090 - "));
2547+
Diag->print(F("D1090 - "));
25412548
switch (settings->d1090)
25422549
{
2543-
case D1090_UART : Serial.println(F("UART")); break;
2544-
case D1090_USB : Serial.println(F("USB CDC")); break;
2545-
case D1090_BLUETOOTH : Serial.println(F("Bluetooth")); break;
2550+
case D1090_UART : Diag->println(F("UART")); break;
2551+
case D1090_USB : Diag->println(F("USB CDC")); break;
2552+
case D1090_BLUETOOTH : Diag->println(F("Bluetooth")); break;
25462553
case D1090_OFF :
2547-
default : Serial.println(F("NULL")); break;
2554+
default : Diag->println(F("NULL")); break;
25482555
}
25492556

2550-
Serial.println();
2551-
Serial.flush();
2557+
Diag->println();
2558+
Diag->flush();
25522559

25532560
switch (hw_info.display)
25542561
{
@@ -4316,11 +4323,11 @@ static void ESP32_swSer_begin(unsigned long baud)
43164323
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
43174324
SOC_GPIO_PIN_BPIPW_GNSS_RX, SOC_GPIO_PIN_BPIPW_GNSS_TX);
43184325
} else if (esp32_board == ESP32_ELECROW_TN_M2) {
4319-
Serial.println(F("INFO: Elecrow ThinkNode M2 is detected."));
4326+
SerialOutput.println(F("INFO: Elecrow ThinkNode M2 is detected."));
43204327
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
43214328
SOC_GPIO_PIN_M2_GNSS_RX, SOC_GPIO_PIN_M2_GNSS_TX);
43224329
} else if (esp32_board == ESP32_ELECROW_TN_M5) {
4323-
Serial.println(F("INFO: Elecrow ThinkNode M5 is detected."));
4330+
SerialOutput.println(F("INFO: Elecrow ThinkNode M5 is detected."));
43244331
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
43254332
SOC_GPIO_PIN_M5_GNSS_RX, SOC_GPIO_PIN_M5_GNSS_TX);
43264333
} else if (esp32_board == ESP32_EBYTE_HUB_900TB) {
@@ -4340,9 +4347,9 @@ static void ESP32_swSer_begin(unsigned long baud)
43404347
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
43414348
SOC_GPIO_PIN_C3_GNSS_RX, SOC_GPIO_PIN_C3_GNSS_TX);
43424349
} else if (esp32_board == ESP32_RADIOMASTER_XR1) {
4343-
Serial.println(F("INFO: RadioMaster XR1 is detected."));
43444350
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
43454351
SOC_GPIO_PIN_ELRS_MAV_RX, SOC_GPIO_PIN_ELRS_MAV_TX);
4352+
Serial_GNSS_Out.println(F("INFO: RadioMaster XR1 is detected."));
43464353
#endif /* CONFIG_IDF_TARGET_ESP32C3 */
43474354
#if defined(CONFIG_IDF_TARGET_ESP32C5)
43484355
} else if (esp32_board == ESP32_C5_DEVKIT) {
@@ -4380,9 +4387,13 @@ static void ESP32_swSer_begin(unsigned long baud)
43804387
/* Default Rx buffer size (256 bytes) is sometimes not big enough */
43814388
// Serial_GNSS_In.setRxBufferSize(512);
43824389

4383-
/* Need to gather some statistics on variety of flash IC usage */
4384-
Serial.print(F("Flash memory ID: "));
4385-
Serial.println(ESP32_getFlashId(), HEX);
4390+
/* Needs to gather some statistics on variety of flash IC usage */
4391+
Stream *Diag;
4392+
if (esp32_board == ESP32_RADIOMASTER_XR1) { Diag = &Serial_GNSS_Out; } else if
4393+
(esp32_board == ESP32_ELECROW_TN_M2 || esp32_board == ESP32_ELECROW_TN_M5)
4394+
{ Diag = &SerialOutput; } else { Diag = &Serial; }
4395+
Diag->print(F("Flash memory ID: "));
4396+
Diag->println(ESP32_getFlashId(), HEX);
43864397
}
43874398

43884399
static void ESP32_swSer_enableRx(boolean arg)

software/firmware/source/libraries/RadioLib/src/Module.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ class Module {
523523
void regdump(const char* level, uint16_t start, size_t len);
524524
#endif
525525

526+
// RF switch pins and table (in use by external LR11x0 module)
527+
uint32_t rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
528+
const RfSwitchMode_t *rfSwitchTable = nullptr;
529+
526530
#if !RADIOLIB_GODMODE
527531
private:
528532
#endif
@@ -531,10 +535,6 @@ class Module {
531535
uint32_t rstPin = RADIOLIB_NC;
532536
uint32_t gpioPin = RADIOLIB_NC;
533537

534-
// RF switch pins and table
535-
uint32_t rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
536-
const RfSwitchMode_t *rfSwitchTable = nullptr;
537-
538538
#if RADIOLIB_INTERRUPT_TIMING
539539
uint32_t prevTimingLen = 0;
540540
#endif

software/firmware/source/libraries/RadioLib/src/modules/LR11x0/LR11x0.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ void LR11x0::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS],
14621462
continue;
14631463
}
14641464

1465-
// only keep DIO pins, there may be some GPIOs in the switch tabke
1465+
// only keep DIO pins, there may be some GPIOs in the switch table
14661466
if(pins[i] & RFSWITCH_PIN_FLAG) {
14671467
enable |= 1UL << RADIOLIB_LR11X0_DIOx_VAL(pins[i]);
14681468
}
@@ -1492,6 +1492,16 @@ void LR11x0::setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS],
14921492

14931493
// set it
14941494
this->setDioAsRfSwitch(enable, modes[0], modes[1], modes[2], modes[3], modes[4], modes[5], modes[6]);
1495+
1496+
// process GPIO entries the same way as Module.cpp does
1497+
memcpy(this->mod->rfSwitchPins, pins, sizeof(this->mod->rfSwitchPins));
1498+
this->mod->rfSwitchTable = table;
1499+
for(size_t i = 0; i < Module::RFSWITCH_MAX_PINS; i++) {
1500+
// only process modes for the GPIO pins, skip DIOx pins
1501+
if(!(pins[i] & RFSWITCH_PIN_FLAG)) {
1502+
this->mod->hal->pinMode(pins[i], this->mod->hal->GpioModeOutput);
1503+
}
1504+
}
14951505
}
14961506

14971507
int16_t LR11x0::forceLDRO(bool enable) {

0 commit comments

Comments
 (0)