Data Gator
Hardware and software documentation for the Data Gator project.
Loading...
Searching...
No Matches
SDCard Class Reference

Thin wrapper around ESP32 SD card API. More...

#include <SDCard.hpp>

Public Types

using File = fs::File
 

Public Member Functions

 operator bool () const
 
bool begin (uint8_t clkPin=TT_CLK, uint8_t misoPin=TT_MISO, uint8_t mosiPin=TT_MOSI, uint8_t ssPin=TT_SS, SPIClass *spi=&SPI)
 
void end ()
 Terminate connection to SD Card and associated SPI interface.
 
File open (const char *path, const char *mode=FILE_READ, const bool create=false)
 
File open (const String &path, const char *mode=FILE_READ, const bool create=false)
 
bool exists (const char *path)
 
bool exists (const String &path)
 
bool remove (const char *path)
 
bool remove (const String &path)
 
bool rename (const char *pathFrom, const char *pathTo)
 
bool rename (const String &pathFrom, const String &pathTo)
 
bool mkdir (const char *path)
 
bool mkdir (const String &path)
 
bool rmdir (const char *path)
 
bool rmdir (const String &path)
 

Private Attributes

fs::SDFS * mCard
 

Detailed Description

Thin wrapper around ESP32 SD card API.

Only works with ESP32 Arduino framework

Member Typedef Documentation

◆ File

using SDCard::File = fs::File

File implements close(), read(), write(), fs implements open, etc.

Member Function Documentation

◆ begin()

bool SDCard::begin ( uint8_t  clkPin = TT_CLK,
uint8_t  misoPin = TT_MISO,
uint8_t  mosiPin = TT_MOSI,
uint8_t  ssPin = TT_SS,
SPIClass spi = &SPI 
)
inline

Function to connect to an SD card using the specified pins and SPI interface.

For more information on SPI https://en.wikipedia.org/wiki/Serial_Peripheral_Interface ESP32 docs https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/spi_master.html

Parameters
clkPin- GPIO pin that provides the clock signal.
misoPin- Master in slave out pin.
mosiPin- Master out slave in pin.
ssPin- Chip/Save select.
spi- Pointer to SPI interface.
Returns
true if interface setup worked false otherwise.

◆ exists()

bool SDCard::exists ( const char path)
inline

Check to see if path exists.

Parameters
pathpath to file or directory.
Returns
true if path exists false otherwise.

◆ mkdir()

bool SDCard::mkdir ( const char path)
inline

Create a directory

If directory doesn't exist it will be created.

Parameters
pathpath to directory to create. Naming conventions are the same as for files. For example "\testdir" will be in the root of the device.
Returns
true if path was created false otherwise.

◆ open()

File SDCard::open ( const char path,
const char mode = FILE_READ,
const bool  create = false 
)
inline

Open and possibly create a file.

Parameters
pathName of file. This API uses the 8.3 DOS file name rules. The full path of the file needs to be specified. Files in the root of the device will requre a "/". For example "/test.txt".
mode"w", "r", "a". Simple C style modes.
createIf true allows creation of the file. true is implied if mode is "w".
Returns
File interface.

◆ operator bool()

SDCard::operator bool ( ) const
inlineexplicit

Operator to test if properly initialized.

Returns
true if connected to the SD interface.

◆ remove()

bool SDCard::remove ( const char path)
inline

Permantly delete a file or directory

Parameters
pathpath to file or directory.
Returns
true if path was deleted false otherwise.

◆ rename()

bool SDCard::rename ( const char pathFrom,
const char pathTo 
)
inline

Permantly rename a file or directory

Parameters
pathFrompath to original file or directory
pathTopath to new file or directory
Returns
true if path was renamed false otherwise.

◆ rmdir()

bool SDCard::rmdir ( const char path)
inline

Delete a directory

path must be an empty directory.

Parameters
pathpath to directory to delete.
Returns
true if path was deleted false otherwise.

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