Adafruit WaveHC Arduino Library
Public Member Functions | List of all members
SdReader Class Reference

Hardware access class for SD flash cards. More...

#include <SdReader.h>

Public Member Functions

 SdReader (void)
 
uint32_t cardSize (void)
 
uint8_t errorCode (void)
 
uint8_t errorData (void)
 
uint8_t init (uint8_t slow=SPI_DEFAULT_HALF_SPEED)
 
void partialBlockRead (uint8_t value)
 
uint8_t readBlock (uint32_t block, uint8_t *dst)
 
uint8_t readData (uint32_t block, uint16_t offset, uint8_t *dst, uint16_t count)
 
uint8_t readCID (cid_t &cid)
 Read a cards CID register. The CID contains card identification information such as Manufacturer ID, Product name, Product serial number and Manufacturing date. More...
 
uint8_t readCSD (csd_t &csd)
 Read a cards CSD register. The CSD contains Card-Specific Data that provides information regarding access to the card contents. More...
 
void readEnd (void)
 
uint8_t type ()
 Return the card type: SD V1, SD V2 or SDHC. More...
 

Detailed Description

Hardware access class for SD flash cards.

Supports raw access to SD and SDHC flash memory cards.

Constructor & Destructor Documentation

◆ SdReader()

SdReader::SdReader ( void  )
inline

Construct an instance of SdReader.

Member Function Documentation

◆ cardSize()

uint32_t SdReader::cardSize ( void  )

Determine the size of an SD flash memory card.

Returns
The number of 512 byte data blocks in the card

◆ errorCode()

uint8_t SdReader::errorCode ( void  )
inline
Returns
error code for last error

◆ errorData()

uint8_t SdReader::errorData ( void  )
inline
Returns
error data for last error

◆ init()

uint8_t SdReader::init ( uint8_t  slow = SPI_DEFAULT_HALF_SPEED)

Initialize a SD flash memory card.

Parameters
[in]slowIf slow is false (zero) the SPI bus will be initialize at a speed of 8 Mhz. If slow is true (nonzero) the SPI bus will be initialize a speed of 4 Mhz. This may be helpful for some SD cards with Version 1.0 of the Adafruit Wave Shield.
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure.

◆ partialBlockRead()

void SdReader::partialBlockRead ( uint8_t  value)
inline

Enable or disable partial block reads.

Enabling partial block reads improves performance by allowing a block to be read over the SPI bus as several sub-blocks. Errors will occur if the time between reads is too long since the SD card will timeout.

Use this for applications like the Adafruit Wave Shield.

Parameters
[in]valueThe value TRUE (non-zero) or FALSE (zero).)

◆ readBlock()

uint8_t SdReader::readBlock ( uint32_t  block,
uint8_t *  dst 
)
inline

Read a 512 byte block from a SD card device.

Parameters
[in]blockLogical block to be read.
[out]dstPointer to the location that will receive the data.
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure.

◆ readData()

uint8_t SdReader::readData ( uint32_t  block,
uint16_t  offset,
uint8_t *  dst,
uint16_t  count 
)

Read part of a 512 byte block from a SD card.

Parameters
[in]blockLogical block to be read.
[in]offsetNumber of bytes to skip at start of block
[out]dstPointer to the location that will receive the data.
[in]countNumber of bytes to read
Returns
The value one, true, is returned for success and the value zero, false, is returned for failure.

◆ readCID()

uint8_t SdReader::readCID ( cid_t cid)
inline

Read a cards CID register. The CID contains card identification information such as Manufacturer ID, Product name, Product serial number and Manufacturing date.

Read a cards CID register. The CID contains card identification information such as Manufacturer ID, Product name, Product serial number and Manufacturing date.

Parameters
cidthe pointer to the cid struct the data should be placed in
Returns
the return code after the read

◆ readCSD()

uint8_t SdReader::readCSD ( csd_t csd)
inline

Read a cards CSD register. The CSD contains Card-Specific Data that provides information regarding access to the card contents.

Parameters
csdpointer to the struct the data should be placed in.
Returns
the return code after the read.

◆ readEnd()

void SdReader::readEnd ( void  )

Skip remaining data in a block when in partial block read mode.

◆ type()

uint8_t SdReader::type ( )
inline

Return the card type: SD V1, SD V2 or SDHC.

Returns
the type

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