SdFat
Public Member Functions | Static Public Member Functions | List of all members
SdFat32 Class Reference

SD file system class for FAT volumes. More...

#include <SdFat.h>

Inheritance diagram for SdFat32:
Inheritance graph
[legend]
Collaboration diagram for SdFat32:
Collaboration graph
[legend]

Public Member Functions

bool begin (BlockDevice *dev, bool setCwv=true, uint8_t part=1)
 
bool begin (SdCsPin_t csPin, uint32_t maxSck)
 
bool begin (SdCsPin_t csPin=SS)
 
bool begin (SdioConfig sdioConfig)
 
bool begin (SdSpiConfig spiConfig)
 
uint16_t bytesPerCluster ()
 
uint8_t bytesPerClusterShift ()
 
uint16_t bytesPerSector ()
 
uint8_t bytesPerSectorShift ()
 
cache_tcacheClear ()
 
SdCardcard ()
 
bool cardBegin (SdioConfig sdioConfig)
 
bool cardBegin (SdSpiConfig spiConfig)
 
bool chdir ()
 
bool chdir (const char *path)
 
bool chdir (const String &path)
 
void chvol ()
 
uint32_t clusterCount () const
 
uint32_t dataStartSector () const
 
int8_t dbgFat (uint32_t n, uint32_t *v)
 
void errorHalt ()
 
void errorHalt (const __FlashStringHelper *msg)
 
void errorHalt (const char *msg)
 
void errorHalt (print_t *pr)
 
void errorHalt (print_t *pr, const __FlashStringHelper *msg)
 
void errorHalt (print_t *pr, const char *msg)
 
void errorPrint (const __FlashStringHelper *msg)
 
void errorPrint (const char *msg)
 
void errorPrint (Print *pr, const __FlashStringHelper *msg)
 
void errorPrint (print_t *pr)
 
void errorPrint (print_t *pr, char const *msg)
 
bool exists (const char *path)
 
bool exists (const String &path)
 
uint8_t fatCount ()
 
uint32_t fatStartSector () const
 
uint8_t fatType () const
 
bool format (print_t *pr=NULL)
 
int32_t freeClusterCount ()
 
bool init (BlockDevice *dev, uint8_t part=1)
 
void initErrorHalt ()
 
void initErrorHalt (const __FlashStringHelper *msg)
 
void initErrorHalt (const char *msg)
 
void initErrorHalt (Print *pr, const __FlashStringHelper *msg)
 
void initErrorHalt (print_t *pr)
 
void initErrorHalt (print_t *pr, const char *msg)
 
void initErrorPrint ()
 
void initErrorPrint (Print *pr)
 
bool ls (const char *path, uint8_t flags=0)
 
bool ls (print_t *pr, const char *path, uint8_t flags)
 
bool ls (print_t *pr, uint8_t flags=0)
 
bool ls (uint8_t flags=0)
 
bool mkdir (const char *path, bool pFlag=true)
 
bool mkdir (const String &path, bool pFlag=true)
 
File32 open (const char *path, oflag_t oflag=0X00)
 
File32 open (const String &path, oflag_t oflag=0X00)
 
void printFatType (print_t *pr)
 
void printSdError (print_t *pr)
 
bool remove (const char *path)
 
bool remove (const String &path)
 
bool rename (const char *oldPath, const char *newPath)
 
bool rename (const String &oldPath, const String &newPath)
 
bool rmdir (const char *path)
 
bool rmdir (const String &path)
 
uint16_t rootDirEntryCount () const
 
uint32_t rootDirStart () const
 
uint8_t sdErrorCode ()
 
uint8_t sdErrorData ()
 
uint16_t sectorMask ()
 
uint8_t sectorsPerCluster () const
 
uint8_t sectorsPerClusterShift () const
 
uint32_t sectorsPerFat () const
 
bool truncate (const char *path, uint32_t length)
 
bool truncate (const String &path, uint32_t length)
 
FatVolumevol ()
 
bool volumeBegin ()
 
uint32_t volumeSectorCount () const
 

Static Public Member Functions

static FatVolumecwv ()
 

Detailed Description

SD file system class for FAT volumes.

Member Function Documentation

◆ begin() [1/5]

bool FatVolume::begin ( BlockDevice dev,
bool  setCwv = true,
uint8_t  part = 1 
)
inlineinherited

Initialize an FatVolume object.

Parameters
[in]devDevice block driver.
[in]setCwvSet current working volume if true.
[in]partpartition to initialize.
Returns
true for success or false for failure.

◆ begin() [2/5]

bool SdBase< FatVolume >::begin ( SdCsPin_t  csPin,
uint32_t  maxSck 
)
inlineinherited

Initialize SD card and file system.

Parameters
[in]csPinSD card chip select pin.
[in]maxSckMaximum SCK frequency.
Returns
true for success or false for failure.

◆ begin() [3/5]

bool SdBase< FatVolume >::begin ( SdCsPin_t  csPin = SS)
inlineinherited

Initialize SD card and file system.

Parameters
[in]csPinSD card chip select pin.
Returns
true for success or false for failure.

◆ begin() [4/5]

bool SdBase< FatVolume >::begin ( SdioConfig  sdioConfig)
inlineinherited

Initialize SD card and file system for SDIO mode.

Parameters
[in]sdioConfigSDIO configuration.
Returns
true for success or false for failure.

◆ begin() [5/5]

bool SdBase< FatVolume >::begin ( SdSpiConfig  spiConfig)
inlineinherited

Initialize SD card and file system for SPI mode.

Parameters
[in]spiConfigSPI configuration.
Returns
true for success or false for failure.

◆ bytesPerCluster()

uint16_t FatPartition::bytesPerCluster ( )
inlineinherited
Returns
Number of bytes in a cluster.

◆ bytesPerClusterShift()

uint8_t FatPartition::bytesPerClusterShift ( )
inlineinherited
Returns
The shift count required to multiply by bytesPerCluster.

◆ bytesPerSector()

uint16_t FatPartition::bytesPerSector ( )
inlineinherited
Returns
Number of bytes per sector.

◆ bytesPerSectorShift()

uint8_t FatPartition::bytesPerSectorShift ( )
inlineinherited
Returns
The shift count required to multiply by bytesPerCluster.

◆ cacheClear()

cache_t* FatPartition::cacheClear ( )
inlineinherited

Clear the cache and returns a pointer to the cache. Not for normal apps.

Returns
A pointer to the cache buffer or zero if an error occurs.

◆ card()

SdCard* SdBase< FatVolume >::card ( )
inlineinherited
Returns
Pointer to SD card object.

◆ cardBegin() [1/2]

bool SdBase< FatVolume >::cardBegin ( SdioConfig  sdioConfig)
inlineinherited

Initialize SD card in SDIO mode.

Parameters
[in]sdioConfigSDIO configuration.
Returns
true for success or false for failure.

◆ cardBegin() [2/2]

bool SdBase< FatVolume >::cardBegin ( SdSpiConfig  spiConfig)
inlineinherited

Initialize SD card in SPI mode.

Parameters
[in]spiConfigSPI configuration.
Returns
true for success or false for failure.

◆ chdir() [1/3]

bool FatVolume::chdir ( )
inlineinherited

Set volume working directory to root.

Returns
true for success or false for failure.

◆ chdir() [2/3]

bool FatVolume::chdir ( const char *  path)
inherited

Set volume working directory.

Parameters
[in]pathPath for volume working directory.
Returns
true for success or false for failure.

◆ chdir() [3/3]

bool FatVolume::chdir ( const String &  path)
inlineinherited

Set volume working directory.

Parameters
[in]pathPath for volume working directory.
Returns
true for success or false for failure.

◆ chvol()

void FatVolume::chvol ( )
inlineinherited

Change global current working volume to this volume.

◆ clusterCount()

uint32_t FatPartition::clusterCount ( ) const
inlineinherited
Returns
The total number of clusters in the volume.

◆ cwv()

static FatVolume* FatVolume::cwv ( )
inlinestaticinherited
Returns
current working volume.

◆ dataStartSector()

uint32_t FatPartition::dataStartSector ( ) const
inlineinherited
Returns
The logical sector number for the start of file data.

◆ dbgFat()

int8_t FatPartition::dbgFat ( uint32_t  n,
uint32_t *  v 
)
inlineinherited

Debug access to FAT table

Parameters
[in]ncluster number.
[out]vvalue of entry
Returns
-1 error, 0 EOC, else 1.

◆ errorHalt() [1/6]

void SdBase< FatVolume >::errorHalt ( )
inlineinherited

Print error info to Serial and halt.

◆ errorHalt() [2/6]

void SdBase< FatVolume >::errorHalt ( const __FlashStringHelper *  msg)
inlineinherited

Print msg to Serial and halt.

Parameters
[in]msgMessage to print.

◆ errorHalt() [3/6]

void SdBase< FatVolume >::errorHalt ( const char *  msg)
inlineinherited

Print error info and halt.

Parameters
[in]msgMessage to print.

◆ errorHalt() [4/6]

void SdBase< FatVolume >::errorHalt ( print_t pr)
inlineinherited

Print error info and halt.

Parameters
[in]prPrint destination.

◆ errorHalt() [5/6]

void SdBase< FatVolume >::errorHalt ( print_t pr,
const __FlashStringHelper *  msg 
)
inlineinherited

Print msg and halt.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ errorHalt() [6/6]

void SdBase< FatVolume >::errorHalt ( print_t pr,
const char *  msg 
)
inlineinherited

Print error info and halt.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ errorPrint() [1/5]

void SdBase< FatVolume >::errorPrint ( const __FlashStringHelper *  msg)
inlineinherited

Print msg, any SD error code.

Parameters
[in]msgMessage to print.

◆ errorPrint() [2/5]

void SdBase< FatVolume >::errorPrint ( const char *  msg)
inlineinherited

Print msg, any SD error code.

Parameters
[in]msgMessage to print.

◆ errorPrint() [3/5]

void SdBase< FatVolume >::errorPrint ( Print *  pr,
const __FlashStringHelper *  msg 
)
inlineinherited

Print msg, any SD error code.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ errorPrint() [4/5]

void SdBase< FatVolume >::errorPrint ( print_t pr)
inlineinherited

Print SD errorCode and errorData.

Parameters
[in]prPrint destination.

◆ errorPrint() [5/5]

void SdBase< FatVolume >::errorPrint ( print_t pr,
char const *  msg 
)
inlineinherited

Print msg, any SD error code.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ exists() [1/2]

bool FatVolume::exists ( const char *  path)
inlineinherited

Test for the existence of a file.

Parameters
[in]pathPath of the file to be tested for.
Returns
true if the file exists else false.

◆ exists() [2/2]

bool FatVolume::exists ( const String &  path)
inlineinherited

Test for the existence of a file.

Parameters
[in]pathPath of the file to be tested for.
Returns
true if the file exists else false.

◆ fatCount()

uint8_t FatPartition::fatCount ( )
inlineinherited
Returns
The number of File Allocation Tables.

◆ fatStartSector()

uint32_t FatPartition::fatStartSector ( ) const
inlineinherited
Returns
The logical sector number for the start of the first FAT.

◆ fatType()

uint8_t FatPartition::fatType ( ) const
inlineinherited
Returns
The FAT type of the volume. Values are 12, 16 or 32.

◆ format()

bool SdFat32::format ( print_t pr = NULL)
inline

Format a SD card FAT32/FAT16.

Parameters
[in]prOptional Print information.
Returns
true for success or false for failure.

◆ freeClusterCount()

int32_t FatPartition::freeClusterCount ( )
inherited

Volume free space in clusters.

Returns
Count of free clusters for success or -1 if an error occurs.

◆ init()

bool FatPartition::init ( BlockDevice dev,
uint8_t  part = 1 
)
inherited

Initialize a FAT partition.

Parameters
[in]devBlockDevice for this partition.
[in]partThe partition to be used. Legal values for part are 1-4 to use the corresponding partition on a device formatted with a MBR, Master Boot Record, or zero if the device is formatted as a super floppy with the FAT boot sector in sector zero.
Returns
true for success or false for failure.

◆ initErrorHalt() [1/6]

void SdBase< FatVolume >::initErrorHalt ( )
inlineinherited

Print error info and halt.

◆ initErrorHalt() [2/6]

void SdBase< FatVolume >::initErrorHalt ( const __FlashStringHelper *  msg)
inlineinherited

Print error info and halt.

Parameters
[in]msgMessage to print.

◆ initErrorHalt() [3/6]

void SdBase< FatVolume >::initErrorHalt ( const char *  msg)
inlineinherited

Print error info and halt.

Parameters
[in]msgMessage to print.

◆ initErrorHalt() [4/6]

void SdBase< FatVolume >::initErrorHalt ( Print *  pr,
const __FlashStringHelper *  msg 
)
inlineinherited

Print error info and halt.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ initErrorHalt() [5/6]

void SdBase< FatVolume >::initErrorHalt ( print_t pr)
inlineinherited

Print error info and halt.

Parameters
[in]prPrint destination.

◆ initErrorHalt() [6/6]

void SdBase< FatVolume >::initErrorHalt ( print_t pr,
const char *  msg 
)
inlineinherited

Print error info and halt.

Parameters
[in]prPrint destination.
[in]msgMessage to print.

◆ initErrorPrint() [1/2]

void SdBase< FatVolume >::initErrorPrint ( )
inlineinherited

Print error details after begin() fails.

◆ initErrorPrint() [2/2]

void SdBase< FatVolume >::initErrorPrint ( Print *  pr)
inlineinherited

Print error details after begin() fails.

Parameters
[in]prPrint destination.

◆ ls() [1/4]

bool FatVolume::ls ( const char *  path,
uint8_t  flags = 0 
)
inlineinherited

List the directory contents of a directory to Serial.

Parameters
[in]pathdirectory to list.
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
true for success or false for failure.

◆ ls() [2/4]

bool FatVolume::ls ( print_t pr,
const char *  path,
uint8_t  flags 
)
inlineinherited

List the contents of a directory.

Parameters
[in]prPrint stream for list.
[in]pathdirectory to list.
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
true for success or false for failure.

◆ ls() [3/4]

bool FatVolume::ls ( print_t pr,
uint8_t  flags = 0 
)
inlineinherited

List the directory contents of the volume root directory.

Parameters
[in]prPrint stream for list.
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
true for success or false for failure.

◆ ls() [4/4]

bool FatVolume::ls ( uint8_t  flags = 0)
inlineinherited

List the directory contents of the root directory to Serial.

Parameters
[in]flagsThe inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

Returns
true for success or false for failure.

◆ mkdir() [1/2]

bool FatVolume::mkdir ( const char *  path,
bool  pFlag = true 
)
inlineinherited

Make a subdirectory in the volume root directory.

Parameters
[in]pathA path with a valid name for the subdirectory.
[in]pFlagCreate missing parent directories if true.
Returns
true for success or false for failure.

◆ mkdir() [2/2]

bool FatVolume::mkdir ( const String &  path,
bool  pFlag = true 
)
inlineinherited

Make a subdirectory in the volume root directory.

Parameters
[in]pathA path with a valid name for the subdirectory.
[in]pFlagCreate missing parent directories if true.
Returns
true for success or false for failure.

◆ open() [1/2]

File32 FatVolume::open ( const char *  path,
oflag_t  oflag = 0X00 
)
inlineinherited

open a file

Parameters
[in]pathlocation of file to be opened.
[in]oflagopen flags.
Returns
a File32 object.

◆ open() [2/2]

File32 FatVolume::open ( const String &  path,
oflag_t  oflag = 0X00 
)
inlineinherited

open a file

Parameters
[in]pathlocation of file to be opened.
[in]oflagopen flags.
Returns
a File32 object.

◆ printFatType()

void SdBase< FatVolume >::printFatType ( print_t pr)
inlineinherited

Print volume FAT/exFAT type.

Parameters
[in]prPrint destination.

◆ printSdError()

void SdBase< FatVolume >::printSdError ( print_t pr)
inlineinherited

Print error info and return.

Parameters
[in]prPrint destination.

◆ remove() [1/2]

bool FatVolume::remove ( const char *  path)
inlineinherited

Remove a file from the volume root directory.

Parameters
[in]pathA path with a valid name for the file.
Returns
true for success or false for failure.

◆ remove() [2/2]

bool FatVolume::remove ( const String &  path)
inlineinherited

