Get external SPI SD reader working on M5StickC-Plus

This commit is contained in:
Noah Axon
2023-10-10 22:32:11 -05:00
parent f0bf1f4b7f
commit b8620e1bd3
2 changed files with 21 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
#include "SDInterface.h" #include "SDInterface.h"
#include "lang_var.h" #include "lang_var.h"
bool SDInterface::initSD() { bool SDInterface::initSD() {
#ifdef HAS_SD #ifdef HAS_SD
String display_string = ""; String display_string = "";
@@ -20,8 +21,23 @@ bool SDInterface::initSD() {
pinMode(SD_CS, OUTPUT); pinMode(SD_CS, OUTPUT);
delay(10); delay(10);
#if defined(MARAUDER_M5STICKC)
if (!SD.begin(SD_CS)) { /* Set up SPI SD Card using external pin header
StickCPlus Header - SPI SD Card Reader
3v3 - 3v3
GND - GND
G0 - CLK
G36/G25 - MISO
G26 - MOSI
- CS (jumper to SD Card GND Pin)
*/
enum { SPI_SCK = 0, SPI_MISO = 36, SPI_MOSI = 26 };
SPIClass SPI_EXT;
SPI_EXT.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SD_CS);
if (!SD.begin(SD_CS, SPI_EXT)) {
#else
if (!SD.begin(SD_CS)) {
#endif
Serial.println(F("Failed to mount SD Card")); Serial.println(F("Failed to mount SD Card"));
this->supported = false; this->supported = false;
return false; return false;
@@ -274,4 +290,4 @@ void SDInterface::main() {
this->initSD(); this->initSD();
} }
} }
} }

View File

@@ -639,7 +639,7 @@
#endif #endif
#ifdef MARAUDER_M5STICKC #ifdef MARAUDER_M5STICKC
#define SD_CS 10 #define SD_CS -1
#endif #endif
#ifdef MARAUDER_FLIPPER #ifdef MARAUDER_FLIPPER
@@ -808,4 +808,4 @@
#endif #endif
//// END MARAUDER TITLE STUFF //// END MARAUDER TITLE STUFF
#endif #endif