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

Added SD functionality to T-beam board #25

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion main/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[env:ttgo-t-beam]
build_unflags = -std=gnu++11
build_flags = -std=gnu++17 -Wall
build_flags = -std=gnu++17 -Wall -DSD_CUSTOM_SPI=1 -DSD_SCK=25 -DSD_MISO=15 -DSD_MOSI=32 -DSD_SS=33
build_src_flags = -Wextra -Werror
platform = espressif32
board = ttgo-t-beam
Expand Down
14 changes: 13 additions & 1 deletion main/src/sd_card.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#include "sd_card.h"

namespace sd {

namespace {
fs::File File;
}

bool SDBegin() {
#ifdef SD_CUSTOM_SPI
SPIClass spi(VSPI);
spi.begin(SD_SCK, SD_MISO, SD_MOSI, SD_SS);
return SD.begin(sd::DEFAULT_DATA_PIN, spi);
#else
return SD.begin(sd::DEFAULT_DATA_PIN);
#endif
}

void init() {
if (!SD.begin(sd::DEFAULT_DATA_PIN)) {
if (!SDBegin()) {
Serial.println("Card Mount Failed");
return;
}
Expand Down