diff --git a/ESPixelStick/src/FileMgr.cpp b/ESPixelStick/src/FileMgr.cpp index 21825f110..1c6abf231 100644 --- a/ESPixelStick/src/FileMgr.cpp +++ b/ESPixelStick/src/FileMgr.cpp @@ -24,7 +24,16 @@ #include "FileMgr.hpp" #include "network/NetworkMgr.hpp" -SdFat sd; +SdFs sd; +const int8_t DISABLE_CS_PIN = -1; + +#if HAS_SDIO_CLASS +#define SD_CONFIG SdioConfig(FIFO_SDIO) +#elif ENABLE_DEDICATED_SPI +#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SD_SCK_MHZ(16)) +#else // HAS_SDIO_CLASS +#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SD_SCK_MHZ(16)) +#endif // HAS_SDIO_CLASS oflag_t XlateFileMode[3] = { O_READ , O_WRITE | O_CREAT, O_WRITE | O_APPEND }; #ifdef SUPPORT_FTP @@ -373,16 +382,13 @@ void c_FileMgr::SetSpiIoPins () // DEBUG_V(); pinMode(miso_pin, INPUT); # endif // def USE_MISO_PULLUP - SPI.begin (clk_pin, miso_pin, mosi_pin, cs_pin); + SPI.begin (clk_pin, miso_pin, mosi_pin, cs_pin); // uses HSPI by default # else // ESP8266 SPI.end (); SPI.begin (); # endif // ! ARDUINO_ARCH_ESP32 // DEBUG_V(); - ResetSdCard(); - - // DEBUG_V(); - if (!ESP_SD.begin (SdSpiConfig(cs_pin, SHARED_SPI, SD_CARD_CLK_MHZ, &SPI))) + if (!ESP_SD.begin (SdSpiConfig(cs_pin, SHARED_SPI, SD_SCK_MHZ(16)))) #endif // !def SUPPORT_SD_MMC { // DEBUG_V(); @@ -1192,11 +1198,11 @@ bool c_FileMgr::OpenSdFile (const String & FileName, FileMode Mode, FileId & Fil // DEBUG_V (); - // DEBUG_V (String("FileName: '") + FileNamePrefix + FileName + "'"); + // DEBUG_V (String("FileName: '") + FileName + "'"); if (FileMode::FileRead == Mode) { - // DEBUG_V (String("Read FIle")); + // DEBUG_V (String("Read mode")); if (false == ESP_SD.exists (FileName)) { logcon (String (F ("ERROR: Cannot find '")) + FileName + F ("' for reading. File does not exist.")); @@ -1221,7 +1227,7 @@ bool c_FileMgr::OpenSdFile (const String & FileName, FileMode Mode, FileId & Fil FileHandle = FileList[FileListIndex].handle; } - // did we get an index + // DEBUG_V("did we get an index"); if (-1 != FileListIndex) { // DEBUG_V(String("Valid FileListIndex: ") + String(FileListIndex)); diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_BreakDanceV2.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_BreakDanceV2.hpp index 1cb2e8edf..f23cfc1a0 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_BreakDanceV2.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_BreakDanceV2.hpp @@ -28,7 +28,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_27 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_32 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_3 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_5 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI.hpp index c8d04903a..bb2f64886 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI.hpp @@ -30,7 +30,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_15 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_25 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_21 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_22 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI_ETH.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI_ETH.hpp index 4b4b1464a..18dc02ab8 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI_ETH.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_D1_MINI_ETH.hpp @@ -41,7 +41,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_15 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_25 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #include diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_DevkitC.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_DevkitC.hpp index 9b1cab120..34d3ae273 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_DevkitC.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_DevkitC.hpp @@ -31,7 +31,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_16 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_17 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_3 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_5 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_KA.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_KA.hpp index be24e5759..5b0245454 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_KA.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_KA.hpp @@ -28,7 +28,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_15 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_25 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_21 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_22 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp index 542cf966e..88b380b13 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp @@ -28,7 +28,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_27 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_32 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_3 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_5 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_MH_ET_LIVE_MiniKit.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_MH_ET_LIVE_MiniKit.hpp index bbd7eb69c..6812e4ce6 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_MH_ET_LIVE_MiniKit.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_MH_ET_LIVE_MiniKit.hpp @@ -33,7 +33,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_16 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_17 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_21 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_22 diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_Tetra2go.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_Tetra2go.hpp index e236a8b0b..d42a5cc9e 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_Tetra2go.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_Tetra2go.hpp @@ -28,7 +28,7 @@ #define SUPPORT_SPI_OUTPUT #define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_15 #define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_25 -#define DEFAULT_SPI_DEVICE HSPI_HOST +#define DEFAULT_SPI_DEVICE VSPI_HOST #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_21 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_22 diff --git a/platformio.ini b/platformio.ini index b8312ba18..f343a7b7c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,13 +31,20 @@ lib_deps = https://github.com/MartinMueller2003/Artnet https://github.com/MartinMueller2003/Espalexa ; pull latest https://github.com/PaulStoffregen/Time - https://github.com/greiman/SdFat + https://github.com/greiman/SdFat @ 2.2.3 https://github.com/MartinMueller2003/SimpleFTPServer extra_scripts = .scripts/download_fs.py .scripts/CopyTargets.py pre:.scripts/pio-version.py build_flags = +; -D ENABLE_DEDICATED_SPI=1 ; instruct SdFat to take ownership of the spi device + -D SDFAT_FILE_TYPE=3 ; SdFat full support + -D USE_LONG_FILE_NAMES=1 ; SdFat + -D MAINTAIN_FREE_CLUSTER_COUNT=1 ; SdFat + -D CHECK_FLASH_PROGRAMMING=0 ; SdFat + -D INCLUDE_SDIOS=1 ; SdFat +; -D USE_DBG_MACROS=2 ; SdFat -D SUPPORT_FTP ; -D FTP_SERVER_DEBUG ; -D FTP_ADDITIONAL_DEBUG