Skip to content

Commit 528c071

Browse files
authored
Adding sectorsize() and numSectors() to SD (#6457)
* Update SD.h * Added numSectors() and sectorSize()
1 parent 7b89b39 commit 528c071

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: libraries/SD/src/SD.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ uint64_t SDFS::cardSize()
7575
return (uint64_t)sectors * sectorSize;
7676
}
7777

78+
size_t SDFS::numSectors()
79+
{
80+
if(_pdrv == 0xFF) {
81+
return 0;
82+
}
83+
return sdcard_num_sectors(_pdrv);
84+
}
85+
86+
size_t SDFS::sectorSize()
87+
{
88+
if(_pdrv == 0xFF) {
89+
return 0;
90+
}
91+
return sdcard_sector_size(_pdrv);
92+
}
93+
7894
uint64_t SDFS::totalBytes()
7995
{
8096
FATFS* fsinfo;

Diff for: libraries/SD/src/SD.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class SDFS : public FS
3232
void end();
3333
sdcard_type_t cardType();
3434
uint64_t cardSize();
35+
size_t numSectors();
36+
size_t sectorSize();
3537
uint64_t totalBytes();
3638
uint64_t usedBytes();
3739
bool readRAW(uint8_t* buffer, uint32_t sector);

0 commit comments

Comments
 (0)