SdFat: SdFatSoftSpi< MisoPin, MosiPin, SckPin > Class Template Reference

SdFat

Public Member Functions | List of all members
SdFatSoftSpi< MisoPin, MosiPin, SckPin > Class Template Reference

SdFat class using software SPI. More...

`#include <SdFat.h>`

Inheritance diagram for SdFatSoftSpi< MisoPin, MosiPin, SckPin >:
[legend]
Collaboration diagram for SdFatSoftSpi< MisoPin, MosiPin, SckPin >:
[legend]

## Public Member Functions
bool | begin (BlockDriver *blockDev, uint8_t part=0)
bool | begin ()
bool | begin (uint8_t csPin=SS, SPISettings spiSettings=SPI_FULL_SPEED)
uint8_t | blocksPerCluster () const
uint32_t | blocksPerFat () const
cache_t * | cacheClear ()
SdSpiCard * | card ()
uint8_t | cardErrorCode ()
uint32_t | cardErrorData ()
bool | chdir (bool set_cwd=false)
bool | chdir (const char *path, bool set_cwd=false)
void | chvol ()
uint32_t | clusterCount () const
uint8_t | clusterSizeShift () const
uint32_t | dataStartBlock () const
int8_t | dbgFat (uint32_t n, uint32_t *v)
void | errorHalt ()
void | errorHalt (Print *pr)
void | errorHalt (char const *msg)
void | errorHalt (Print *pr, char const *msg)
void | errorHalt (const __FlashStringHelper *msg)
void | errorHalt (Print *pr, const __FlashStringHelper *msg)
void | errorPrint ()
void | errorPrint (Print *pr)
void | errorPrint (const char *msg)
void | errorPrint (Print *pr, char const *msg)
void | errorPrint (const __FlashStringHelper *msg)
void | errorPrint (Print *pr, const __FlashStringHelper *msg)
bool | exists (const char *path)
uint8_t | fatCount ()
uint32_t | fatStartBlock () const
uint8_t | fatType () const
int32_t | freeClusterCount ()
bool | init ()
bool | init (uint8_t part)
void | initErrorHalt ()
void | initErrorHalt (Print *pr)
void | initErrorHalt (char const *msg)
void | initErrorHalt (Print *pr, char const *msg)
void | initErrorHalt (const __FlashStringHelper *msg)
void | initErrorHalt (Print *pr, const __FlashStringHelper *msg)
void | initErrorPrint ()
void | initErrorPrint (Print *pr)
void | initErrorPrint (char const *msg)
void | initErrorPrint (Print *pr, char const *msg)
void | initErrorPrint (const __FlashStringHelper *msg)
void | initErrorPrint (Print *pr, const __FlashStringHelper *msg)
void | ls (uint8_t flags=0)
void | ls (const char *path, uint8_t flags=0)
void | ls (print_t *pr, uint8_t flags=0)
void | ls (print_t *pr, const char *path, uint8_t flags)
bool | mkdir (const char *path, bool pFlag=true)
File | open (const char *path, oflag_t oflag=FILE_READ)
File | open (const String &path, oflag_t oflag=FILE_READ)
bool | remove (const char *path)
bool | rename (const char *oldPath, const char *newPath)
bool | rmdir (const char *path)
uint16_t | rootDirEntryCount () const
uint32_t | rootDirStart () const
bool | truncate (const char *path, uint32_t length)
FatVolume * | vol ()
uint32_t | volumeBlockCount () const
FatFile * | vwd ()
bool | wipe (print_t *pr=0)

## Detailed Description

### template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
class SdFatSoftSpi< MisoPin, MosiPin, SckPin >

SdFat class using software SPI.

## Member Function Documentation

## ◆ begin() [1/3]

bool FatFileSystem::begin | ( | BlockDriver * | blockDev,
|  | uint8_t | part = `0`
| ) |  |
| inlineinherited

Initialize an FatFileSystem object.

Parameters

  [in] | blockDev | Device block driver.
  [in] | part | partition to initialize.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ begin() [2/3]

bool SdFileSystem< SdSpiCard >::begin | ( |  | ) |
| inlineinherited

Initialize file system.

Returns
  true for success else false.

## ◆ begin() [3/3]

