From 232ee865a50c94ac17d71d20fc0afeae99bfc1a1 Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Sun, 30 Jun 2024 21:39:28 +0200 Subject: [PATCH] fix back MMC support --- .../components/files/FilesComponent.cpp | 23 ++++++++++--------- .../components/files/FilesComponent.h | 4 +++- Firmware/Bentuino/src/UnityIncludes.h | 6 ++--- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Firmware/Bentuino/src/Component/components/files/FilesComponent.cpp b/Firmware/Bentuino/src/Component/components/files/FilesComponent.cpp index e545cd9..3025c3b 100644 --- a/Firmware/Bentuino/src/Component/components/files/FilesComponent.cpp +++ b/Firmware/Bentuino/src/Component/components/files/FilesComponent.cpp @@ -6,6 +6,18 @@ bool FilesComponent::initInternal(JsonObject o) { useInternalMemory = false; + bool mounted = false; +#ifdef FILES_TYPE_MMC + + NDBG("Init SD MMC"); + if (SD_MMC.begin("/sdcard", true)) // if using ESP32 package 3.x.x + { + mounted = true; + } +#else + + NDBG("Init SD SPI"); + AddIntParamConfig(sdEnPin); AddBoolParamConfig(sdEnVal); AddIntParamConfig(sdSCK); @@ -37,17 +49,6 @@ bool FilesComponent::initInternal(JsonObject o) return initInternalMemory(); } - bool mounted = false; -#ifdef FILES_MMC_TYPE - - NDBG("Init SD MMC"); - if (SD_MMC.begin("/sdcard", true)) // if using ESP32 package 3.x.x - { - mounted = true; - } -#else - - NDBG("Init SD SPI"); // NDBG("initilializing SD with pins SCK,MISO,MOSI,CS,Speed : " + sdSCK.stringValue() + "," + sdMiso.stringValue() + "," + sdMosi.stringValue() + "," + sdCS.stringValue() + "," + sdSpeed.stringValue()); pinMode(sdSCK, INPUT_PULLUP); pinMode(sdMiso, INPUT_PULLUP); diff --git a/Firmware/Bentuino/src/Component/components/files/FilesComponent.h b/Firmware/Bentuino/src/Component/components/files/FilesComponent.h index 15ed5a7..1b1d1dc 100644 --- a/Firmware/Bentuino/src/Component/components/files/FilesComponent.h +++ b/Firmware/Bentuino/src/Component/components/files/FilesComponent.h @@ -36,6 +36,7 @@ bool handleCommandInternal(const String &command, var *data, int numData) overri DeclareComponentEventTypes(UploadStart, UploadProgress, UploadComplete, UploadCancel, FileList); DeclareComponentEventNames("uploadStart", "uploadProgress", "uploadComplete", "uploadCancel", "list"); +#ifdef FILES_TYPE_SD HandleSetParamInternalStart CheckAndSetParam(sdEnPin); CheckAndSetParam(sdEnVal); @@ -65,5 +66,6 @@ FillOSCQueryIntParam(sdMosi); FillOSCQueryIntParam(sdCS); FillOSCQueryIntParam(sdSpeed); FillOSCQueryInternalEnd +#endif - EndDeclareComponent \ No newline at end of file + EndDeclareComponent diff --git a/Firmware/Bentuino/src/UnityIncludes.h b/Firmware/Bentuino/src/UnityIncludes.h index bd5f275..c128ded 100644 --- a/Firmware/Bentuino/src/UnityIncludes.h +++ b/Firmware/Bentuino/src/UnityIncludes.h @@ -36,11 +36,11 @@ #ifdef USE_FILES -#ifndef FILES_MMC_TYPE -#define FILES_SD_TYPE +#ifndef FILES_TYPE_MMC +#define FILES_TYPE_SD #endif -#ifdef FILES_MMC_TYPE +#ifdef FILES_TYPE_MMC #include "SD_MMC.h" #else #include "SD.h"