123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #define SFN_PATH "/DIR/TEST.TXT"
- #define CS_PIN SS
- #define USE_SD_H 0
- #if USE_SD_H
- #include "SD.h"
- File file;
- #else
- #include "SdFat.h"
- #if ENABLE_DEDICATED_SPI
- #warning \
- "Set ENABLE_DEDICATED_SPI zero in SdFat/src/SdFatConfig.h for minimum size"
- #endif
- SdFat32 SD;
- FatFile file;
- #endif
- void error(const char* msg) {
- Serial.println(msg);
- while (true) {
- }
- }
- void setup() {
- int n;
- char buf[4];
- Serial.begin(9600);
- while (!Serial) {
- }
- Serial.println("Type any character to begin");
- while (!Serial.available()) {
- }
- if (!SD.begin(CS_PIN)) error("SD.begin");
- #if USE_SD_H
- file = SD.open(SFN_PATH);
- if (!file) error("open");
- #else
-
-
- if (!file.openExistingSFN(SFN_PATH)) error("open");
- #endif
- while ((n = file.read(buf, sizeof(buf)))) {
- Serial.write(buf, n);
- }
-
-
-
- }
- void loop() {}
|