diff --git a/main/commonRF.cpp b/main/commonRF.cpp index 85d150c..4e84e28 100644 --- a/main/commonRF.cpp +++ b/main/commonRF.cpp @@ -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) { diff --git a/platformio.ini b/platformio.ini index 3365f91..2c3b540 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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