template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>

bool SdFatSoftSpi< MisoPin, MosiPin, SckPin >::begin | ( | uint8_t | csPin = `SS`,
|  | SPISettings | spiSettings = `SPI_FULL_SPEED`
| ) |  |
| inline

Initialize SD card and file system.

Parameters

  [in] | csPin | SD card chip select pin.
  [in] | spiSettings | ignored for software SPI..

Returns
  true for success else false.

## ◆ blocksPerCluster()

uint8_t FatVolume::blocksPerCluster | ( |  | ) | const
| inlineinherited

Returns
  The volume's cluster size in blocks.

## ◆ blocksPerFat()

uint32_t FatVolume::blocksPerFat | ( |  | ) | const
| inlineinherited

Returns
  The number of blocks in one FAT.

## ◆ cacheClear()

cache_t* FatVolume::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()

SdSpiCard * SdFileSystem< SdSpiCard >::card | ( |  | ) |
| inlineinherited

Returns
  Pointer to SD card object

## ◆ cardErrorCode()

uint8_t SdFileSystem< SdSpiCard >::cardErrorCode | ( |  | ) |
| inlineinherited

Returns
  The card error code

## ◆ cardErrorData()

uint32_t SdFileSystem< SdSpiCard >::cardErrorData | ( |  | ) |
| inlineinherited

Returns
  the card error data

## ◆ chdir() [1/2]

bool FatFileSystem::chdir | ( | bool | set_cwd = `false` | ) |
| inlineinherited

Change a volume's working directory to root

Changes the volume's working directory to the SD's root directory. Optionally set the current working directory to the volume's working directory.

Parameters

  [in] | set_cwd | Set the current working directory to this volume's working directory if true.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ chdir() [2/2]

bool FatFileSystem::chdir | ( | const char * | path,
|  | bool | set_cwd = `false`
| ) |  |
| inlineinherited

Change a volume's working directory

Changes the volume working directory to the path subdirectory. Optionally set the current working directory to the volume's working directory.

Example: If the volume's working directory is "/DIR", chdir("SUB") will change the volume's working directory from "/DIR" to "/DIR/SUB".

If path is "/", the volume's working directory will be changed to the root directory

Parameters

  [in] | path | The name of the subdirectory.
  [in] | set_cwd | Set the current working directory to this volume's working directory if true.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ chvol()

void FatFileSystem::chvol | ( |  | ) |
| inlineinherited

Set the current working directory to a volume's working directory.

This is useful with multiple SD cards.

The current working directory is changed to this volume's working directory.

This is like the Windows/DOS <drive letter>: command.

## ◆ clusterCount()

uint32_t FatVolume::clusterCount | ( |  | ) | const
| inlineinherited

Returns
  The total number of clusters in the volume.

## ◆ clusterSizeShift()

uint8_t FatVolume::clusterSizeShift | ( |  | ) | const
| inlineinherited

Returns
  The shift count required to multiply by blocksPerCluster.

## ◆ dataStartBlock()

uint32_t FatVolume::dataStartBlock | ( |  | ) | const
| inlineinherited

Returns
  The logical block number for the start of file data.

## ◆ dbgFat()

int8_t FatVolume::dbgFat | ( | uint32_t | n,
|  | uint32_t * | v
| ) |  |
| inlineinherited

Debug access to FAT table

Parameters

  [in] | n | cluster number.
  [out] | v | value of entry

Returns
  -1 error, 0 EOC, else 1.

## ◆ errorHalt() [1/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( |  | ) |
| inlineinherited

Print any SD error code to Serial and halt.

## ◆ errorHalt() [2/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( | Print * | pr | ) |
| inlineinherited

Print any SD error code and halt.

Parameters

  [in] | pr | Print destination.

## ◆ errorHalt() [3/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( | char const * | msg | ) |
| inlineinherited

Print msg, any SD error code and halt.

Parameters

  [in] | msg | Message to print.

