Skip to content

Commit

Permalink
Get external SPI SD reader working on M5StickC-Plus
Browse files Browse the repository at this point in the history
  • Loading branch information
n0xa committed Oct 11, 2023
1 parent f0bf1f4 commit b8620e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions esp32_marauder/SDInterface.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "SDInterface.h"
#include "lang_var.h"


bool SDInterface::initSD() {
#ifdef HAS_SD
String display_string = "";
Expand All @@ -20,8 +21,23 @@ bool SDInterface::initSD() {
pinMode(SD_CS, OUTPUT);

delay(10);

if (!SD.begin(SD_CS)) {
#if defined(MARAUDER_M5STICKC)
/* 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"));
this->supported = false;
return false;
Expand Down Expand Up @@ -274,4 +290,4 @@ void SDInterface::main() {
this->initSD();
}
}
}
}
4 changes: 2 additions & 2 deletions esp32_marauder/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@
#endif

#ifdef MARAUDER_M5STICKC
#define SD_CS 10
#define SD_CS -1
#endif

#ifdef MARAUDER_FLIPPER
Expand Down Expand Up @@ -808,4 +808,4 @@
#endif
//// END MARAUDER TITLE STUFF

#endif
#endif

0 comments on commit b8620e1

Please sign in to comment.