Skip to content

Commit a5e4bde

Browse files
committed
Add UTF-8 support
1 parent caece65 commit a5e4bde

File tree

105 files changed

+2326
-1267
lines changed

Some content is hidden

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

105 files changed

+2326
-1267
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ 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.
8+
9+
Try the UnicodeFilenames example. Here is output from ls:
10+
<pre>
11+
Type any character to begin
12+
ls:
13+
0 😀/
14+
20 россиянин
15+
17 très élégant
16+
9 狗.txt
17+
</pre>
18+
719
SdFat Version 2 supports FAT16/FAT32 and exFAT SD cards. It is mostly
820
backward compatible with SdFat Version 1 for FAT16/FAT32 cards.
921

doc/html.zip

-13.1 KB
Binary file not shown.

examples/AvrAdcLogger/AvrAdcLogger.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ const uint16_t ISR_TIMER0 = 160;
152152
//==============================================================================
153153
const uint32_t MAX_FILE_SIZE = MAX_FILE_SIZE_MiB << 20;
154154

155-
// Select fastest interface.
155+
// Select fastest interface. Max SPI rate for AVR is 10 MHx.
156+
#define SPI_CLOCK SD_SCK_MHZ(10)
157+
156158
#if ENABLE_DEDICATED_SPI
157-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
159+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
158160
#else // ENABLE_DEDICATED_SPI
159-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
161+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
160162
#endif // ENABLE_DEDICATED_SPI
161163

162164
#if SD_FAT_TYPE == 0

examples/BackwardCompatibility/BackwardCompatibility.ino

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
//
44
// Your SD must be formatted FAT16/FAT32.
55
//
6+
// SD.h does not support some default SdFat features.
7+
// To compare flash size, set USE_FAT_FILE_FLAG_CONTIGUOUS,
8+
// ENABLE_DEDICATED_SPI, and USE_LONG_FILE_NAMES to zero also
9+
// set SDFAT_FILE_TYPE to one in SdFat/src/SdFatCongfig.h
10+
//
611
// Set USE_SD_H nonzero to use SD.h.
712
// Set USE_SD_H zero to use SdFat.h.
813
//

examples/BufferedPrint/BufferedPrint.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
2424
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
2525
#endif // SDCARD_SS_PIN
2626

27+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
28+
#define SPI_CLOCK SD_SCK_MHZ(50)
29+
2730
// Try to select the best SD card configuration.
2831
#if HAS_SDIO_CLASS
2932
#define SD_CONFIG SdioConfig(FIFO_SDIO)
30-
#elif ENABLE_DEDICATED_SPI
31-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
33+
#elif ENABLE_DEDICATED_SPI
34+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3235
#else // HAS_SDIO_CLASS
33-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
36+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
3437
#endif // HAS_SDIO_CLASS
3538

3639
#if SD_FAT_TYPE == 0

examples/DirectoryFunctions/DirectoryFunctions.ino

+7-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
2424
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
2525
#endif // SDCARD_SS_PIN
2626

27+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
28+
#define SPI_CLOCK SD_SCK_MHZ(50)
29+
2730
// Try to select the best SD card configuration.
2831
#if HAS_SDIO_CLASS
2932
#define SD_CONFIG SdioConfig(FIFO_SDIO)
30-
#elif ENABLE_DEDICATED_SPI
31-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
33+
#elif ENABLE_DEDICATED_SPI
34+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3235
#else // HAS_SDIO_CLASS
33-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
36+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
3437
#endif // HAS_SDIO_CLASS
3538
//------------------------------------------------------------------------------
3639

@@ -66,7 +69,6 @@ void setup() {
6669
SysCall::yield();
6770
}
6871
delay(1000);
69-
7072
cout << F("Type any character to start\n");
7173
while (!Serial.available()) {
7274
SysCall::yield();
@@ -153,4 +155,4 @@ void setup() {
153155
}
154156
//------------------------------------------------------------------------------
155157
// Nothing happens in loop.
156-
void loop() {}
158+
void loop() {}

examples/ExFatLogger/ExFatLogger.ino

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Example to demonstrate write latency for preallocated exFAT files.
22
// I suggest you write a PC program to convert very large bin files.
33
//
4-
// If an exFAT SD is required, the ExFatFormatter example will format
5-
// smaller cards with an exFAT file system.
6-
//
74
// The maximum data rate will depend on the quality of your SD,
85
// the size of the FIFO, and using dedicated SPI.
96
#include "SdFat.h"
@@ -68,12 +65,17 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
6865
// Preallocate 1GiB file.
6966
const uint32_t PREALLOCATE_SIZE_MiB = 1024UL;
7067

71-
// Select the fastest interface. Assumes no other SPI devices.
72-
#if ENABLE_DEDICATED_SPI
73-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
74-
#else // ENABLE_DEDICATED_SPI
75-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
76-
#endif // ENABLE_DEDICATED_SPI
68+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
69+
#define SPI_CLOCK SD_SCK_MHZ(50)
70+
71+
// Try to select the best SD card configuration.
72+
#if HAS_SDIO_CLASS
73+
#define SD_CONFIG SdioConfig(FIFO_SDIO)
74+
#elif ENABLE_DEDICATED_SPI
75+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
76+
#else // HAS_SDIO_CLASS
77+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
78+
#endif // HAS_SDIO_CLASS
7779

7880
// Save SRAM if 328.
7981
#ifdef __AVR_ATmega328P__
@@ -189,7 +191,7 @@ void binaryToCsv() {
189191
data_t binData[FIFO_DIM];
190192

191193
if (!binFile.seekSet(512)) {
192-
error("binFile.seek faile");
194+
error("binFile.seek failed");
193195
}
194196
uint32_t tPct = millis();
195197
printRecord(&csvFile, nullptr);

examples/ExFatUnicodeTest/ExFatUnicodeTest.ino

-47
This file was deleted.

examples/OpenNext/OpenNext.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ const uint8_t SD_CS_PIN = SS;
2323
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
2424
#endif // SDCARD_SS_PIN
2525

26+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
27+
#define SPI_CLOCK SD_SCK_MHZ(50)
28+
2629
// Try to select the best SD card configuration.
2730
#if HAS_SDIO_CLASS
2831
#define SD_CONFIG SdioConfig(FIFO_SDIO)
29-
#elif ENABLE_DEDICATED_SPI
30-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
32+
#elif ENABLE_DEDICATED_SPI
33+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3134
#else // HAS_SDIO_CLASS
32-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
35+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
3336
#endif // HAS_SDIO_CLASS
3437

3538
#if SD_FAT_TYPE == 0

examples/ReadCsvFile/ReadCsvFile.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ const uint8_t SD_CS_PIN = SS;
2020
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
2121
#endif // SDCARD_SS_PIN
2222

23+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
24+
#define SPI_CLOCK SD_SCK_MHZ(50)
25+
2326
// Try to select the best SD card configuration.
2427
#if HAS_SDIO_CLASS
2528
#define SD_CONFIG SdioConfig(FIFO_SDIO)
26-
#elif ENABLE_DEDICATED_SPI
27-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
29+
#elif ENABLE_DEDICATED_SPI
30+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
2831
#else // HAS_SDIO_CLASS
29-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
32+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
3033
#endif // HAS_SDIO_CLASS
3134

3235
#if SD_FAT_TYPE == 0

examples/RtcTimestampTest/RtcTimestampTest.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ const uint8_t SD_CS_PIN = SS;
3131
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
3232
#endif // SDCARD_SS_PIN
3333

34+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
35+
#define SPI_CLOCK SD_SCK_MHZ(50)
36+
3437
// Try to select the best SD card configuration.
3538
#if HAS_SDIO_CLASS
3639
#define SD_CONFIG SdioConfig(FIFO_SDIO)
37-
#elif ENABLE_DEDICATED_SPI
38-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
40+
#elif ENABLE_DEDICATED_SPI
41+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3942
#else // HAS_SDIO_CLASS
40-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
43+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
4144
#endif // HAS_SDIO_CLASS
4245

4346
#if SD_FAT_TYPE == 0

examples/STM32Test/STM32Test.ino

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/*
1+
/* This example is for https://github.com/rogerclarkmelbourne/Arduino_STM32
2+
*
23
* Example use of two SPI ports on an STM32 board.
34
* Note SPI speed is limited to 18 MHz.
45
*/
@@ -13,7 +14,7 @@ FsFile file1;
1314

1415
// Use mySPI2 since SPI2 is used in SPI.h as a different type.
1516
static SPIClass mySPI2(2);
16-
// Chip select PB21, dedicated SPI, 18 MHz, port 2.
17+
// Chip select PB12, dedicated SPI, 18 MHz, port 2.
1718
#if ENABLE_DEDICATED_SPI
1819
#define SD2_CONFIG SdSpiConfig(PB12, DEDICATED_SPI, SD_SCK_MHZ(18), &mySPI2)
1920
#else // ENABLE_DEDICATED_SPI

examples/SdFormatter/SdFormatter.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ const uint8_t SD_CS_PIN = SS;
3636
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
3737
#endif // SDCARD_SS_PIN
3838

39+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
40+
#define SPI_CLOCK SD_SCK_MHZ(50)
41+
3942
// Try to select the best SD card configuration.
4043
#if HAS_SDIO_CLASS
4144
#define SD_CONFIG SdioConfig(FIFO_SDIO)
42-
#elif ENABLE_DEDICATED_SPI
43-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
45+
#elif ENABLE_DEDICATED_SPI
46+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
4447
#else // HAS_SDIO_CLASS
45-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
48+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
4649
#endif // HAS_SDIO_CLASS
4750
//==============================================================================
4851
// Serial output stream

examples/TeensyRtcTimestamp/TeensyRtcTimestamp.ino

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ const uint8_t SD_CS_PIN = SS;
2424
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
2525
#endif // SDCARD_SS_PIN
2626

27+
// Try max SPI clock for an SD. Reduce SPI_CLOCK if errors occur.
28+
#define SPI_CLOCK SD_SCK_MHZ(50)
29+
2730
// Try to select the best SD card configuration.
2831
#if HAS_SDIO_CLASS
2932
#define SD_CONFIG SdioConfig(FIFO_SDIO)
30-
#elif ENABLE_DEDICATED_SPI
31-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI)
33+
#elif ENABLE_DEDICATED_SPI
34+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3235
#else // HAS_SDIO_CLASS
33-
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI)
36+
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)
3437
#endif // HAS_SDIO_CLASS
3538

3639
#if SD_FAT_TYPE == 0

0 commit comments

Comments
 (0)