From 2aed417d09be57db5bef3ac20e91515a6dbaacab Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 1 Aug 2017 18:16:48 +0300 Subject: [PATCH] Enable 1bit SDMMC for Olimex ESP32-EVB Fixes: https://github.com/espressif/arduino-esp32/issues/495#issuecomment-31604 2612 --- libraries/SD_MMC/src/SD_MMC.cpp | 9 +++++++-- libraries/SD_MMC/src/SD_MMC.h | 2 +- variants/esp32-evb/pins_arduino.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/SD_MMC/src/SD_MMC.cpp b/libraries/SD_MMC/src/SD_MMC.cpp index cc3f1791..54b97c1e 100644 --- a/libraries/SD_MMC/src/SD_MMC.cpp +++ b/libraries/SD_MMC/src/SD_MMC.cpp @@ -34,7 +34,7 @@ SDMMCFS::SDMMCFS(FSImplPtr impl) : FS(impl), _card(NULL) {} -bool SDMMCFS::begin(const char * mountpoint) +bool SDMMCFS::begin(const char * mountpoint, bool mode1bit) { if(_card) { return true; @@ -43,7 +43,12 @@ bool SDMMCFS::begin(const char * mountpoint) sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT(); sdmmc_host_t host = SDMMC_HOST_DEFAULT(); host.max_freq_khz = SDMMC_FREQ_HIGHSPEED; - //host.flags = SDMMC_HOST_FLAG_1BIT; //use 1-line SD mode +#ifdef BOARD_HAS_1BIT_SDMMC + mode1bit = true; +#endif + if(mode1bit) { + host.flags = SDMMC_HOST_FLAG_1BIT; //use 1-line SD mode + } esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = false, diff --git a/libraries/SD_MMC/src/SD_MMC.h b/libraries/SD_MMC/src/SD_MMC.h index 51d9e8e6..fad774cb 100644 --- a/libraries/SD_MMC/src/SD_MMC.h +++ b/libraries/SD_MMC/src/SD_MMC.h @@ -28,7 +28,7 @@ protected: public: SDMMCFS(FSImplPtr impl); - bool begin(const char * mountpoint="/sdcard"); + bool begin(const char * mountpoint="/sdcard", bool mode1bit=false); void end(); sdcard_type_t cardType(); uint64_t cardSize(); diff --git a/variants/esp32-evb/pins_arduino.h b/variants/esp32-evb/pins_arduino.h index 0a5a17bc..1153c77c 100644 --- a/variants/esp32-evb/pins_arduino.h +++ b/variants/esp32-evb/pins_arduino.h @@ -25,4 +25,6 @@ static const uint8_t MOSI = 2; static const uint8_t MISO = 15; static const uint8_t SCK = 14; +#define BOARD_HAS_1BIT_SDMMC + #endif /* Pins_Arduino_h */