M5StickCPlus Card Mount Failed
-
Trying to connect SD Card Module via External SPI. Keep getting Card Mount Failed. Tried with both 3.3 and 5v external power. Can someone please tell me what I'm doing wrong?
#include <M5StickCPlus.h>
#include "SD.h"
SPIClass SPI_EXT;
// PIN配置
enum { spi_sck = 0, spi_miso = 36, spi_mosi = 26, spi_ss = -1 };
void setup()
{
// M5StickC initialize
M5.begin();
M5.Lcd.setRotation(3);
// SPI initialize
SPI_EXT.begin(spi_sck, spi_miso, spi_mosi, spi_ss);
// SD initialize
if (!SD.begin(spi_ss, SPI_EXT)) {
M5.Lcd.println("Card Mount Failed");
return;
}
// SD check
uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
M5.Lcd.println("None SD Card");
return;
}
M5.Lcd.print("SD Card Type: ");
if (cardType == CARD_MMC) {
M5.Lcd.println("MMC");
} else if (cardType == CARD_SD) {
M5.Lcd.println("SDSC");
} else if (cardType == CARD_SDHC) {
M5.Lcd.println("SDHC");
} else {
M5.Lcd.println("UNKNOWN");
}
// SD volume
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
M5.Lcd.printf("SD Card Size: %lluMB\n", cardSize);
}
void loop() {
}