Skip to content

Commit 8a58cf1

Browse files
committed
[ESP32] more of LilyGO T-ELRS build infra
1 parent a17de37 commit 8a58cf1

File tree

4 files changed

+78
-16
lines changed

4 files changed

+78
-16
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,24 @@ static const Module::RfSwitchMode_t rfswitch_table_elecrow[] = {
313313
{ LR11x0::MODE_WIFI, { LOW, LOW } },
314314
END_OF_MODE_TABLE,
315315
};
316+
317+
static const uint32_t rfswitch_dio_pins_lilygo[] = {
318+
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
319+
10 /* SOC_GPIO_PIN_ELRS_HF_RX */, 14 /* SOC_GPIO_PIN_ELRS_HF_TX */,
320+
RADIOLIB_NC
321+
};
322+
323+
static const Module::RfSwitchMode_t rfswitch_table_lilygo[] = {
324+
// mode DIO5 DIO6 HF_RX HF_TX
325+
{ LR11x0::MODE_STBY, { LOW, LOW, LOW, LOW } },
326+
{ LR11x0::MODE_RX, { LOW, HIGH, HIGH, LOW } },
327+
{ LR11x0::MODE_TX, { LOW, LOW, LOW, LOW } },
328+
{ LR11x0::MODE_TX_HP, { LOW, LOW, LOW, LOW } },
329+
{ LR11x0::MODE_TX_HF, { LOW, LOW, LOW, HIGH } },
330+
{ LR11x0::MODE_GNSS, { LOW, LOW, LOW, LOW } },
331+
{ LR11x0::MODE_WIFI, { LOW, LOW, LOW, LOW } },
332+
END_OF_MODE_TABLE,
333+
};
316334
#endif /* USE_LR11XX */
317335

318336
// this function is called when a complete packet
@@ -991,7 +1009,13 @@ static void lr11xx_setup()
9911009
#endif
9921010
state = radio_semtech->setOutputPower(txpow, false);
9931011
} else {
994-
radio_semtech->setDioAsRfSwitch(0x0F, 0x0, 0x0C, 0x08, 0x08, 0x6, 0x0, 0x5);
1012+
if (hw_info.revision == 2) {
1013+
/* LilyGO T-Lora Dual LR, a.k.a. LilyGO T-ELRS-LR1121 */
1014+
radio_semtech->setRfSwitchTable(rfswitch_dio_pins_lilygo, rfswitch_table_lilygo);
1015+
} else {
1016+
/* RadioMaster XR1 */
1017+
radio_semtech->setDioAsRfSwitch(0x0F, 0x0, 0x0C, 0x08, 0x08, 0x6, 0x0, 0x5);
1018+
}
9951019
state = radio_semtech->setOutputPower(txpow, high ? false : true);
9961020
}
9971021
break;

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

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ esp_err_t es8311_codec_init(void) {
520520
#endif /* CONFIG_IDF_TARGET_ESP32P4 */
521521
#endif /* CONFIG_IDF_TARGET_ESP32S3-P4 */
522522

523-
#if defined(CONFIG_IDF_TARGET_ESP32C3)
523+
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32)
524524
#if defined(USE_NEOPIXELBUS_LIBRARY)
525525
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> XR1_Pixel(1, SOC_GPIO_PIN_ELRS_PIXEL);
526526
#endif /* USE_NEOPIXELBUS_LIBRARY */
@@ -727,9 +727,26 @@ static void ESP32_setup()
727727
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
728728
uint32_t pkg_ver = chip_ver & 0x7;
729729
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
730-
esp32_board = ESP32_TTGO_V2_OLED;
731-
lmic_pins.rst = SOC_GPIO_PIN_TBEAM_RF_RST_V05;
732-
lmic_pins.busy = SOC_GPIO_PIN_TBEAM_RF_BUSY_V08;
730+
esp32_board = ESP32_TTGO_V2_OLED;
731+
732+
#if 0
733+
pinMode(SOC_GPIO_PIN_TBEAM_RF_RST_V05, INPUT_PULLDOWN);
734+
pinMode(SOC_GPIO_PIN_DIO0, INPUT_PULLUP);
735+
736+
delay(50);
737+
738+
if (digitalRead(SOC_GPIO_PIN_DIO0) == HIGH) {
739+
esp32_board = ESP32_LILYGO_T_ELRS;
740+
}
741+
742+
pinMode(SOC_GPIO_PIN_DIO0, INPUT);
743+
pinMode(SOC_GPIO_PIN_TBEAM_RF_RST_V05, INPUT);
744+
#endif
745+
746+
if (esp32_board == ESP32_TTGO_V2_OLED) {
747+
lmic_pins.rst = SOC_GPIO_PIN_TBEAM_RF_RST_V05;
748+
lmic_pins.busy = SOC_GPIO_PIN_TBEAM_RF_BUSY_V08;
749+
}
733750
}
734751
#endif /* ESP_IDF_VERSION_MAJOR */
735752
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
@@ -905,6 +922,8 @@ static void ESP32_setup()
905922
lmic_pins.nss = SOC_GPIO_PIN_ELRS_SS;
906923
lmic_pins.rst = SOC_GPIO_PIN_ELRS_RST;
907924
lmic_pins.busy = SOC_GPIO_PIN_ELRS_BUSY;
925+
// lmic_pins.txe = SOC_GPIO_PIN_ELRS_HF_TX; /* 1+ GHz only */
926+
// lmic_pins.rxe = SOC_GPIO_PIN_ELRS_HF_RX; /* 1+ GHz only */
908927
#if defined(USE_RADIOLIB) || defined(USE_RADIOHEAD)
909928
lmic_pins.dio[0] = SOC_GPIO_PIN_ELRS_DIO9;
910929
#endif /* USE_RADIOLIB || USE_RADIOHEAD */
@@ -2301,8 +2320,9 @@ static void ESP32_setup()
23012320
}
23022321
#endif /* CONFIG_IDF_TARGET_ESP32S3 */
23032322

