Skip to content

Commit

Permalink
Fix SdInfo example and file.timestamp. Remove Syscall::yield and SysC…
Browse files Browse the repository at this point in the history
…all::halt

Fix SdInfo example and file.timestamp. Remove Syscall::yield and SysCall::halt.

Major restructuring for future portability to RTOS systems and RPI Pico.
  • Loading branch information
greiman committed Oct 31, 2021
1 parent a5e4bde commit fb74151
Show file tree
Hide file tree
Showing 168 changed files with 1,493 additions and 1,655 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Earlier releases of Version 1 are here:

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

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

Try the UnicodeFilenames example. Here is output from ls:
<pre>
Expand Down
651 changes: 410 additions & 241 deletions doc/Doxyfile

Large diffs are not rendered by default.

Binary file modified doc/html.zip
Binary file not shown.
12 changes: 8 additions & 4 deletions doc/mainpage.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2011-2020 Bill Greiman
* Copyright (c) 2011-2021 Bill Greiman
* This file is part of the SdFat library for SD memory cards.
*
* MIT License
Expand Down Expand Up @@ -249,11 +249,9 @@ DirectoryFunctions - Use of chdir(), ls(), mkdir(), and rmdir().
examplesV1 folder - Examples from SdFat V1 for compatibility tests.
%ExFatFormatter - Produces optimal exFAT format for smaller SD cards.
ExFatLogger - A data-logger optimized for exFAT features.
ExFatUnicodeTest - Test program for Unicode file names.
MinimumSizeSdReader - Example of small file reader for FAT16/FAT32.
OpenNext - Open all files in the root dir and print their filename.
Expand All @@ -275,10 +273,16 @@ SoftwareSpi - Demo of limited Software SPI support in SdFat V2.
STM32Test - Example use of two SPI ports on an STM32 board.
TeensyDmaAdcLogger - Fast logger using DMA ADC.
TeensyRtcTimestamp - %File timestamps for Teensy3.
TeensySdioDemo - Demo of SDIO and SPI modes for the Teensy 3.5/3.6 built-in SD.
TeensySdioLogger - Fast logger using a ring buffer.
UnicodeFilenames - Test program for Unicode file names.
UserChipSelectFunction - Useful for port expanders or replacement of the standard GPIO functions.
UserSPIDriver - An example of an external SPI driver.
Expand Down
9 changes: 3 additions & 6 deletions examples/AvrAdcLogger/AvrAdcLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ MinimumSerial MinSerial;
//------------------------------------------------------------------------------
// This example was designed for exFAT but will support FAT16/FAT32.
//
// If an exFAT SD is required, the ExFatFormatter example will format
// smaller cards with an exFAT file system.
//
// Note: Uno will not support SD_FAT_TYPE = 3.
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
Expand Down Expand Up @@ -152,9 +149,9 @@ const uint16_t ISR_TIMER0 = 160;
//==============================================================================
const uint32_t MAX_FILE_SIZE = MAX_FILE_SIZE_MiB << 20;

// Select fastest interface. Max SPI rate for AVR is 10 MHx.
// Max SPI rate for AVR is 10 MHz for F_CPU 20 MHz, 8 MHz for F_CPU 16 MHz.
#define SPI_CLOCK SD_SCK_MHZ(10)

// Select fastest interface.
#if ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else // ENABLE_DEDICATED_SPI
Expand Down Expand Up @@ -868,7 +865,7 @@ void loop(void) {
Serial.println(F("r - record ADC data"));

while(!Serial.available()) {
SysCall::yield();
yield();
}
char c = tolower(Serial.read());
Serial.println();
Expand Down
4 changes: 2 additions & 2 deletions examples/DirectoryFunctions/DirectoryFunctions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ void setup() {

// Wait for USB Serial
while (!Serial) {
SysCall::yield();
yield();
}
delay(1000);
cout << F("Type any character to start\n");
while (!Serial.available()) {
SysCall::yield();
yield();
}

// Initialize the SD card.
Expand Down
4 changes: 2 additions & 2 deletions examples/ExFatLogger/ExFatLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void setup() {

// Wait for USB Serial
while (!Serial) {
SysCall::yield();
yield();
}
delay(1000);
Serial.println(F("Type any character to begin"));
Expand Down Expand Up @@ -568,7 +568,7 @@ void loop() {
Serial.println(F("r - record data"));
Serial.println(F("t - test without logging"));
while(!Serial.available()) {
SysCall::yield();
yield();
}
char c = tolower(Serial.read());
Serial.println();
Expand Down
58 changes: 58 additions & 0 deletions examples/MinimumSizeSdReader/MinimumSizeSdReader.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Create a text file on the SD with this path using short 8.3 names.
#define SFN_PATH "/DIR/TEST.TXT"

// Modify CS_PIN for your chip select pin.
#define CS_PIN SS

// Set USE_SD_H to one for SD.h or zero for SdFat.
#define USE_SD_H 0

#if USE_SD_H
#include "SD.h"
File file;
#else
#include "SdFat.h"
// Setting ENABLE_DEDICATED_SPI to zero saves over 200 more bytes.
#if ENABLE_DEDICATED_SPI
#warning "Set ENABLE_DEDICATED_SPI zero in SdFat/src/SdFatConfig.h for minimum size"
#endif // ENABLE_DEDICATED_SPI
// Insure FAT16/FAT32 only.
SdFat32 SD;
// FatFile does not support Stream functions, just simple read/write.
FatFile file;
#endif

void error(const char* msg) {
Serial.println(msg);
while(true);
}

void setup() {
int n;
char buf[4];

Serial.begin(9600);
while (!Serial) {}
Serial.println("Type any character to begin");
while (!Serial.available()) {}

if (!SD.begin(CS_PIN)) error("SD.begin");

#if USE_SD_H
file = SD.open(SFN_PATH);
if (!file) error("open");
#else
// Open existing file with a path of 8.3 names.
// Directories will be opened O_RDONLY files O_RDWR.
if (!file.openExistingSFN(SFN_PATH)) error("open");
#endif
while ((n = file.read(buf, sizeof(buf)))) {
Serial.write(buf, n);
}
// close() is only needed if you write to the file. For example, read
// config data, modify the data, rewind the file and write the data.
// file.close();
}

void loop() {
}
4 changes: 2 additions & 2 deletions examples/OpenNext/OpenNext.ino
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ void setup() {

// Wait for USB Serial
while (!Serial) {
SysCall::yield();
yield();
}

Serial.println("Type any character to start");
while (!Serial.available()) {
SysCall::yield();
yield();
}

// Initialize the SD.
Expand Down
6 changes: 3 additions & 3 deletions examples/QuickStart/QuickStart.ino
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void setup() {

// Wait for USB Serial
while (!Serial) {
SysCall::yield();
yield();
}
cout << F("\nSPI pins:\n");
cout << F("MISO: ") << int(MISO) << endl;
Expand Down Expand Up @@ -106,7 +106,7 @@ void loop() {

cout << F("\nEnter the chip select pin number: ");
while (!Serial.available()) {
SysCall::yield();
yield();
}
cin.readline();
if (cin >> chipSelect) {
Expand Down Expand Up @@ -182,6 +182,6 @@ void loop() {

cout << F("\nSuccess! Type any character to restart.\n");
while (!Serial.available()) {
SysCall::yield();
yield();
}
}
175 changes: 0 additions & 175 deletions examples/STM32Test/STM32Test.ino

This file was deleted.

Loading

0 comments on commit fb74151

Please sign in to comment.