|
-
- #include "SdFat.h"
-
-
-
-
- #ifndef SDCARD_SS_PIN
- const uint8_t SD_CS_PIN = SS;
- #else
-
- const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
- #endif
-
-
- #if HAS_SDIO_CLASS
-
- #define SD_CONFIG SdioConfig(FIFO_SDIO)
-
- #elif ENABLE_DEDICATED_SPI
- #define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
- #else
- #define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
- #endif
-
- SdExFat sd;
-
- void errorHalt() {
- sd.printSdError(&Serial);
- SysCall::halt();
- }
- #define error(s) (Serial.println(F(s)),errorHalt())
-
- void setup() {
- Serial.begin(9600);
- while (!Serial) {}
- Serial.println(F("Type any character to begin"));
-
- while (!Serial.available()) {
- yield();
- }
- do {
- delay(10);
- } while(Serial.read() >= 0);
-
- Serial.println();
- Serial.println(F(
- "Your SD will be formated exFAT.\r\n"
- "All data on the SD will be lost.\r\n"
- "Type 'Y' to continue.\r\n"));
-
- while (!Serial.available()) {
- yield();
- }
- if (Serial.read() != 'Y') {
- Serial.println(F("Exiting, 'Y' not typed."));
- return;
- }
- if (!sd.cardBegin(SD_CONFIG)) {
- error("cardBegin failed");
- }
- if(!sd.format(&Serial)) {
- error("format failed");
- }
- if (!sd.volumeBegin()) {
- error("volumeBegin failed");
- }
- Serial.print(F("Bytes per cluster: "));
- Serial.println(sd.bytesPerCluster());
- Serial.println(F("Done"));
- }
- void loop() {
- }
|