Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get external SPI SD reader working on M5StickC-Plus #350

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading