|
COSA
An Object-Oriented Platform for Arduino Programming
|
#include <SD.hh>


Classes | |
| struct | cid_t |
| union | csd_t |
| struct | csd_v1_t |
| struct | csd_v2_t |
| union | R1 |
| union | R2 |
| struct | R3 |
| union | R6 |
| union | R7 |
| struct | request_t |
Public Types | |
| enum | CARD { TYPE_UNKNOWN = 0, TYPE_SD1 = 1, TYPE_SD2 = 2, TYPE_SDHC = 3 } |
Public Member Functions | |
| SD (Board::DigitalPin csn=Board::D8) | |
| CARD | type () const |
| bool | begin (SPI::Clock rate=SPI::DIV128_CLOCK) |
| bool | end () |
| bool | erase (uint32_t start, uint32_t end) |
| bool | read (uint32_t block, uint8_t *dst) |
| bool | read (cid_t *cid) |
| bool | read (csd_t *csd) |
| bool | write (uint32_t block, const uint8_t *src) |
Static Public Attributes | |
| static const size_t | BLOCK_MAX = 512 |
Protected Member Functions | |
| uint8_t | send (CMD command, uint32_t arg=0L) |
| bool | send (uint16_t ms, CMD command, uint32_t arg=0L) |
| uint8_t | send (ACMD command, uint32_t arg=0L) |
| bool | send (uint16_t ms, ACMD command, uint32_t arg=0L) |
| bool | await (uint16_t ms=0, uint8_t token=0) |
| uint32_t | receive () |
| bool | read (CMD command, uint32_t arg, void *buf, size_t count) |
Protected Attributes | |
| uint8_t | m_response |
| CARD | m_type |
Static Protected Attributes | |
| static const uint8_t | CHECK_PATTERN = 0xAA |
| static const uint16_t | INIT_TIMEOUT = 2000 |
| static const uint16_t | ERASE_TIMEOUT = 10000 |
| static const uint16_t | READ_TIMEOUT = 300 |
| static const uint16_t | WRITE_TIMEOUT = 600 |
| static const uint8_t | INIT_PULSES = 10 |
| static const uint8_t | INIT_RETRY = 200 |
| static const uint8_t | RESPONSE_RETRY = 100 |
Private Member Functions | |
| void | set_clock (Clock rate) |
| void | set_clock (uint32_t freq) |
Static Private Member Functions | |
| static Clock | clock (uint32_t freq) |
| static Clock | cycle (uint16_t ns) |
Private Attributes | |
| Driver * | m_next |
| List of drivers. More... | |
| Interrupt::Handler * | m_irq |
| Interrupt handler. More... | |
| OutputPin | m_cs |
| Device chip select pin. More... | |
| Pulse | m_pulse |
| Chip select pulse width. More... | |
| uint8_t | m_spcr |
| SPI/SPCR hardware control register setting. More... | |
| uint8_t | m_spsr |
| SPI/SPSR hardware status register. More... | |
Cosa SD low-level device driver class. Implements disk driver connect/disconnect, erase, read and write block.
|
protected |
Table 4-28: Application-Specific Commands.
| enum SD::CARD |
|
protected |
Command Abbreviations.
| Enumerator | |
|---|---|
| GO_IDLE_STATE |
Reset the SD Memory Card. |
| ALL_SEND_CID |
Sends host capacity support information. |
| SEND_RELATIVE_ADDR |
Checks switchable function. |
| SET_DSR |
Programs the DSR of all cards. |
| SWITCH_FUNC |
Checks switchable function. |
| SELECT_DESELECT_CARD |
Toggles card state (stdby/prog and disc). |
| SEND_IF_COND |
Sends SD Memory Card interface condition. |
| SEND_CSD |
Asks the selected card to send CSD. |
| SEND_CID |
Asks the selected card to send CID. |
| VOLTAGE_SWITCH |
Switch to 1V8 bus signaling level. |
| STOP_TRANSMISSION |
Stop Multiple Block Read. |
| SEND_STATUS |
Asks the selected card status register. |
| GO_INACTIVE_STATE |
Addressed card into inactive state. |
| SET_BLOCKLEN |
Set block length (in bytes). |
| READ_SINGLE_BLOCK |
Read block length bytes. |
| READ_MULTIPLE_BLOCK |
Read blocks until STOP_TRANSMISSION. |
| SEND_TUNING_BLOCK |
Send 64 byte tuning pattern to card. |
| SPEED_CLASS_CONTROL |
Check speed class. |
| SET_BLOCK_COUNT |
Specify block count for multiple block. |
| WRITE_BLOCK |
Write block length bytes. |
| WRITE_MULTIPLE_BLOCK |
Write block until STOP_TRANSMISSION. |
| PROGRAM_CSD |
Set programmable bits in CSD. |
| SET_WRITE_PROT |
Set write protect bit. |
| CLR_WRITE_PROT |
Clears write protect bit. |
| SEND_WRITE_PROT |
Read write protect bit. |
| ERASE_WR_BLK_START |
Set first write block to be erased. |
| ERASE_WR_BLK_END |
Set last write block to be erased. |
| ERASE |
Erases selected write blocks. |
| LOCK_UNLOCK |
Set/reset password or unlock/lock card. |
| APP_CMD |
Next command is application specific command. |
| GEN_CMD |
Data block for application specific command. |
| READ_OCR |
Read OCR register of a card. |
| CRC_ON_OFF |
Turns the CRC on/off. |
|
protected |
|
protected |
|
inline |
|
protected |
Await the completion of a command. Wait for at most given period in milli-seconds (default zero will block). Return true if command was completed otherwise false if the time limit was exceeded.
| [in] | ms | timeout period in number of milli-seconds (default 0). |
| [in] | token | to await (default any). |
| bool SD::begin | ( | SPI::Clock | rate = SPI::DIV128_CLOCK | ) |
| bool SD::end | ( | ) |
| bool SD::erase | ( | uint32_t | start, |
| uint32_t | end | ||
| ) |
|
protected |
Send given command and argument and transfer data response into given buffer with given number of bytes. Returns true if successful otherwise false.
| [in] | command | to send. |
| [in] | arg | argument. |
| [in] | buf | pointer to buffer for response data. |
| [in] | count | number of bytes. |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Send given application specific command and argument. Resend if response any error state. Return true if command was issued successfully otherwise false.
| [in] | ms | number of milli-seconds to resend. |
| [in] | command | to send. |
| [in] | arg | argument (default 0L). |
| bool SD::write | ( | uint32_t | block, |
| const uint8_t * | src | ||
| ) |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |