My board: TTGO T-Display
Framework: Arduino
IDE: platformio
here is sample how I initialize SD:
Code: Select all
static SPIClass SD_SPI(VSPI);
void SDINIT(){
pinMode(SD_CS_PIN,OUTPUT); digitalWrite(SD_CS_PIN,1);
SD_SPI.begin(SD_SCK_PIN,SD_MISO_PIN,SD_MOSI_PIN,-1); // ESP32
if(!SD.begin(SD_CS_PIN,SD_SPI)){
LOG("Card Mount Failed\n");
SD_MOUNT = 0;
return;
}
// other initialize stuff here
}
Code: Select all
#include <esp32-hal-log.h>
void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
{
log_i("SPI.begin( %i,%i,%i,%i )",sck,miso,mosi,ss); // <-- I just added here some logs
if(_spi) {
return;
}
...
Code: Select all
[I][SPI.cpp:33] begin(): SPI.begin( 18,19,19,-1 ) <--- tft VSPI (tft_eSPI library)
[I][SPI.cpp:33] begin(): SPI.begin( 25,26,27,-1 ) <--- other SPI device HSPI (its time critical so I need to use separate SPI bus)
[I][SPI.cpp:33] begin(): SPI.begin( 33,32,15,-1 ) <--- SD VSPI
[E][esp32-hal-cpu.c:93] addApbChangeCallback(): duplicate func=400D7964 arg=3FFBDCAC
[I][SPI.cpp:33] begin(): SPI.begin( -1,-1,-1,-1 ) <--- its because SD.begin(SD_CS_PIN,SD_SPI)->spi.begin()