diff --git a/src/main.cpp b/src/main.cpp index 37ed61e56..4763c1f0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1111,6 +1111,23 @@ void setup() #endif #endif +#if defined(SENSECAP_INDICATOR) + // The ST7701 panel shares SCK/MOSI/MISO (41/48/47) with the SX1262, and its host is SPI2_HOST, + // which on the S3 is the same peripheral as the Arduino `SPI` object (FSPI == SPI2). + // LovyanGFX bit-bangs the ST7701 init sequence on those pins, and because this variant builds + // with USE_ARDUINO_HAL_GPIO it does so via Arduino pinMode()/digitalWrite(). pinMode() calls + // perimanSetPinBus(.., ESP32_BUS_TYPE_GPIO, ..), whose deinit callback (spiDetachBus_SCK) ends + // up in spiStopBus() and gates the SPI2 clock. RadioLib then spins forever in spiTransferByte() + // waiting on cmd.update, which never clears on a stopped peripheral, and the watchdog fires. + // + // Restart the bus here, after the panel is up and before the radio is touched. Note that + // SPIClass::begin() early-returns when _spi is already non-NULL, so end() first is required. + SPI.end(); + SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, -1); // CS is an IO-expander pin, driven by RadioLib + SPI.setFrequency(4000000); + LOG_DEBUG("SPI2 restarted after ST7701 init (SCK=%d, MISO=%d, MOSI=%d)", LORA_SCK, LORA_MISO, LORA_MOSI); +#endif + auto rIf = initLoRa(); lateInitVariant(); // Do board specific init (see extra_variants/README.md for documentation)