From c81da8e021e5a3bcea3ca9f046fb1f70aaa20937 Mon Sep 17 00:00:00 2001 From: Konrad Iturbe Date: Thu, 13 Mar 2025 11:37:36 +0100 Subject: [PATCH] Fix for Heltec Lora V3 3.2 board (#144) * attempt at getting the spi issues fixed * Fix for Heltec Lora V3 (v3.2) variant * Better warning message --- lib/comms/bus.cpp | 7 +++++++ lib/comms/bus.h | 2 ++ platformio.ini | 24 +++++++++++++++++++++++- src/main.cpp | 4 ++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/comms/bus.cpp b/lib/comms/bus.cpp index 520aa58..2e73042 100644 --- a/lib/comms/bus.cpp +++ b/lib/comms/bus.cpp @@ -20,12 +20,15 @@ bool initUARTs(Config &config) return true; } +#ifndef HELTEC SPIClass &hspi = *(new SPIClass(HSPI)); // not usable until initSPIs +#endif bool initSPIs(Config &config) { if (config.spi1.enabled) { +#ifndef HELTEC delete (&hspi); hspi = *(new SPIClass(config.spi1.bus_num)); if (config.spi1.clock_freq > 0) @@ -35,10 +38,14 @@ bool initSPIs(Config &config) // if all the pins are -1, then will use the default for SPI bus_num hspi.begin(config.spi1.clk, config.spi1.miso, config.spi1.mosi); + Serial.printf("Initialized SPI%d @ %x: SC:%d MISO:%d MOSI:%d clock:%d\n", (int)config.spi1.bus_num, (void *)&hspi, (int)config.spi1.clk, (int)config.spi1.miso, (int)config.spi1.mosi, (int)config.spi1.clock_freq); +#else + Serial.println("Custom SPI initializer not supported on Heltec"); +#endif } return true; diff --git a/lib/comms/bus.h b/lib/comms/bus.h index b94599e..35a0aae 100644 --- a/lib/comms/bus.h +++ b/lib/comms/bus.h @@ -17,7 +17,9 @@ enum I2CDevices extern uint8_t wireDevices; extern uint8_t wire1Devices; +#ifndef HELTEC extern SPIClass &hspi; +#endif // abstract away a reference to Serial vs Serial0 vs Serial1, so it compiles #ifndef ARDUINO_USB_CDC_ON_BOOT diff --git a/platformio.ini b/platformio.ini index dbea0ee..7fb8742 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,13 +32,35 @@ board_build.f_cpu = 240000000 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - ESP Async WebServer + ESP32Async/AsyncTCP + ESP32Async/ESPAsyncWebServer build_flags = -DHELTEC_POWER_BUTTON -DHELTEC -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 +; Heltec WiFi LORA 32 V3 - V3.2 +; display is external now +[env:heltec_wifi_lora_32_V3_2] +platform = espressif32 +board = heltec_wifi_lora_32_V3 +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +board_build.filesystem = littlefs +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + ESP32Async/AsyncTCP + ESP32Async/ESPAsyncWebServer +build_flags = + -DHELTEC_POWER_BUTTON + -DHELTEC + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_MODE=1 + -DHELTEC_WIFI_LORA_32_V3_2 + [env:heltec_wifi_lora_32_V3_lora-TX-scanner] platform = espressif32 board = heltec_wifi_lora_32_V3 diff --git a/src/main.cpp b/src/main.cpp index 8eae9cf..396e18b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1618,6 +1618,10 @@ void setup(void) pinMode(REB_PIN, OUTPUT); heltec_setup(); +#ifdef HELTEC_WIFI_LORA_32_V3_2 + heltec_ve(true); +#endif + if (!initUARTs(config)) { Serial.println("Failed to initialize UARTs");