ESP8266
|
Raw access to SD and SDHC flash memory cards. More...
Public Member Functions | |
Sd2Card (void) | |
uint32_t | cardSize (void) |
uint8_t | erase (uint32_t firstBlock, uint32_t lastBlock) |
uint8_t | eraseSingleBlockEnable (void) |
uint8_t | errorCode (void) const |
uint8_t | errorData (void) const |
uint8_t | init (void) |
uint8_t | init (uint32_t sckRateID) |
uint8_t | init (uint32_t sckRateID, uint8_t chipSelectPin) |
void | partialBlockRead (uint8_t value) |
uint8_t | partialBlockRead (void) const |
uint8_t | readBlock (uint32_t block, uint8_t *dst) |
uint8_t | readData (uint32_t block, uint16_t offset, uint16_t count, uint8_t *dst) |
uint8_t | readCID (cid_t *cid) |
uint8_t | readCSD (csd_t *csd) |
void | readEnd (void) |
uint8_t | setSckRate (uint32_t sckRateID) |
uint8_t | type (void) const |
uint8_t | writeBlock (uint32_t blockNumber, const uint8_t *src) |
uint8_t | writeData (const uint8_t *src) |
uint8_t | writeStart (uint32_t blockNumber, uint32_t eraseCount) |
uint8_t | writeStop (void) |
Private Member Functions | |
uint8_t | cardAcmd (uint8_t cmd, uint32_t arg) |
uint8_t | cardCommand (uint8_t cmd, uint32_t arg) |
void | error (uint8_t code) |
uint8_t | readRegister (uint8_t cmd, void *buf) |
uint8_t | sendWriteCommand (uint32_t blockNumber, uint32_t eraseCount) |
void | chipSelectHigh (void) |
void | chipSelectLow (void) |
void | type (uint8_t value) |
uint8_t | waitNotBusy (uint16_t timeoutMillis) |
uint8_t | writeData (uint8_t token, const uint8_t *src) |
uint8_t | waitStartBlock (void) |
Private Attributes | |
uint32_t | block_ |
uint8_t | chipSelectPin_ |
uint8_t | errorCode_ |
uint8_t | inBlock_ |
uint16_t | offset_ |
uint8_t | partialBlockRead_ |
uint8_t | status_ |
uint8_t | type_ |
Raw access to SD and SDHC flash memory cards.
Sd2Card::Sd2Card | ( | void | ) |
Construct an instance of Sd2Card.
|
private |
|
private |
uint32_t Sd2Card::cardSize | ( | void | ) |
Determine the size of an SD flash memory card.
|
private |
|
private |
uint8_t Sd2Card::erase | ( | uint32_t | firstBlock, |
uint32_t | lastBlock | ||
) |
Erase a range of blocks.
[in] | firstBlock | The address of the first block in the range. |
[in] | lastBlock | The address of the last block in the range. |
uint8_t Sd2Card::eraseSingleBlockEnable | ( | void | ) |
Determine if card supports single block erase.
|
private |
uint8_t Sd2Card::errorCode | ( | void | ) | const |
uint8_t Sd2Card::errorData | ( | void | ) | const |
uint8_t Sd2Card::init | ( | void | ) |
Initialize an SD flash memory card with default clock rate and chip select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin).
uint8_t Sd2Card::init | ( | uint32_t | sckRateID | ) |
Initialize an SD flash memory card with the selected SPI clock rate and the default SD chip select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin).
uint8_t Sd2Card::init | ( | uint32_t | sckRateID, |
uint8_t | chipSelectPin | ||
) |
Initialize an SD flash memory card.
[in] | sckRateID | SPI clock rate selector. See setSckRate(). |
[in] | chipSelectPin | SD chip select pin number. |
void Sd2Card::partialBlockRead | ( | uint8_t | value | ) |
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 may occur if the time between reads is too long since the SD card may timeout. The SPI SS line will be held low until the entire block is read or readEnd() is called.
Use this for applications like the Adafruit Wave Shield.
[in] | value | The value TRUE (non-zero) or FALSE (zero).) |
uint8_t Sd2Card::partialBlockRead | ( | void | ) | const |
Returns the current value, true or false, for partial block read.
uint8_t Sd2Card::readBlock | ( | uint32_t | block, |
uint8_t * | dst | ||
) |
Read a 512 byte block from an SD card device.
[in] | block | Logical block to be read. |
[out] | dst | Pointer to the location that will receive the data. |
uint8_t Sd2Card::readCID | ( | cid_t * | cid | ) |
uint8_t Sd2Card::readCSD | ( | csd_t * | csd | ) |
Read a cards CSD register. The CSD contains Card-Specific Data that provides information regarding access to the card's contents.
uint8_t Sd2Card::readData | ( | uint32_t | block, |
uint16_t | offset, | ||
uint16_t | count, | ||
uint8_t * | dst | ||
) |
Read part of a 512 byte block from an SD card.
[in] | block | Logical block to be read. |
[in] | offset | Number of bytes to skip at start of block |
[out] | dst | Pointer to the location that will receive the data. |
[in] | count | Number of bytes to read |
void Sd2Card::readEnd | ( | void | ) |
Skip remaining data in a block when in partial block read mode.
|
private |
read CID or CSR register
|
private |
uint8_t Sd2Card::setSckRate | ( | uint32_t | sckRateID | ) |
Set the SPI clock rate.
[in] | sckRateID | A value in the range [0, 6]. |
The SPI clock will be set to F_CPU/pow(2, 1 + sckRateID). The maximum SPI rate is F_CPU/2 for sckRateID = 0 and the minimum rate is F_CPU/128 for scsRateID = 6.
uint8_t Sd2Card::type | ( | void | ) | const |
Return the card type: SD V1, SD V2 or SDHC
|
private |
|
private |
|
private |
Wait for start block token
uint8_t Sd2Card::writeBlock | ( | uint32_t | blockNumber, |
const uint8_t * | src | ||
) |
Writes a 512 byte block to an SD card.
[in] | blockNumber | Logical block to be written. |
[in] | src | Pointer to the location of the data to be written. |
uint8_t Sd2Card::writeData | ( | const uint8_t * | src | ) |
Write one data block in a multiple block write sequence
|
private |
uint8_t Sd2Card::writeStart | ( | uint32_t | blockNumber, |
uint32_t | eraseCount | ||
) |
Start a write multiple blocks sequence.
[in] | blockNumber | Address of first block in sequence. |
[in] | eraseCount | The number of blocks to be pre-erased. |
uint8_t Sd2Card::writeStop | ( | void | ) |
End a write multiple blocks sequence.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |