|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include <SerialFlash.h>
- #include <SPI.h>
-
- SerialFlashFile file;
-
- void setup() {
- char filename[40];
- uint32_t len;
-
- while (!Serial) ;
- delay(10);
-
- SPI.setSCK(14); // Audio shield has SCK on pin 14
- SPI.setMOSI(7); // Audio shield has MOSI on pin 7
-
- Serial.println("Test Hardware");
- SerialFlash.begin();
- #if 0
- Serial.println("erase");
- SerialFlash.eraseAll();
- while (!SerialFlash.ready()) {
- }
- Serial.println("erase done");
- #endif
-
- Serial.println("Directory:");
- while (SerialFlash.readdir(filename, sizeof(filename), len)) {
- Serial.print(" file: ");
- Serial.print(filename);
- Serial.print(" bytes: ");
- Serial.print(len);
- Serial.println();
- }
- Serial.println();
-
- Serial.println("simple.txt test");
- file = SerialFlash.open("simple.txt");
- if (file) {
- Serial.println(" file opened");
- Serial.print(" length = ");
- Serial.println(file.size());
- Serial.print(" addr on chip = ");
- Serial.println(file.getFlashAddress());
- file.close();
- } else {
- Serial.println(" create file");
- SerialFlash.create("simple.txt", 516);
- }
-
- Serial.println("soundfile.wav test");
- file = SerialFlash.open("soundfile.wav");
- if (file) {
- Serial.println(" file opened");
- Serial.print(" length = ");
- Serial.println(file.size());
- Serial.print(" addr on chip = ");
- Serial.println(file.getFlashAddress());
- file.close();
- } else {
- Serial.println(" create file");
- SerialFlash.createErasable("soundfile.wav", 3081000);
- }
-
- Serial.println("wavetable1 test");
- file = SerialFlash.open("wavetable1");
- if (file) {
- Serial.println(" file opened");
- Serial.print(" length = ");
- Serial.println(file.size());
- Serial.print(" addr on chip = ");
- Serial.println(file.getFlashAddress());
- file.close();
- } else {
- Serial.println(" create file");
- SerialFlash.create("wavetable1", 181003);
- }
-
- Serial.println("end");
- }
-
-
- void loop() {
-
- }
-
-
- void printbuf(const void *buf, uint32_t len)
- {
- const uint8_t *p = (const uint8_t *)buf;
- do {
- Serial.print(*p++);
- Serial.print(" ");
- } while (--len > 0);
- Serial.println();
- }
-
|