123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #include "SdFat.h"
- #define SD_FAT_TYPE 0
- #ifndef SDCARD_SS_PIN
- const uint8_t SD_CS_PIN = SS;
- #else
- const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
- #endif
- #define SPI_CLOCK SD_SCK_MHZ(50)
- #if HAS_SDIO_CLASS
- #define SD_CONFIG SdioConfig(FIFO_SDIO)
- #elif ENABLE_DEDICATED_SPI
- #define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
- #else
- #define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
- #endif
- #if SD_FAT_TYPE == 0
- SdFat sd;
- File dir;
- File file;
- #elif SD_FAT_TYPE == 1
- SdFat32 sd;
- File32 dir;
- File32 file;
- #elif SD_FAT_TYPE == 2
- SdExFat sd;
- ExFile dir;
- ExFile file;
- #elif SD_FAT_TYPE == 3
- SdFs sd;
- FsFile dir;
- FsFile file;
- #else
- #error invalid SD_FAT_TYPE
- #endif
- #define error(s) sd.errorHalt(&Serial, F(s))
- void setup() {
- Serial.begin(9600);
-
- while (!Serial) {
- yield();
- }
- Serial.println("Type any character to start");
- while (!Serial.available()) {
- yield();
- }
-
- if (!sd.begin(SD_CONFIG)) {
- sd.initErrorHalt(&Serial);
- }
-
- if (!dir.open("/")) {
- error("dir.open failed");
- }
-
-
-
- while (file.openNext(&dir, O_RDONLY)) {
- file.printFileSize(&Serial);
- Serial.write(' ');
- file.printModifyDateTime(&Serial);
- Serial.write(' ');
- file.printName(&Serial);
- if (file.isDir()) {
-
- Serial.write('/');
- }
- Serial.println();
- file.close();
- }
- if (dir.getError()) {
- Serial.println("openNext failed");
- } else {
- Serial.println("Done!");
- }
- }
- void loop() {}
|