Skip to content

Commit aadedbf

Browse files
committed
Added Move constructor and bug fixes.
1 parent 57900b2 commit aadedbf

38 files changed

+500
-175
lines changed

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
### Warning: Major Reformat of Source in 2.2.2
1+
File copy constructors and file assignment operators have been made private by
2+
default in 2.2.3 to prevent call by value and multiple copies of file instances.
23

3-
There are a huge number of changes in 2.2.2 since I decided to use clang-format
4-
to force Google style formatting.
5-
6-
I did this to avoid warnings from the static analysis programs Cppcheck and
7-
cpplint.
8-
9-
clang-format is aggressive so it may actually cause code to fail. For example
10-
clang-format rearranges the order of includes according to the selected style.
4+
SdFatConfig.h has options to make file constructors and assignment operators
5+
public.
116

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

doc/html.zip

-90.1 KB
Binary file not shown.

doc/mainpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2011-2021 Bill Greiman
2+
* Copyright (c) 2011-2024 Bill Greiman
33
* This file is part of the SdFat library for SD memory cards.
44
*
55
* MIT License

examples/BufferedPrint/BufferedPrint.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
88
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
9-
#define SD_FAT_TYPE 0
9+
#define SD_FAT_TYPE 3
1010
/*
1111
Change the value of SD_CS_PIN if you are using SPI and
1212
your hardware does not use the default value, SS.

examples/DirectoryFunctions/DirectoryFunctions.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
88
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
9-
#define SD_FAT_TYPE 0
9+
#define SD_FAT_TYPE 3
1010
/*
1111
Change the value of SD_CS_PIN if you are using SPI and
1212
your hardware does not use the default value, SS.

examples/OpenNext/OpenNext.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
77
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
8-
#define SD_FAT_TYPE 0
8+
#define SD_FAT_TYPE 3
99
/*
1010
Change the value of SD_CS_PIN if you are using SPI and
1111
your hardware does not use the default value, SS.

examples/QuickStart/QuickStart.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void loop() {
143143
}
144144
cout << F("\nCard successfully initialized.\n");
145145
if (sd.vol()->fatType() == 0) {
146-
cout << F("Can't find a valid FAT16/FAT32 partition.\n");
146+
cout << F("Can't find a valid FAT16/FAT32/exFAT partition.\n");
147147
reformatMsg();
148148
return;
149149
}
@@ -163,7 +163,11 @@ void loop() {
163163
cout << F("Card size: ") << sizeMB;
164164
cout << F(" MB (MB = 1,000,000 bytes)\n");
165165
cout << endl;
166-
cout << F("Volume is FAT") << int(sd.vol()->fatType());
166+
if (sd.fatType() <= 32) {
167+
cout << F("\nVolume is FAT") << int(sd.fatType());
168+
} else {
169+
cout << F("\nVolume is exFAT");
170+
}
167171
cout << F(", Cluster size (bytes): ") << sd.vol()->bytesPerCluster();
168172
cout << endl << endl;
169173

examples/ReadCsvFile/ReadCsvFile.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
44
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
5-
#define SD_FAT_TYPE 0
5+
#define SD_FAT_TYPE 3
66
/*
77
Change the value of SD_CS_PIN if you are using SPI and
88
your hardware does not use the default value, SS.

examples/RtcTimestampTest/RtcTimestampTest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
1515
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
16-
#define SD_FAT_TYPE 0
16+
#define SD_FAT_TYPE 3
1717
/*
1818
Change the value of SD_CS_PIN if you are using SPI and
1919
your hardware does not use the default value, SS.

examples/SdInfo/SdInfo.ino

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/*
22
* This program attempts to initialize an SD card and analyze its structure.
3+
* The CID and CSD registers are also printed in HEX for use in online
4+
* decoders like these.
5+
*
6+
* https://gurumeditation.org/1342/sd-memory-card-register-decoder/
7+
* https://archive.goughlui.com/static/multicid.htm
38
*/
49
#include "SdFat.h"
510
#include "sdios.h"
@@ -55,7 +60,8 @@ void cidDmp() {
5560
cout << F("Serial number: ") << hex << cid.psn() << dec << endl;
5661
cout << F("Manufacturing date: ");
5762
cout << cid.mdtMonth() << '/' << cid.mdtYear() << endl;
58-
cout << endl;
63+
cout << F("CID HEX: ");
64+
hexDmp(&cid, sizeof(cid));
5965
}
6066
//------------------------------------------------------------------------------
6167
void clearSerialInput() {
@@ -69,7 +75,7 @@ void clearSerialInput() {
6975
//------------------------------------------------------------------------------
7076
void csdDmp() {
7177
eraseSize = csd.eraseSize();
72-
cout << F("cardSize: ") << 0.000512 * csd.capacity();
78+
cout << F("\ncardSize: ") << 0.000512 * csd.capacity();
7379
cout << F(" MB (MB = 1,000,000 bytes)\n");
7480

7581
cout << F("flashEraseSize: ") << int(eraseSize) << F(" blocks\n");
@@ -85,6 +91,8 @@ void csdDmp() {
8591
} else {
8692
cout << F("zeros\n");
8793
}
94+
cout << F("CSD HEX: ");
95+
hexDmp(&csd, sizeof(csd));
8896
}
8997
//------------------------------------------------------------------------------
9098
void errorPrint() {
@@ -96,18 +104,27 @@ void errorPrint() {
96104
}
97105
}
98106
//------------------------------------------------------------------------------
107+
void hexDmp(void* reg, uint8_t size) {
108+
uint8_t* u8 = reinterpret_cast<uint8_t*>(reg);
109+
cout << hex << noshowbase;
110+
for (size_t i = 0; i < size; i++) {
111+
cout << setw(2) << setfill('0') << int(u8[i]);
112+
}
113+
cout << dec << endl;
114+
}
115+
//------------------------------------------------------------------------------
99116
bool mbrDmp() {
100117
MbrSector_t mbr;
101118
bool valid = true;
102-
if (!sd.card()->readSector(0, (uint8_t *)&mbr)) {
119+
if (!sd.card()->readSector(0, (uint8_t*)&mbr)) {
103120
cout << F("\nread MBR failed.\n");
104121
errorPrint();
105122
return false;
106123
}
107124
cout << F("\nSD Partition Table\n");
108125
cout << F("part,boot,bgnCHS[3],type,endCHS[3],start,length\n");
109126
for (uint8_t ip = 1; ip < 5; ip++) {
110-
MbrPart_t *pt = &mbr.part[ip - 1];
127+
MbrPart_t* pt = &mbr.part[ip - 1];
111128
if ((pt->boot != 0 && pt->boot != 0X80) ||
112129
getLe32(pt->relativeSectors) > csd.capacity()) {
113130
valid = false;
@@ -242,7 +259,7 @@ void loop() {
242259
printCardType();
243260
cout << F("sdSpecVer: ") << 0.01 * scr.sdSpecVer() << endl;
244261
cout << F("HighSpeedMode: ");
245-
if (scr.sdSpecVer() && sd.card()->cardCMD6(0X00FFFFFF, cmd6Data) &&
262+
if (scr.sdSpecVer() > 101 && sd.card()->cardCMD6(0X00FFFFFF, cmd6Data) &&
246263
(2 & cmd6Data[13])) {
247264
cout << F("true\n");
248265
} else {

0 commit comments

Comments
 (0)