Skip to content

Adding sectorsize() and numSectors() to SD #6457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libraries/SD/src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ uint64_t SDFS::cardSize()
return (uint64_t)sectors * sectorSize;
}

size_t SDFS::numSectors()
{
if(_pdrv == 0xFF) {
return 0;
}
return sdcard_num_sectors(_pdrv);
}

size_t SDFS::sectorSize()
{
if(_pdrv == 0xFF) {
return 0;
}
return sdcard_sector_size(_pdrv);
}

uint64_t SDFS::totalBytes()
{
FATFS* fsinfo;
Expand Down
2 changes: 2 additions & 0 deletions libraries/SD/src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class SDFS : public FS
void end();
sdcard_type_t cardType();
uint64_t cardSize();
size_t numSectors();
size_t sectorSize();
uint64_t totalBytes();
uint64_t usedBytes();
bool readRAW(uint8_t* buffer, uint32_t sector);
Expand Down