[RF] Fix CC1101 on Arduino core 3.x: bump SmartRC to V3.0.2 + init before probe (#2353)
On the platform we ship (pioarduino 55.03.39 / arduino-esp32 3.3.9) the pinned SmartRC-CC1101-Driver-Lib v2.5.7 does not work with the CC1101 at all. Core 3.x's peripheral manager owns SCK/MISO/MOSI once SPI.begin() has run, so the driver's digitalWrite() calls on those pins become silent no-ops, and it starts and stops the SPI bus around every single register access (LSatan/SmartRC-CC1101-Driver-Lib#176). Bench result on an ESP32 DevKit + CC1101 running esp32dev-pilight-cc1101: setup hangs in the driver's unbounded `while(digitalRead(MISO_PIN));` before any C1101 log line is emitted, and TG1WDT reboots the board in a loop. The same build on espressif32@6.8.1 (core 2.0.17) initialises normally, so this is the core, not the wiring. Every ZradioCC1101 ESP32 environment is affected: Pilight, RF, RF2 and Somfy. The RTL_433 CC1101 path goes through RadioLib and is unaffected. V3.0.x re-engineered the SPI core for ESP32: gpio_get_level() with a timeout instead of the unbounded digitalRead() wait, SPI.begin() once instead of per transaction, and no digitalWrite() on peripheral-owned pins. It also moved SPI.begin() out of getCC1101() and into Init(), so the connection probe has to run after Init() rather than before it — reported in #2348. Both changes are needed together: the reorder alone does not help on core 3.x, and V3 cannot work without it. Verified on the bench, core 3.3.9, esp32dev-pilight-cc1101: N: C1101 SPI connection OK on attempt 1 N: C1101 tuned RX to 433.92 MHz plus a live round trip — an arctech_switch frame published to MQTTtoPilight was transmitted and decoded back by the board's own receiver on PilighttoMQTT. Note for review: this bumps the pin for the ESP8266 CC1101 environments too. They are not affected by the core 3.x breakage and V3 is untested there, so the pin may be worth splitting per environment before this lands. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4462ac94bf
commit
5fdaddadaf
2 files changed
+11
-5
No files matched your search
+10
-4
@@ -76,17 +76,21 @@ void initCC1101() {
|
||||
int delayMaxMS = 500;
|
||||
bool connected = false;
|
||||
|
||||
for (int attempt = 1; attempt <= 10; attempt++) {
|
||||
# if defined(RF_CC1101_SCK) && defined(RF_CC1101_MISO) && \
|
||||
defined(RF_CC1101_MOSI) && defined(RF_CC1101_CS)
|
||||
THEENGS_LOG_TRACE(F("initCC1101 with custom SPI pins, SCK=%d, MISO=%d, MOSI=%d, CS=%d" CR), RF_CC1101_SCK, RF_CC1101_MISO, RF_CC1101_MOSI, RF_CC1101_CS);
|
||||
ELECHOUSE_cc1101.setSpiPin(RF_CC1101_SCK, RF_CC1101_MISO, RF_CC1101_MOSI, RF_CC1101_CS);
|
||||
THEENGS_LOG_TRACE(F("initCC1101 with custom SPI pins, SCK=%d, MISO=%d, MOSI=%d, CS=%d" CR), RF_CC1101_SCK, RF_CC1101_MISO, RF_CC1101_MOSI, RF_CC1101_CS);
|
||||
ELECHOUSE_cc1101.setSpiPin(RF_CC1101_SCK, RF_CC1101_MISO, RF_CC1101_MOSI, RF_CC1101_CS);
|
||||
# endif
|
||||
|
||||
// Init() must run before getCC1101(): from driver V3.x on it is Init() that
|
||||
// starts the SPI bus, so the status-register read behind getCC1101() would
|
||||
// otherwise run on a bus that was never begun.
|
||||
ELECHOUSE_cc1101.Init();
|
||||
|
||||
for (int attempt = 1; attempt <= 10; attempt++) {
|
||||
if (ELECHOUSE_cc1101.getCC1101()) {
|
||||
connected = true;
|
||||
THEENGS_LOG_NOTICE(F("C1101 SPI connection OK on attempt %d" CR), attempt);
|
||||
ELECHOUSE_cc1101.Init();
|
||||
ELECHOUSE_cc1101.SetRx(freqMhz);
|
||||
THEENGS_LOG_NOTICE(F("C1101 tuned RX to %F MHz" CR), freqMhz);
|
||||
break;
|
||||
@@ -98,6 +102,8 @@ void initCC1101() {
|
||||
// truncated exponential backoff
|
||||
delayMS = delayMS * 2;
|
||||
if (delayMS > delayMaxMS) delayMS = delayMaxMS;
|
||||
|
||||
ELECHOUSE_cc1101.Init();
|
||||
}
|
||||
|
||||
if (!connected) {
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ m5stickc = M5StickC@0.2.5
|
||||
m5stickcp = https://github.com/m5stack/M5StickC-Plus/archive/0.1.1.zip
|
||||
m5stack = M5Stack@0.4.6
|
||||
m5tough = https://github.com/m5stack/M5Tough/archive/ccf49e1.zip
|
||||
smartrc-cc1101-driver-lib = https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/archive/v2.5.7.zip
|
||||
smartrc-cc1101-driver-lib = https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/archive/v3.0.2.zip
|
||||
stl = https://github.com/mike-matera/ArduinoSTL/archive/7411816.zip
|
||||
shtc3 = https://github.com/sparkfun/SparkFun_SHTC3_Arduino_Library/archive/671ef7e.zip
|
||||
somfy_remote=Somfy_Remote_Lib@0.3.0
|
||||
|
||||
Reference in new issue
Block a user