|
1 | 1 | // Example to demonstrate write latency for preallocated exFAT files.
|
2 | 2 | // I suggest you write a PC program to convert very large bin files.
|
3 | 3 | //
|
4 |
| -// If an exFAT SD is required, the ExFatFormatter example will format |
5 |
| -// smaller cards with an exFAT file system. |
6 |
| -// |
7 | 4 | // The maximum data rate will depend on the quality of your SD,
|
8 | 5 | // the size of the FIFO, and using dedicated SPI.
|
9 | 6 | #include "SdFat.h"
|
@@ -68,12 +65,17 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
|
68 | 65 | // Preallocate 1GiB file.
|
69 | 66 | const uint32_t PREALLOCATE_SIZE_MiB = 1024UL;
|
70 | 67 |
|
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 |
77 | 79 |
|
78 | 80 | // Save SRAM if 328.
|
79 | 81 | #ifdef __AVR_ATmega328P__
|
@@ -189,7 +191,7 @@ void binaryToCsv() {
|
189 | 191 | data_t binData[FIFO_DIM];
|
190 | 192 |
|
191 | 193 | if (!binFile.seekSet(512)) {
|
192 |
| - error("binFile.seek faile"); |
| 194 | + error("binFile.seek failed"); |
193 | 195 | }
|
194 | 196 | uint32_t tPct = millis();
|
195 | 197 | printRecord(&csvFile, nullptr);
|
|
0 commit comments