Skip to content

Commit fb74151

Browse files
committed
Fix SdInfo example and file.timestamp. Remove Syscall::yield and SysCall::halt
Fix SdInfo example and file.timestamp. Remove Syscall::yield and SysCall::halt. Major restructuring for future portability to RTOS systems and RPI Pico.
1 parent a5e4bde commit fb74151

File tree

168 files changed

+1493
-1655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1493
-1655
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Earlier releases of Version 1 are here:
44

55
https://github.com/greiman/SdFat/releases
66

7-
###### UTF-8 encoded filenames are supported in v2.1.0.
7+
UTF-8 encoded filenames are supported in v2.1.0 or later.
88

99
Try the UnicodeFilenames example. Here is output from ls:
1010
<pre>

doc/Doxyfile

Lines changed: 410 additions & 241 deletions
Large diffs are not rendered by default.

doc/html.zip

31.9 KB
Binary file not shown.

doc/mainpage.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2011-2020 Bill Greiman
2+
* Copyright (c) 2011-2021 Bill Greiman
33
* This file is part of the SdFat library for SD memory cards.
44
*
55
* MIT License
@@ -249,11 +249,9 @@ DirectoryFunctions - Use of chdir(), ls(), mkdir(), and rmdir().
249249
250250
examplesV1 folder - Examples from SdFat V1 for compatibility tests.
251251
252-
%ExFatFormatter - Produces optimal exFAT format for smaller SD cards.
253-
254252
ExFatLogger - A data-logger optimized for exFAT features.
255253
256-
ExFatUnicodeTest - Test program for Unicode file names.
254+
MinimumSizeSdReader - Example of small file reader for FAT16/FAT32.
257255
258256
OpenNext - Open all files in the root dir and print their filename.
259257
@@ -275,10 +273,16 @@ SoftwareSpi - Demo of limited Software SPI support in SdFat V2.
275273
276274
STM32Test - Example use of two SPI ports on an STM32 board.
277275
276+
TeensyDmaAdcLogger - Fast logger using DMA ADC.
277+
278278
TeensyRtcTimestamp - %File timestamps for Teensy3.
279279
280280
TeensySdioDemo - Demo of SDIO and SPI modes for the Teensy 3.5/3.6 built-in SD.
281281
282+
TeensySdioLogger - Fast logger using a ring buffer.
283+
284+
UnicodeFilenames - Test program for Unicode file names.
285+
282286
UserChipSelectFunction - Useful for port expanders or replacement of the standard GPIO functions.
283287
284288
UserSPIDriver - An example of an external SPI driver.

examples/AvrAdcLogger/AvrAdcLogger.ino

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ MinimumSerial MinSerial;
3434
//------------------------------------------------------------------------------
3535
// This example was designed for exFAT but will support FAT16/FAT32.
3636
//
37-
// If an exFAT SD is required, the ExFatFormatter example will format
38-
// smaller cards with an exFAT file system.
39-
//
4037
// Note: Uno will not support SD_FAT_TYPE = 3.
4138
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
4239
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
@@ -152,9 +149,9 @@ const uint16_t ISR_TIMER0 = 160;
152149
//==============================================================================
153150
const uint32_t MAX_FILE_SIZE = MAX_FILE_SIZE_MiB << 20;
154151

