Skip to content

Commit 3892bc7

Browse files
committed
Support SDCard on SPI bus 2 (if present)
1 parent 6317a8a commit 3892bc7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tasmota/include/tasmota_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ const uint16_t kGpioNiceList[] PROGMEM = {
656656
AGPIO(GPIO_RC522_RST), // RC522 Rfid Reset
657657
#endif
658658
#ifdef USE_SDCARD
659-
AGPIO(GPIO_SDCARD_CS), // SDCard in SPI mode
659+
AGPIO(GPIO_SDCARD_CS) + AGMAX(MAX_SPI), // SDCard in SPI mode
660660
#endif // USE_SDCARD
661661
#if defined(USE_MCP2515) || defined(USE_CANSNIFFER)
662662
AGPIO(GPIO_MCP2515_CS),

tasmota/tasmota_xdrv_driver/xdrv_50_filesystem.ino

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,26 @@ char *fileOnly(char *fname){
194194
void UfsCheckSDCardInit(void) {
195195
// Try SPI mode first
196196
// SPI mode requires SDCARD_CS to be configured
197+
/*
197198
if (TasmotaGlobal.spi_enabled && PinUsed(GPIO_SDCARD_CS)) {
198199
int8_t cs = Pin(GPIO_SDCARD_CS);
200+
*/
201+
uint32_t spi_bus = 0;
202+
int8_t cs = -1;
203+
if (TasmotaGlobal.spi_enabled && PinUsed(GPIO_SDCARD_CS)) {
204+
cs = Pin(GPIO_SDCARD_CS);
205+
}
206+
if (TasmotaGlobal.spi_enabled2 && PinUsed(GPIO_SDCARD_CS, 1)) {
207+
spi_bus = 1;
208+
cs = Pin(GPIO_SDCARD_CS, 1);
209+
}
210+
if (cs > -1) {
199211

200212
#ifdef ESP8266
201213
SPI.begin();
202214
#endif // ESP8266
203215
#ifdef ESP32
204-
SPI.begin(Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), -1);
216+
SPI.begin(Pin(GPIO_SPI_CLK, spi_bus), Pin(GPIO_SPI_MISO, spi_bus), Pin(GPIO_SPI_MOSI, spi_bus), -1);
205217
#endif // ESP32
206218

207219
if (SD.begin(cs)) {

0 commit comments

Comments
 (0)