您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
1.0KB

  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. // Wait for USB Serial
  10. while (!Serial) {
  11. SysCall::yield();
  12. }
  13. Serial.println("Type 'Y' to wipe all data.");
  14. while (!Serial.available()) {
  15. SysCall::yield();
  16. }
  17. c = Serial.read();
  18. if (c != 'Y') {
  19. sd.errorHalt("Quitting, you did not type 'Y'.");
  20. }
  21. // Initialize at the highest speed supported by the board that is
  22. // not over 50 MHz. Try a lower speed if SPI errors occur.
  23. if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
  24. sd.initErrorHalt();
  25. }
  26. // Use wipe() for no dot progress indicator.
  27. if (!sd.wipe(&Serial)) {
  28. sd.errorHalt("Wipe failed.");
  29. }
  30. // Must reinitialize after wipe.
  31. // Initialize at the highest speed supported by the board that is
  32. // not over 50 MHz. Try a lower speed if SPI errors occur.
  33. if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
  34. sd.errorHalt("Second init failed.");
  35. }
  36. Serial.println("Done");
  37. }
  38. void loop() {
  39. }