WaveHC
Public Member Functions
SdReader Class Reference

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

#include <SdReader.h>

List of all members.

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)
uint8_t readCSD (csd_t &csd)
void readEnd (void)
uint8_t type ()

Detailed Description

Hardware access class for SD flash cards.

Supports raw access to SD and SDHC flash memory cards.


Constructor & Destructor Documentation

SdReader::SdReader ( void  ) [inline]

Construct an instance of SdReader.


Member Function Documentation

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
uint8_t SdReader::errorCode ( void  ) [inline]
Returns:
error code for last error
uint8_t SdReader::errorData ( void  ) [inline]
Returns:
error data for last error
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.
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).)
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.
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.

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.

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.
void SdReader::readEnd ( void  )

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

uint8_t SdReader::type ( ) [inline]

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


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