mac-floppy-emu/floppy-emu-source-1.0L-F11/AVR/SdFat/examples/OpenNext/OpenNext.pde

36 lines
942 B
Plaintext
Executable File

/*
* Open all files in the root dir and print their filename
*/
#include <SdFat.h>
// SD chip select pin
const uint8_t chipSelect = SS_PIN;
// file system object
SdFat sd;
SdFile file;
// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup() {
char name[13];
Serial.begin(9600);
// initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
// breadboards. use SPI_FULL_SPEED for better performance.
if (!sd.init(SPI_HALF_SPEED, chipSelect)) sd.initErrorHalt();
// open next file in root. The volume working directory, vwd, is root
while (file.openNext(sd.vwd(), O_READ)) {
file.getFilename(name);
cout << name << endl;
file.close();
}
cout << "Done" << endl;
}
//------------------------------------------------------------------------------
void loop() {}