|
-
- #include <SPI.h>
- #include "SdFat.h"
-
-
- const uint8_t chipSelect = SS;
-
-
- SdFat sd;
-
-
- ArduinoOutStream cout(Serial);
-
-
- #define error(s) sd.errorHalt(F(s))
-
- void setup() {
-
- char name[] = "append.txt";
-
- Serial.begin(9600);
-
-
- while (!Serial) {
- SysCall::yield();
- }
-
- cout << endl << F("Type any character to start\n");
- while (!Serial.available()) {
- SysCall::yield();
- }
-
-
-
- if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {
- sd.initErrorHalt();
- }
-
- cout << F("Appending to: ") << name;
-
- for (uint8_t i = 0; i < 100; i++) {
-
- ofstream sdout(name, ios::out | ios::app);
- if (!sdout) {
- error("open failed");
- }
-
-
- for (uint8_t j = 0; j < 100; j++) {
-
- sdout << "line " << int(j) << " of pass " << int(i);
- sdout << " millis = " << millis() << endl;
- }
-
- sdout.close();
-
- if (!sdout) {
- error("append data failed");
- }
-
-
- if (i % 25 == 0) {
- cout << endl;
- }
- cout << '.';
- }
- cout << endl << "Done" << endl;
- }
-
- void loop() {}
|