155-
// Select fastest interface. Max SPI rate for AVR is 10 MHx.
152+
// Max SPI rate for AVR is 10 MHz for F_CPU 20 MHz, 8 MHz for F_CPU 16 MHz.
156153
#define SPI_CLOCK SD_SCK_MHZ(10)
157-
154+
// Select fastest interface.
158155
#if ENABLE_DEDICATED_SPI
159156
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
160157
#else // ENABLE_DEDICATED_SPI
@@ -868,7 +865,7 @@ void loop(void) {
868865
Serial.println(F("r - record ADC data"));
869866

870867
while(!Serial.available()) {
871-
SysCall::yield();
868+
yield();
872869
}
873870
char c = tolower(Serial.read());
874871
Serial.println();

examples/DirectoryFunctions/DirectoryFunctions.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ void setup() {
6666

6767
// Wait for USB Serial
6868
while (!Serial) {
69-
SysCall::yield();
69+
yield();
7070
}
7171
delay(1000);
7272
cout << F("Type any character to start\n");
7373
while (!Serial.available()) {
74-
SysCall::yield();
74+
yield();
7575
}
7676

7777
// Initialize the SD card.

examples/ExFatLogger/ExFatLogger.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void setup() {
516516

517517
// Wait for USB Serial
518518
while (!Serial) {
519-
SysCall::yield();
519+
yield();
520520
}
521521
delay(1000);
522522
Serial.println(F("Type any character to begin"));
@@ -568,7 +568,7 @@ void loop() {
568568
Serial.println(F("r - record data"));
569569
Serial.println(F("t - test without logging"));
570570
while(!Serial.available()) {
571-
SysCall::yield();
571+
yield();
572572
}
573573
char c = tolower(Serial.read());
574574
Serial.println();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Create a text file on the SD with this path using short 8.3 names.
2+
#define SFN_PATH "/DIR/TEST.TXT"
3+
4+
// Modify CS_PIN for your chip select pin.
5+
#define CS_PIN SS
6+
7+
// Set USE_SD_H to one for SD.h or zero for SdFat.
8+
#define USE_SD_H 0
9+
10+
#if USE_SD_H
11+
#include "SD.h"
12+
File file;
13+
#else
14+
#include "SdFat.h"
15+
// Setting ENABLE_DEDICATED_SPI to zero saves over 200 more bytes.
16+
#if ENABLE_DEDICATED_SPI
17+
#warning "Set ENABLE_DEDICATED_SPI zero in SdFat/src/SdFatConfig.h for minimum size"
18+
#endif // ENABLE_DEDICATED_SPI
19+
// Insure FAT16/FAT32 only.
20+
SdFat32 SD;
21+
// FatFile does not support Stream functions, just simple read/write.
22+
FatFile file;
23+
#endif
24+
25+
void error(const char* msg) {
26+
Serial.println(msg);
27+
while(true);
28+
}
29+
30+
void setup() {
31+
int n;
32+
char buf[4];
33+
34+
Serial.begin(9600);
35+
while (!Serial) {}
36+
Serial.println("Type any character to begin");
37+
while (!Serial.available()) {}
38+
39+
if (!SD.begin(CS_PIN)) error("SD.begin");
40+
41+
#if USE_SD_H
42+
file = SD.open(SFN_PATH);
43+
if (!file) error("open");
44+
#else
45+
// Open existing file with a path of 8.3 names.
46+
// Directories will be opened O_RDONLY files O_RDWR.
47+
if (!file.openExistingSFN(SFN_PATH)) error("open");
48+
#endif
49+
while ((n = file.read(buf, sizeof(buf)))) {
50+
Serial.write(buf, n);
51+
}
52+
// close() is only needed if you write to the file. For example, read
53+
// config data, modify the data, rewind the file and write the data.
54+
// file.close();
55+
}
56+
57+
void loop() {
58+
}

examples/OpenNext/OpenNext.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ void setup() {
6363

6464
// Wait for USB Serial
6565
while (!Serial) {
66-
SysCall::yield();
66+
yield();
6767
}
6868

6969
Serial.println("Type any character to start");
7070
while (!Serial.available()) {
71-
SysCall::yield();
71+
yield();
7272
}
7373

7474
// Initialize the SD.

examples/QuickStart/QuickStart.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void setup() {
6868

6969
// Wait for USB Serial
7070
while (!Serial) {
71-
SysCall::yield();
71+
yield();
7272
}
7373
cout << F("\nSPI pins:\n");
7474
cout << F("MISO: ") << int(MISO) << endl;
@@ -106,7 +106,7 @@ void loop() {
106106

107107
cout << F("\nEnter the chip select pin number: ");
108108
while (!Serial.available()) {
109-
SysCall::yield();
109+
yield();
110110
}
111111
cin.readline();
112112
if (cin >> chipSelect) {
@@ -182,6 +182,6 @@ void loop() {
182182

183183
cout << F("\nSuccess! Type any character to restart.\n");
184184
while (!Serial.available()) {
185-
SysCall::yield();
185+
yield();
186186
}
187187
}

0 commit comments

Comments
 (0)