From 29df10d8377e9b50fd03c015ab9e354c7c0c560e Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 9 Jan 2021 08:51:27 +0100 Subject: [PATCH] fix spi init issues --- tasmota/xdrv_50_filesystem.ino | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index 527b43dd6..fe35234df 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -100,6 +100,7 @@ void UfsInitOnce(void) { #ifdef ESP8266 ffsp = &LittleFS; if (!LittleFS.begin()) { + ffsp = 0; return; } #endif // ESP8266 @@ -137,13 +138,27 @@ void UfsInit(void) { #ifdef USE_SDCARD void UfsCheckSDCardInit(void) { + +#ifdef ESP8266 + if (PinUsed(GPIO_SPI_CLK) && PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_MISO)) { +#endif // ESP8266 + +#ifdef ESP32 if (TasmotaGlobal.spi_enabled) { - // if (1) { +#endif // ESP32 int8_t cs = SDCARD_CS_PIN; if (PinUsed(GPIO_SDCARD_CS)) { cs = Pin(GPIO_SDCARD_CS); } +#ifdef EPS8266 + SPI.begin(); +#endif // EPS8266 + +#ifdef ESP32 + SPI.begin(Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), -1); +#endif // ESP32 + if (SD.begin(cs)) { #ifdef ESP8266 ufsp = &SDFS; @@ -154,7 +169,7 @@ void UfsCheckSDCardInit(void) { #endif // ESP32 ufs_type = UFS_TSDC; dfsp = ufsp; - ufs_dir = 1; + if (ffsp) {ufs_dir = 1;} // make sd card the global filesystem #ifdef ESP8266 // on esp8266 sdcard info takes several seconds !!!, so we ommit it here