Skip to content
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
20 changes: 20 additions & 0 deletions libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,25 @@ void testFileIO(fs::FS &fs, const char *path) {
file.close();
}

void testRawIO(uint32_t sectors, uint8_t sequential) {
uint32_t readSect = 0;
uint32_t startTime = millis();
uint8_t* buf = (uint8_t*)heap_caps_malloc(SD_MMC.sectorSize(), MALLOC_CAP_DMA);
for (uint32_t x=0; x<sectors; x++) {
if (! SD_MMC.readRAW(buf, readSect)) {
log_e("Unable to read sector %lu\n", readSect);
free(buf);
return;
}
readSect = sequential ? readSect + 1 : random(SD_MMC.numSectors()-1);
}
uint32_t passed = millis() - startTime;
uint32_t rate = sectors * SD_MMC.sectorSize() / passed;
Serial.printf("%lu %s sectors read in %lu msec (%luKB/s)\n",
sectors, sequential ? "sequential" : "random", passed, rate);
free(buf);
}

void setup() {
Serial.begin(115200);
/*
Expand Down Expand Up @@ -262,6 +281,7 @@ void setup() {
renameFile(SD_MMC, "/hello.txt", "/foo.txt");
readFile(SD_MMC, "/foo.txt");
testFileIO(SD_MMC, "/test.txt");
testRawIO(2000, 1);
Serial.printf("Total space: %lluMB\n", SD_MMC.totalBytes() / (1024 * 1024));
Serial.printf("Used space: %lluMB\n", SD_MMC.usedBytes() / (1024 * 1024));
}
Expand Down
9 changes: 9 additions & 0 deletions libraries/SD_MMC/src/SD_MMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_
.width = 4,
.flags = 0,
};
#ifdef SOC_SDMMC_UHS_I_SUPPORTED
if (sdmmc_frequency == SDMMC_FREQ_DDR50) {
host.flags |= SDMMC_HOST_FLAG_DDR;
slot_config.flags = SDMMC_SLOT_FLAG_UHS1;
}
if (sdmmc_frequency == SDMMC_FREQ_SDR50) {
slot_config.flags = SDMMC_SLOT_FLAG_UHS1;
}
#endif
#else
host.slot = SDMMC_HOST_SLOT_1;
#endif
Expand Down
4 changes: 4 additions & 0 deletions libraries/SD_MMC/src/SD_MMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
// you can define BOARD_MAX_SDMMC_FREQ with lower value (Ex. SDMMC_FREQ_DEFAULT)
// in pins_arduino.h for your board variant.
#ifndef BOARD_MAX_SDMMC_FREQ
#ifdef SOC_SDMMC_UHS_I_SUPPORTED
#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_SDR50
#else
#define BOARD_MAX_SDMMC_FREQ SDMMC_FREQ_HIGHSPEED
#endif
#endif

namespace fs {

Expand Down
Loading