## ◆ errorHalt() [4/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( | Print * | pr,
|  | char const * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code, and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorHalt() [5/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( | const __FlashStringHelper * | msg | ) |
| inlineinherited

Print msg, any SD error code, and halt.

Parameters

  [in] | msg | Message to print.

## ◆ errorHalt() [6/6]

void SdFileSystem< SdSpiCard >::errorHalt | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code, and halt.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorPrint() [1/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( |  | ) |
| inlineinherited

Print any SD error code to Serial

## ◆ errorPrint() [2/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( | Print * | pr | ) |
| inlineinherited

Print any SD error code.

Parameters

  [in] | pr | Print device.

## ◆ errorPrint() [3/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( | const char * | msg | ) |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | msg | Message to print.

## ◆ errorPrint() [4/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( | Print * | pr,
|  | char const * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ errorPrint() [5/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( | const __FlashStringHelper * | msg | ) |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | msg | Message to print.

## ◆ errorPrint() [6/6]

void SdFileSystem< SdSpiCard >::errorPrint | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print msg, any SD error code.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ exists()

bool FatFileSystem::exists | ( | const char * | path | ) |
| inlineinherited

Test for the existence of a file.

Parameters

  [in] | path | Path of the file to be tested for.

Returns
  true if the file exists else false.

## ◆ fatCount()

uint8_t FatVolume::fatCount | ( |  | ) |
| inlineinherited

Returns
  The number of File Allocation Tables.

## ◆ fatStartBlock()

uint32_t FatVolume::fatStartBlock | ( |  | ) | const
| inlineinherited

Returns
  The logical block number for the start of the first FAT.

## ◆ fatType()

uint8_t FatVolume::fatType | ( |  | ) | const
| inlineinherited

Returns
  The FAT type of the volume. Values are 12, 16 or 32.

## ◆ freeClusterCount()

int32_t FatVolume::freeClusterCount | ( |  | ) |
| inherited

Volume free space in clusters.

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

## ◆ init() [1/2]

bool FatVolume::init | ( |  | ) |
| inlineinherited

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

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ init() [2/2]

bool FatVolume::init | ( | uint8_t | part | ) |
| inherited

Initialize a FAT volume.

Parameters

  [in] | part | The 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 block zero.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ initErrorHalt() [1/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( |  | ) |
| inlineinherited

Print any SD error code and halt.

## ◆ initErrorHalt() [2/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( | Print * | pr | ) |
| inlineinherited

Print error details and halt after begin fails.

Parameters

  [in] | pr | Print destination.

## ◆ initErrorHalt() [3/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( | char const * | msg | ) |
| inlineinherited

Print message, error details, and halt after begin() fails.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorHalt() [4/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( | Print * | pr,
|  | char const * | msg
| ) |  |
| inlineinherited

Print message, error details, and halt after begin() fails.

Parameters

  [in] | pr | Print device.
  [in] | msg | Message to print.

## ◆ initErrorHalt() [5/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( | const __FlashStringHelper * | msg | ) |
| inlineinherited

Print message, error details, and halt after begin() fails.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorHalt() [6/6]

void SdFileSystem< SdSpiCard >::initErrorHalt | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print message, error details, and halt after begin() fails.

Parameters

  [in] | pr | Print device for message.
  [in] | msg | Message to print.

## ◆ initErrorPrint() [1/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( |  | ) |
| inlineinherited

Print error details after begin() fails.

## ◆ initErrorPrint() [2/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( | Print * | pr | ) |
| inlineinherited

Print error details after begin() fails.

Parameters

  [in] | pr | Print destination.

## ◆ initErrorPrint() [3/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( | char const * | msg | ) |
| inlineinherited

Print message and error details and halt after begin() fails.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorPrint() [4/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( | Print * | pr,
|  | char const * | msg
| ) |  |
| inlineinherited

Print message and error details and halt after begin() fails.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ initErrorPrint() [5/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( | const __FlashStringHelper * | msg | ) |
| inlineinherited

Print message and error details and halt after begin() fails.

Parameters

  [in] | msg | Message to print.

## ◆ initErrorPrint() [6/6]

void SdFileSystem< SdSpiCard >::initErrorPrint | ( | Print * | pr,
|  | const __FlashStringHelper * | msg
| ) |  |
| inlineinherited

Print message and error details and halt after begin() fails.

Parameters

  [in] | pr | Print destination.
  [in] | msg | Message to print.

## ◆ ls() [1/4]

void FatFileSystem::ls | ( | uint8_t | flags = `0` | ) |
| inlineinherited

List the directory contents of the volume working directory to Serial.

Parameters

  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

## ◆ ls() [2/4]

void FatFileSystem::ls | ( | const char * | path,
|  | uint8_t | flags = `0`
| ) |  |
| inlineinherited

List the directory contents of a directory to Serial.

Parameters

  [in] | path | directory to list.
  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

## ◆ ls() [3/4]

void FatFileSystem::ls | ( | print_t * | pr,
|  | uint8_t | flags = `0`
| ) |  |
| inlineinherited

List the directory contents of the volume working directory.

Parameters

  [in] | pr | Print stream for list.
  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

## ◆ ls() [4/4]

void FatFileSystem::ls | ( | print_t * | pr,
|  | const char * | path,
|  | uint8_t | flags
| ) |  |
| inlineinherited

List the directory contents of a directory.

Parameters

  [in] | pr | Print stream for list.
  [in] | path | directory to list.
  [in] | flags | The inclusive OR of

LS_DATE - Print file modification date

LS_SIZE - Print file size.

LS_R - Recursive list of subdirectories.

## ◆ mkdir()

bool FatFileSystem::mkdir | ( | const char * | path,
|  | bool | pFlag = `true`
| ) |  |
| inlineinherited

Make a subdirectory in the volume working directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the subdirectory.
  [in] | pFlag | Create missing parent directories if true.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ open() [1/2]

File FatFileSystem::open | ( | const char * | path,
|  | oflag_t | oflag = `FILE_READ`
| ) |  |
| inlineinherited

open a file

Parameters

  [in] | path | location of file to be opened.
  [in] | oflag | open flags.

Returns
  a File object.

## ◆ open() [2/2]

File FatFileSystem::open | ( | const String & | path,
|  | oflag_t | oflag = `FILE_READ`
| ) |  |
| inlineinherited

open a file

Parameters

  [in] | path | location of file to be opened.
  [in] | oflag | open flags.

Returns
  a File object.

## ◆ remove()

bool FatFileSystem::remove | ( | const char * | path | ) |
| inlineinherited

Remove a file from the volume working directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the file.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ rename()

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

Rename a file or subdirectory.

Parameters

  [in] | oldPath | Path name to the file or subdirectory to be renamed.
  [in] | newPath | New 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
  The value true is returned for success and the value false is returned for failure.

## ◆ rmdir()

bool FatFileSystem::rmdir | ( | const char * | path | ) |
| inlineinherited

Remove a subdirectory from the volume's working directory.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the subdirectory.

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

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ rootDirEntryCount()

uint16_t FatVolume::rootDirEntryCount | ( |  | ) | const
| inlineinherited

Returns
  The number of entries in the root directory for FAT16 volumes.

## ◆ rootDirStart()

uint32_t FatVolume::rootDirStart | ( |  | ) | const
| inlineinherited

Returns
  The logical block number for the start of the root directory on FAT16 volumes or the first cluster number on FAT32 volumes.

## ◆ truncate()

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

Truncate a file to a specified length. The current file position will be maintained if it is less than or equal to length otherwise it will be set to end of file.

Parameters

  [in] | path | A path with a valid 8.3 DOS name for the file.
  [in] | length | The desired length for the file.

Returns
  The value true is returned for success and the value false is returned for failure.

## ◆ vol()

FatVolume* FatFileSystem::vol | ( |  | ) |
| inlineinherited

Returns
  a pointer to the FatVolume object.

## ◆ volumeBlockCount()

uint32_t FatVolume::volumeBlockCount | ( |  | ) | const
| inlineinherited

Returns
  The number of blocks in the volume

## ◆ vwd()

FatFile* FatFileSystem::vwd | ( |  | ) |
| inlineinherited

Returns
  a pointer to the volume working directory.

## ◆ wipe()

bool FatFileSystem::wipe | ( | print_t * | pr = `0` | ) |
| inlineinherited

Wipe all data from the volume. You must reinitialize the volume before accessing it again.

Parameters

  [in] | pr | print stream for status dots.

Returns
  true for success else false.

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

- Arduino/libraries/SdFat/src/SdFat.h