From dce1c78a660de250249c78de0cb2917026c6c51e Mon Sep 17 00:00:00 2001 From: mverch67 Date: Wed, 26 Mar 2025 22:47:02 +0100 Subject: [PATCH] allow LoRa on SPI/HSPI (elecrow) --- src/FSCommon.cpp | 4 ++-- src/main.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 88f0764b5..68f18b815 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -17,8 +17,8 @@ #include #ifdef SDCARD_USE_SPI1 -SPIClass SPI1(HSPI); -#define SDHandler SPI1 +SPIClass SPI_HSPI(HSPI); +#define SDHandler SPI_HSPI #else #define SDHandler SPI #endif diff --git a/src/main.cpp b/src/main.cpp index 0972c4974..a7b51d098 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,6 +137,10 @@ void setupNicheGraphics(); #include "nicheGraphics.h" #endif +#if defined(HW_SPI1_DEVICE) && defined(ELECROW) +SPIClass SPI1(HSPI); +#endif + using namespace concurrency; volatile static const char slipstreamTZString[] = {USERPREFS_TZ_STRING}; @@ -789,10 +793,16 @@ void setup() #elif !defined(ARCH_ESP32) // ARCH_RP2040 SPI.begin(); #else - // ESP32 + // ESP32 +#if defined(HW_SPI1_DEVICE) && defined(ELECROW) + SPI1.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); + LOG_DEBUG("SPI1.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); + SPI1.setFrequency(4000000); +#else SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); LOG_DEBUG("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); SPI.setFrequency(4000000); +#endif #endif // Initialize the screen first so we can show the logo while we start up everything else.