You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
710B

  1. // Example to wipe all data from an already formatted SD.
  2. #include <SPI.h>
  3. #include "SdFat.h"
  4. const int chipSelect = SS;
  5. SdFat sd;
  6. void setup() {
  7. int c;
  8. Serial.begin(9600);
  9. while (!Serial) {} // wait for Leonardo
  10. Serial.println("Type 'Y' to wipe all data.");
  11. while ((c = Serial.read()) <= 0) {}
  12. if (c != 'Y') {
  13. sd.errorHalt("Quitting, you did not type 'Y'.");
  14. }
  15. if (!sd.begin(chipSelect)) {
  16. sd.initErrorHalt();
  17. }
  18. // Use wipe() for no dot progress indicator.
  19. if (!sd.wipe(&Serial)) {
  20. sd.errorHalt("Wipe failed.");
  21. }
  22. // Must reinitialize after wipe.
  23. if (!sd.begin(chipSelect)) {
  24. sd.errorHalt("Second init failed.");
  25. }
  26. Serial.println("Done");
  27. }
  28. void loop() {
  29. }