2304-
#if defined(CONFIG_IDF_TARGET_ESP32C3)
2305-
if (esp32_board == ESP32_RADIOMASTER_XR1) {
2323+
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32)
2324+
if (esp32_board == ESP32_RADIOMASTER_XR1 ||
2325+
esp32_board == ESP32_LILYGO_T_ELRS) {
23062326
#if SOC_GPIO_PIN_ELRS_LED != SOC_UNUSED_PIN
23072327
digitalWrite(SOC_GPIO_PIN_ELRS_LED, LED_STATE_ON);
23082328
pinMode(SOC_GPIO_PIN_ELRS_LED, OUTPUT);
@@ -4234,8 +4254,14 @@ static void ESP32_swSer_begin(unsigned long baud)
42344254
TTGO_V2_PIN_GNSS_RX, TTGO_V2_PIN_GNSS_TX);
42354255
} else if (esp32_board == ESP32_LILYGO_T_ELRS) {
42364256
Serial.println(F("INFO: LilyGO T-Lora Dual is detected."));
4237-
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
4238-
SOC_GPIO_PIN_ELRS_MAV_RX, SOC_GPIO_PIN_ELRS_MAV_TX);
4257+
if (settings->mode == SOFTRF_MODE_UAV) {
4258+
SerialOutput.updateBaudRate(baud);
4259+
Serial_GNSS_In = SerialOutput;
4260+
} else {
4261+
Serial_GNSS_In.begin(baud, SERIAL_IN_BITS,
4262+
SOC_GPIO_PIN_ELRS_GNSS_RX,
4263+
SOC_GPIO_PIN_ELRS_GNSS_TX);
4264+
};
42394265
#endif /* CONFIG_IDF_TARGET_ESP32 */
42404266
#if defined(CONFIG_IDF_TARGET_ESP32S2)
42414267
} else if (esp32_board == ESP32_S2_T8_V1_1) {
@@ -5240,7 +5266,8 @@ static void ESP32_Battery_setup()
52405266
#if !defined(ESP_IDF_VERSION_MAJOR) || ESP_IDF_VERSION_MAJOR < 5
52415267
calibrate_voltage(hw_info.model == SOFTRF_MODEL_PRIME_MK2 ||
52425268
(esp32_board == ESP32_TTGO_V2_OLED &&
5243-
hw_info.revision == STD_EDN_REV_T3_1_6) ?
5269+
hw_info.revision == STD_EDN_REV_T3_1_6) ||
5270+
esp32_board == ESP32_LILYGO_T_ELRS ?
52445271
(adc1_channel_t) ADC1_GPIO35_CHANNEL :
52455272
(adc1_channel_t) ADC1_GPIO36_CHANNEL);
52465273
#else

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,15 @@ struct rst_info {
493493
#if defined(CONFIG_IDF_TARGET_ESP32)
494494
//#define ENABLE_BT_VOICE
495495
//#define USE_NIMBLE
496+
497+
//#define USE_RADIOLIB
498+
//#define EXCLUDE_LR11XX
499+
#define EXCLUDE_CC1101
500+
#define EXCLUDE_SI443X
501+
#define EXCLUDE_SI446X
502+
#define EXCLUDE_SX1231
503+
#define EXCLUDE_SX1280
504+
496505
#else
497506

498507
#define EXCLUDE_UATM

software/firmware/source/SoftRF/src/platform/iomap/LilyGO_ELRS.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* ESP32-PICO-D4
44
*/
55

6-
#define SOC_GPIO_PIN_ELRS_CONS_RX 12 /* NC */
7-
#define SOC_GPIO_PIN_ELRS_CONS_TX 23 /* NC */
6+
#define SOC_GPIO_PIN_ELRS_GNSS_RX 12 /* NC */
7+
#define SOC_GPIO_PIN_ELRS_GNSS_TX 23 /* NC */
88

99
#define SOC_GPIO_PIN_ELRS_MAV_RX 3 /* U0RXD */
1010
#define SOC_GPIO_PIN_ELRS_MAV_TX 1 /* U0TXD */
@@ -23,8 +23,9 @@
2323
#define SOC_GPIO_PIN_ELRS_RST 26
2424
#define SOC_GPIO_PIN_ELRS_DIO9 37
2525

26-
#define SOC_GPIO_PIN_ELRS_ANT_SW_TX 14
27-
#define SOC_GPIO_PIN_ELRS_ANT_SW_RX 10
26+
/* AT2401C */
27+
#define SOC_GPIO_PIN_ELRS_HF_TX 14
28+
#define SOC_GPIO_PIN_ELRS_HF_RX 10
2829
#else
2930
// Radio #2
3031
#define SOC_GPIO_PIN_ELRS_SS 13
@@ -33,8 +34,9 @@
3334
#define SOC_GPIO_PIN_ELRS_RST 21
3435
#define SOC_GPIO_PIN_ELRS_DIO9 34
3536

36-
#define SOC_GPIO_PIN_ELRS_ANT_SW_TX 15
37-
#define SOC_GPIO_PIN_ELRS_ANT_SW_RX 9
37+
/* AT2401C */
38+
#define SOC_GPIO_PIN_ELRS_HF_TX 15
39+
#define SOC_GPIO_PIN_ELRS_HF_RX 9
3840
#endif
3941

4042
// misc.

0 commit comments

Comments
 (0)