Raw access to SD and SDHC card using default SPI library.
More...
#include <SdSpiCard.h>
|
bool | begin (uint8_t chipSelectPin=SS, uint8_t sckDivisor=2) |
|
uint32_t | cardSize () |
|
void | chipSelectHigh () |
|
void | chipSelectLow () |
|
bool | erase (uint32_t firstBlock, uint32_t lastBlock) |
|
bool | eraseSingleBlockEnable () |
|
void | error (uint8_t code) |
|
int | errorCode () const |
|
int | errorData () const |
|
bool | init (uint8_t sckDivisor=2, uint8_t chipSelectPin=SS) |
|
bool | isBusy () |
|
bool | readBlock (uint32_t block, uint8_t *dst) |
|
bool | readBlocks (uint32_t block, uint8_t *dst, size_t count) |
|
bool | readCID (cid_t *cid) |
|
bool | readCSD (csd_t *csd) |
|
bool | readData (uint8_t *dst) |
|
bool | readOCR (uint32_t *ocr) |
|
bool | readStart (uint32_t blockNumber) |
|
bool | readStop () |
|
uint8_t | sckDivisor () |
|
bool | selected () |
|
int | type () const |
|
bool | writeBlock (uint32_t blockNumber, const uint8_t *src) |
|
bool | writeBlocks (uint32_t block, const uint8_t *src, size_t count) |
|
bool | writeData (const uint8_t *src) |
|
bool | writeStart (uint32_t blockNumber, uint32_t eraseCount) |
|
bool | writeStop () |
|
Raw access to SD and SDHC card using default SPI library.
bool Sd2Card::begin |
( |
uint8_t |
chipSelectPin = SS , |
|
|
uint8_t |
sckDivisor = 2 |
|
) |
| |
|
inline |
Initialize the SD card.
- Parameters
-
[in] | chipSelectPin | SD chip select pin. |
[in] | sckDivisor | SPI clock divisor. |
- Returns
- true for success else false.
uint32_t SdSpiCard::cardSize |
( |
| ) |
|
|
inherited |
Determine the size of an SD flash memory card.
- Returns
- The number of 512 byte data blocks in the card or zero if an error occurs.
void SdSpiCard::chipSelectHigh |
( |
| ) |
|
|
inherited |
Set the SD chip select pin high, send a dummy byte, and call SPI endTransaction.
This function should only be called by programs doing raw I/O to the SD.
void SdSpiCard::chipSelectLow |
( |
| ) |
|
|
inherited |
Set the SD chip select pin low and call SPI beginTransaction.
This function should only be called by programs doing raw I/O to the SD.
bool SdSpiCard::erase |
( |
uint32_t |
firstBlock, |
|
|
uint32_t |
lastBlock |
|
) |
| |
|
inherited |
Erase a range of blocks.
- Parameters
-
[in] | firstBlock | The address of the first block in the range. |
[in] | lastBlock | The address of the last block in the range. |
- Note
- This function requests the SD card to do a flash erase for a range of blocks. The data on the card after an erase operation is either 0 or 1, depends on the card vendor. The card must support single block erase.
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::eraseSingleBlockEnable |
( |
| ) |
|
|
inherited |
Determine if card supports single block erase.
- Returns
- true is returned if single block erase is supported. false is returned if single block erase is not supported.
void SdSpiCard::error |
( |
uint8_t |
code | ) |
|
|
inlineinherited |
Set SD error code.
- Parameters
-
[in] | code | value for error code. |
int SdSpiCard::errorCode |
( |
| ) |
const |
|
inlineinherited |
- Returns
- code for the last error. See SdSpiCard.h for a list of error codes.
int SdSpiCard::errorData |
( |
| ) |
const |
|
inlineinherited |
- Returns
- error data for last error.
bool Sd2Card::init |
( |
uint8_t |
sckDivisor = 2 , |
|
|
uint8_t |
chipSelectPin = SS |
|
) |
| |
|
inline |
Initialize the SD card. Obsolete form.
- Parameters
-
[in] | chipSelectPin | SD chip select pin. |
[in] | sckDivisor | SPI clock divisor. |
- Returns
- true for success else false.
bool SdSpiCard::isBusy |
( |
| ) |
|
|
inherited |
Check for busy. MISO low indicates the card is busy.
- Returns
- true if busy else false.
bool SdSpiCard::readBlock |
( |
uint32_t |
block, |
|
|
uint8_t * |
dst |
|
) |
| |
|
inherited |
Read a 512 byte block from an SD card.
- Parameters
-
[in] | block | Logical block to be read. |
[out] | dst | Pointer to the location that will receive the data. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::readBlocks |
( |
uint32_t |
block, |
|
|
uint8_t * |
dst, |
|
|
size_t |
count |
|
) |
| |
|
inherited |
Read multiple 512 byte blocks from an SD card.
- Parameters
-
[in] | block | Logical block to be read. |
[in] | count | Number of blocks to be read. |
[out] | dst | Pointer to the location that will receive the data. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::readCID |
( |
cid_t * |
cid | ) |
|
|
inlineinherited |
Read a card's CID register. The CID contains card identification information such as Manufacturer ID, Product name, Product serial number and Manufacturing date.
- Parameters
-
[out] | cid | pointer to area for returned data. |
- Returns
- true for success or false for failure.
bool SdSpiCard::readCSD |
( |
csd_t * |
csd | ) |
|
|
inlineinherited |
Read a card's CSD register. The CSD contains Card-Specific Data that provides information regarding access to the card's contents.
- Parameters
-
[out] | csd | pointer to area for returned data. |
- Returns
- true for success or false for failure.
bool SdSpiCard::readData |
( |
uint8_t * |
dst | ) |
|
|
inherited |
Read one data block in a multiple block read sequence
- Parameters
-
[out] | dst | Pointer to the location for the data to be read. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::readOCR |
( |
uint32_t * |
ocr | ) |
|
|
inherited |
Read OCR register.
- Parameters
-
[out] | ocr | Value of OCR register. |
- Returns
- true for success else false.
bool SdSpiCard::readStart |
( |
uint32_t |
blockNumber | ) |
|
|
inherited |
Start a read multiple blocks sequence.
- Parameters
-
[in] | blockNumber | Address of first block in sequence. |
- Note
- This function is used with readData() and readStop() for optimized multiple block reads. SPI chipSelect must be low for the entire sequence.
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::readStop |
( |
| ) |
|
|
inherited |
End a read multiple blocks sequence.
- Returns
- The value true is returned for success and the value false is returned for failure.
uint8_t SdSpiCard::sckDivisor |
( |
| ) |
|
|
inlineinherited |
Return SCK divisor.
- Returns
- Requested SCK divisor.
bool SdSpiCard::selected |
( |
| ) |
|
|
inlineinherited |
- Returns
- the SD chip select status, true if slected else false.
int SdSpiCard::type |
( |
| ) |
const |
|
inlineinherited |
Return the card type: SD V1, SD V2 or SDHC
- Returns
- 0 - SD V1, 1 - SD V2, or 3 - SDHC.
bool SdSpiCard::writeBlock |
( |
uint32_t |
blockNumber, |
|
|
const uint8_t * |
src |
|
) |
| |
|
inherited |
Writes a 512 byte block to an SD card.
- Parameters
-
[in] | blockNumber | Logical block to be written. |
[in] | src | Pointer to the location of the data to be written. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::writeBlocks |
( |
uint32_t |
block, |
|
|
const uint8_t * |
src, |
|
|
size_t |
count |
|
) |
| |
|
inherited |
Write multiple 512 byte blocks to an SD card.
- Parameters
-
[in] | block | Logical block to be written. |
[in] | count | Number of blocks to be written. |
[in] | src | Pointer to the location of the data to be written. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::writeData |
( |
const uint8_t * |
src | ) |
|
|
inherited |
Write one data block in a multiple block write sequence.
- Parameters
-
[in] | src | Pointer to the location of the data to be written. |
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::writeStart |
( |
uint32_t |
blockNumber, |
|
|
uint32_t |
eraseCount |
|
) |
| |
|
inherited |
Start a write multiple blocks sequence.
- Parameters
-
[in] | blockNumber | Address of first block in sequence. |
[in] | eraseCount | The number of blocks to be pre-erased. |
- Note
- This function is used with writeData() and writeStop() for optimized multiple block writes.
- Returns
- The value true is returned for success and the value false is returned for failure.
bool SdSpiCard::writeStop |
( |
| ) |
|
|
inherited |
End a write multiple blocks sequence.
- Returns
- The value true is returned for success and the value false is returned for failure.
The documentation for this class was generated from the following file: