Prusa MINI Firmware overview
SdVolume Class Reference

Access FAT16 and FAT32 volumes on SD and SDHC cards. More...

#include <SdVolume.h>

Public Member Functions

 SdVolume ()
 
cache_tcacheClear ()
 
bool init (Sd2Card *dev)
 
bool init (Sd2Card *dev, uint8_t part)
 
uint8_t blocksPerCluster () const
 
uint32_t blocksPerFat () const
 
uint32_t clusterCount () const
 
uint8_t clusterSizeShift () const
 
uint32_t dataStartBlock () const
 
uint8_t fatCount () const
 
uint32_t fatStartBlock () const
 
uint8_t fatType () const
 
int32_t freeClusterCount ()
 
uint32_t rootDirEntryCount () const
 
uint32_t rootDirStart () const
 
Sd2CardsdCard ()
 
bool dbgFat (uint32_t n, uint32_t *v)
 

Friends

class SdBaseFile
 

Detailed Description

Access FAT16 and FAT32 volumes on SD and SDHC cards.

Constructor & Destructor Documentation

◆ SdVolume()

SdVolume::SdVolume ( )
74 : fatType_(0) {}

Member Function Documentation

◆ cacheClear()

cache_t* SdVolume::cacheClear ( )

Clear the cache and returns a pointer to the cache. Used by the WaveRP recorder to do raw write to the SD card. Not for normal apps.

Returns
A pointer to the cache buffer or zero if an error occurs.
80  {
81  if (!cacheFlush()) return 0;
82  cacheBlockNumber_ = 0xFFFFFFFF;
83  return &cacheBuffer_;
84  }

◆ init() [1/2]

bool SdVolume::init ( Sd2Card dev)

Initialize a FAT volume. Try partition one first then try super floppy format.

Parameters
[in]devThe Sd2Card where the volume is located.
Returns
true for success, false for failure. Reasons for failure include not finding a valid partition, not finding a valid FAT file system or an I/O error.
96 { return init(dev, 1) ? true : init(dev, 0); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

bool SdVolume::init ( Sd2Card dev,
uint8_t  part 
)

◆ blocksPerCluster()

uint8_t SdVolume::blocksPerCluster ( ) const
100 { return blocksPerCluster_; } //> \return The volume's cluster size in blocks.

◆ blocksPerFat()

uint32_t SdVolume::blocksPerFat ( ) const
101 { return blocksPerFat_; } //> \return The number of blocks in one FAT.

◆ clusterCount()

uint32_t SdVolume::clusterCount ( ) const
102 { return clusterCount_; } //> \return The total number of clusters in the volume.

◆ clusterSizeShift()

uint8_t SdVolume::clusterSizeShift ( ) const
103 { return clusterSizeShift_; } //> \return The shift count required to multiply by blocksPerCluster.

◆ dataStartBlock()

uint32_t SdVolume::dataStartBlock ( ) const
104 { return dataStartBlock_; } //> \return The logical block number for the start of file data.

◆ fatCount()

uint8_t SdVolume::fatCount ( ) const
105 { return fatCount_; } //> \return The number of FAT structures on the volume.

◆ fatStartBlock()

uint32_t SdVolume::fatStartBlock ( ) const
106 { return fatStartBlock_; } //> \return The logical block number for the start of the first FAT.

◆ fatType()

uint8_t SdVolume::fatType ( ) const
107 { return fatType_; } //> \return The FAT type of the volume. Values are 12, 16 or 32.

◆ freeClusterCount()

int32_t SdVolume::freeClusterCount ( )

◆ rootDirEntryCount()

uint32_t SdVolume::rootDirEntryCount ( ) const
109 { return rootDirEntryCount_; } /** \return The number of entries in the root directory for FAT16 volumes. */

◆ rootDirStart()

uint32_t SdVolume::rootDirStart ( ) const
Returns
The number of entries in the root directory for FAT16 volumes.
The logical block number for the start of the root directory on FAT16 volumes or the first cluster number on FAT32 volumes.
115 { return rootDirStart_; }

◆ sdCard()

Sd2Card* SdVolume::sdCard ( )

Sd2Card object for this volume

Returns
pointer to Sd2Card object.
121 { return sdCard_; }

◆ dbgFat()

bool SdVolume::dbgFat ( uint32_t  n,
uint32_t *  v 
)

Debug access to FAT table

Parameters
[in]ncluster number.
[out]vvalue of entry
Returns
true for success or false for failure
130 { return fatGet(n, v); }

Friends And Related Function Documentation

◆ SdBaseFile

friend class SdBaseFile
friend
SdVolume::init
bool init(Sd2Card *dev)
Definition: SdVolume.h:96