Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

60 rindas
1.3KB

  1. #include <SerialFlash.h>
  2. #include <SPI.h>
  3. const int FlashChipSelect = 6; // digital pin for flash chip CS pin
  4. void setup() {
  5. //uncomment these if using Teensy audio shield
  6. //SPI.setSCK(14); // Audio shield has SCK on pin 14
  7. //SPI.setMOSI(7); // Audio shield has MOSI on pin 7
  8. //uncomment these if you have other SPI chips connected
  9. //to keep them disabled while using only SerialFlash
  10. //pinMode(4, INPUT_PULLUP);
  11. //pinMode(10, INPUT_PULLUP);
  12. // wait for Arduino Serial Monitor
  13. while (!Serial) ;
  14. delay(100);
  15. Serial.println("All Files on SPI Flash chip:");
  16. if (!SerialFlash.begin(FlashChipSelect)) {
  17. error("Unable to access SPI Flash chip");
  18. }
  19. SerialFlash.opendir();
  20. unsigned int count = 0;
  21. while (1) {
  22. char filename[64];
  23. unsigned long filesize;
  24. if (SerialFlash.readdir(filename, sizeof(filename), filesize)) {
  25. Serial.print(" ");
  26. Serial.print(filename);
  27. spaces(20 - strlen(filename));
  28. Serial.print(" ");
  29. Serial.print(filesize);
  30. Serial.print(" bytes");
  31. Serial.println();
  32. } else {
  33. break; // no more files
  34. }
  35. }
  36. }
  37. void spaces(int num) {
  38. for (int i=0; i < num; i++) {
  39. Serial.print(" ");
  40. }
  41. }
  42. void loop() {
  43. }
  44. void error(const char *message) {
  45. while (1) {
  46. Serial.println(message);
  47. delay(2500);
  48. }
  49. }