Remove a file from the volume root directory.

Parameters
[in]pathA path with a valid name for the file.
Returns
true for success or false for failure.

◆ rename() [1/2]

bool FatVolume::rename ( const char *  oldPath,
const char *  newPath 
)
inlineinherited

Rename a file or subdirectory.

Parameters
[in]oldPathPath name to the file or subdirectory to be renamed.
[in]newPathNew path name of the file or subdirectory.

The newPath object must not exist before the rename call.

The file to be renamed must not be open. The directory entry may be moved and file system corruption could occur if the file is accessed by a file object that was opened before the rename() call.

Returns
true for success or false for failure.

◆ rename() [2/2]

bool FatVolume::rename ( const String &  oldPath,
const String &  newPath 
)
inlineinherited

Rename a file or subdirectory.

Parameters
[in]oldPathPath name to the file or subdirectory to be renamed.
[in]newPathNew path name of the file or subdirectory.

The newPath object must not exist before the rename call.

The file to be renamed must not be open. The directory entry may be moved and file system corruption could occur if the file is accessed by a file object that was opened before the rename() call.

Returns
true for success or false for failure.

◆ rmdir() [1/2]

bool FatVolume::rmdir ( const char *  path)
inlineinherited

Remove a subdirectory from the volume's working directory.

Parameters
[in]pathA path with a valid name for the subdirectory.

The subdirectory file will be removed only if it is empty.

Returns
true for success or false for failure.

◆ rmdir() [2/2]

bool FatVolume::rmdir ( const String &  path)
inlineinherited

Remove a subdirectory from the volume's working directory.

Parameters
[in]pathA path with a valid name for the subdirectory.

The subdirectory file will be removed only if it is empty.

Returns
true for success or false for failure.

◆ rootDirEntryCount()

uint16_t FatPartition::rootDirEntryCount ( ) const
inlineinherited
Returns
The number of entries in the root directory for FAT16 volumes.

◆ rootDirStart()

uint32_t FatPartition::rootDirStart ( ) const
inlineinherited
Returns
The logical sector number for the start of the root directory on FAT16 volumes or the first cluster number on FAT32 volumes.

◆ sdErrorCode()

uint8_t SdBase< FatVolume >::sdErrorCode ( )
inlineinherited
Returns
SD card error code.

◆ sdErrorData()

uint8_t SdBase< FatVolume >::sdErrorData ( )
inlineinherited
Returns
SD card error data.

◆ sectorMask()

uint16_t FatPartition::sectorMask ( )
inlineinherited
Returns
Mask for sector offset.

◆ sectorsPerCluster()

uint8_t FatPartition::sectorsPerCluster ( ) const
inlineinherited
Returns
The volume's cluster size in sectors.

◆ sectorsPerClusterShift()

uint8_t FatPartition::sectorsPerClusterShift ( ) const
inlineinherited
Returns
The shift count required to multiply by sectorsPerCluster.

◆ sectorsPerFat()

uint32_t FatPartition::sectorsPerFat ( ) const
inlineinherited
Returns
The number of sectors in one FAT.

◆ truncate() [1/2]

bool FatVolume::truncate ( const char *  path,
uint32_t  length 
)
inlineinherited

Truncate a file to a specified length. The current file position will be at the new EOF.

Parameters
[in]pathA path with a valid name for the file.
[in]lengthThe desired length for the file.
Returns
true for success or false for failure.

◆ truncate() [2/2]

bool FatVolume::truncate ( const String &  path,
uint32_t  length 
)
inlineinherited

Truncate a file to a specified length. The current file position will be at the new EOF.

Parameters
[in]pathA path with a valid name for the file.
[in]lengthThe desired length for the file.
Returns
true for success or false for failure.

◆ vol()

FatVolume * SdBase< FatVolume >::vol ( )
inlineinherited
Returns
pointer to base volume

◆ volumeBegin()

bool SdBase< FatVolume >::volumeBegin ( )
inlineinherited

Initialize file system after call to cardBegin.

Returns
true for success or false for failure.

◆ volumeSectorCount()

uint32_t FatPartition::volumeSectorCount ( ) const
inlineinherited
Returns
The number of sectors in the volume

The documentation for this class was generated from the following file: