From 642cfd0c94aa3eb65674f010eefe904cc779d201 Mon Sep 17 00:00:00 2001 From: cjkas Date: Sat, 24 Oct 2026 20:53:10 +0200 Subject: [PATCH] fix: CC1101 init hangs the ESP32-S3 when the radio is enabled Init() starts the SPI bus and resets the chip, then every register write calls SpiStart() again while the bus is still up. SpiStart() ran pinMode() on SCK, MOSI and MISO. On Arduino 3.x that takes the pins from the SPI bus, which stops it (spiStopBus) while SPIClass still holds the handle, so the following SPI.begin() returns early and the bus stays down. On the S3 the stopped bus also has clk_gate cleared, so spiTransferByte() waits on cmd.usr forever and the task watchdog aborts async_tcp when the radio settings are saved. On the ESP32 the transfer completes on detached pins, so the first register write (FSCTRL1) is silently lost. SPI.begin() attaches and configures the bus pins itself, so on ESP32 targets SpiStart() now only sets SS, which the driver drives by hand. Co-Authored-By: Claude Opus 5.5 --- .../ELECHOUSE_CC1101_SRC_DRV.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp index c5f014d..10e16fa 100644 --- a/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp +++ b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp @@ -104,10 +104,19 @@ uint8_t PA_TABLE_915[10] {0x03,0x0E,0x1E,0x27,0x38,0x8E,0x84,0xCC,0xC3,0xC0,}; void ELECHOUSE_CC1101::SpiStart(void) { // initialize the SPI pins + #ifdef ESP32 + // ESPSomfy-RTS: SPI.begin() sets the bus pins up itself. Init() calls this + // again while the bus is running, and on Arduino 3.x a pinMode() on a pin + // the bus owns stops the bus while SPI.begin() still thinks it is up. The + // next transfer is lost on the ESP32 and hangs forever on the S3, whose + // stopped bus has no clock. SS is driven by hand, so it still needs one. + pinMode(SS_PIN, OUTPUT); + #else pinMode(SCK_PIN, OUTPUT); pinMode(MOSI_PIN, OUTPUT); pinMode(MISO_PIN, INPUT); pinMode(SS_PIN, OUTPUT); + #endif // enable SPI #ifdef ESP32