From 9d8ef192904390bf47522d2413d350e02b1b5da4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 22 Apr 2024 22:00:09 +0200 Subject: [PATCH] fix ESP32-S3 --- scripts/applyPatches.py | 7 ++++--- src/hm/nrfHal.h | 5 +++++ src/hms/cmtHal.h | 5 +++++ src/network/AhoyEthernetSpi.h | 5 +++++ src/plugins/Display/epdHal.h | 5 +++++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/applyPatches.py b/scripts/applyPatches.py index 3c38c100..83b28c23 100644 --- a/scripts/applyPatches.py +++ b/scripts/applyPatches.py @@ -28,9 +28,10 @@ def applyPatch(libName, patchFile): # list of patches to apply (relative to /src) applyPatch("ESPAsyncWebServer-esphome", "../patches/AsyncWeb_Prometheus.patch") -if env['PIOENV'][:13] == "opendtufusion": - applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") -elif env['PIOENV'][:5] == "esp32": +#if env['PIOENV'][:13] == "opendtufusion": + #applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") +#el +if (env['PIOENV'][:5] == "esp32") or (env['PIOENV'][:13] == "opendtufusion"): applyPatch("GxEPD2", "../patches/GxEPD2_HAL.patch") if (env['PIOENV'][:13] == "opendtufusion") or (env['PIOENV'][:5] == "esp32"): diff --git a/src/hm/nrfHal.h b/src/hm/nrfHal.h index a9bd89d2..a9228543 100644 --- a/src/hm/nrfHal.h +++ b/src/hm/nrfHal.h @@ -39,7 +39,12 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle { mPinEn = static_cast(en); mSpiSpeed = speed; + #if defined(CONFIG_IDF_TARGET_ESP32S3) + mHostDevice = SPI2_HOST; + #else mHostDevice = (14 == sclk) ? SPI2_HOST : SPI3_HOST; + #endif + mSpiPatcher = SpiPatcher::getInstance(mHostDevice); gpio_reset_pin(mPinMosi); diff --git a/src/hms/cmtHal.h b/src/hms/cmtHal.h index 58f79da4..13a14950 100644 --- a/src/hms/cmtHal.h +++ b/src/hms/cmtHal.h @@ -37,7 +37,12 @@ class cmtHal : public SpiPatcherHandle { mPinFcs = static_cast(fcs); mSpiSpeed = speed; + #if defined(CONFIG_IDF_TARGET_ESP32S3) + mHostDevice = SPI2_HOST; + #else mHostDevice = (14 == clk) ? SPI2_HOST : SPI3_HOST; + #endif + mSpiPatcher = SpiPatcher::getInstance(mHostDevice); gpio_reset_pin(mPinSdio); diff --git a/src/network/AhoyEthernetSpi.h b/src/network/AhoyEthernetSpi.h index 7b5bac85..4848de28 100644 --- a/src/network/AhoyEthernetSpi.h +++ b/src/network/AhoyEthernetSpi.h @@ -44,7 +44,12 @@ class AhoyEthernetSpi { gpio_reset_pin(static_cast(pin_int)); gpio_set_pull_mode(static_cast(pin_int), GPIO_PULLUP_ONLY); + #if defined(CONFIG_IDF_TARGET_ESP32S3) + mHostDevice = SPI3_HOST; + #else mHostDevice = (14 == pin_sclk) ? SPI2_HOST : SPI3_HOST; + #endif + mSpiPatcher = SpiPatcher::getInstance(mHostDevice); spi_device_interface_config_t devcfg = { diff --git a/src/plugins/Display/epdHal.h b/src/plugins/Display/epdHal.h index 4d2057dd..37763288 100644 --- a/src/plugins/Display/epdHal.h +++ b/src/plugins/Display/epdHal.h @@ -38,7 +38,12 @@ class epdHal: public GxEPD2_HalInterface, public SpiPatcherHandle { mPinBusy = static_cast(busy); mSpiSpeed = speed; + #if defined(CONFIG_IDF_TARGET_ESP32S3) + mHostDevice = SPI3_HOST; + #else mHostDevice = (14 == sclk) ? SPI2_HOST : SPI3_HOST; + #endif + mSpiPatcher = SpiPatcher::getInstance(mHostDevice); gpio_reset_pin(mPinMosi);