![]() |
Soldered SD Card Arduino Library 1.0.0
Easily read and write files to and form the SD card breakout! A fork of the original SDFat library by Bill Greiman.
|
Go to the source code of this file.
Classes | |
| class | CID |
| Card IDentification (CID) register. More... | |
| class | CSDV1 |
| CSD register for version 1.00 cards . More... | |
| class | CSDV2 |
| CSD register for version 2.00 cards. More... | |
| class | csd_t |
| Union of old and new style CSD register. More... | |
| struct | SdStatus |
Typedefs | |
| typedef struct SdStatus | SdStatus_t |
Enumerations | |
| enum | { SD_CARD_ERROR_UNKNOWN } |
Functions | |
| void | printSdErrorSymbol (print_t *pr, uint8_t code) |
| void | printSdErrorText (print_t *pr, uint8_t code) |
| struct CID | __attribute__ ((packed)) cid_t |
| uint32_t | sdCardCapacity (csd_t *csd) |
Variables | |
| const uint8_t | SD_CARD_TYPE_SD1 = 1 |
| const uint8_t | SD_CARD_TYPE_SD2 = 2 |
| const uint8_t | SD_CARD_TYPE_SDHC = 3 |
| const uint8_t | SD_CMD0_RETRY = 10 |
| const uint16_t | SD_CMD_TIMEOUT = 300 |
| const uint16_t | SD_ERASE_TIMEOUT = 10000 |
| const uint16_t | SD_INIT_TIMEOUT = 2000 |
| const uint16_t | SD_READ_TIMEOUT = 300 |
| const uint16_t | SD_WRITE_TIMEOUT = 600 |
| const uint8_t | CMD0 = 0X00 |
| const uint8_t | CMD2 = 0X02 |
| const uint8_t | CMD3 = 0X03 |
| const uint8_t | CMD6 = 0X06 |
| const uint8_t | CMD7 = 0X07 |
| const uint8_t | CMD8 = 0X08 |
| const uint8_t | CMD9 = 0X09 |
| const uint8_t | CMD10 = 0X0A |
| const uint8_t | CMD11 = 0X0B |
| const uint8_t | CMD12 = 0X0C |
| const uint8_t | CMD13 = 0X0D |
| const uint8_t | CMD17 = 0X11 |
| const uint8_t | CMD18 = 0X12 |
| const uint8_t | CMD24 = 0X18 |
| const uint8_t | CMD25 = 0X19 |
| const uint8_t | CMD32 = 0X20 |
| const uint8_t | CMD33 = 0X21 |
| const uint8_t | CMD38 = 0X26 |
| const uint8_t | CMD55 = 0X37 |
| const uint8_t | CMD58 = 0X3A |
| const uint8_t | CMD59 = 0X3B |
| const uint8_t | ACMD6 = 0X06 |
| const uint8_t | ACMD13 = 0X0D |
| const uint8_t | ACMD23 = 0X17 |
| const uint8_t | ACMD41 = 0X29 |
| const uint32_t | CARD_STATUS_OUT_OF_RANGE = 1UL << 31 |
| const uint32_t | CARD_STATUS_ADDRESS_ERROR = 1UL << 30 |
| const uint32_t | CARD_STATUS_SECTOR_LEN_ERROR = 1UL << 29 |
| const uint32_t | CARD_STATUS_ERASE_SEQ_ERROR = 1UL << 28 |
| const uint32_t | CARD_STATUS_ERASE_PARAM = 1UL << 27 |
| const uint32_t | CARD_STATUS_WP_VIOLATION = 1UL << 26 |
| const uint32_t | CARD_STATUS_CARD_IS_LOCKED = 1UL << 25 |
| const uint32_t | CARD_STATUS_LOCK_UNLOCK_FAILED = 1UL << 24 |
| const uint32_t | CARD_STATUS_COM_CRC_ERROR = 1UL << 23 |
| const uint32_t | CARD_STATUS_ILLEGAL_COMMAND = 1UL << 22 |
| const uint32_t | CARD_STATUS_CARD_ECC_FAILED = 1UL << 21 |
| const uint32_t | CARD_STATUS_CC_ERROR = 1UL << 20 |
| const uint32_t | CARD_STATUS_ERROR = 1UL << 19 |
| const uint32_t | CARD_STATUS_CSD_OVERWRITE = 1UL << 16 |
| const uint32_t | CARD_STATUS_WP_ERASE_SKIP = 1UL << 15 |
| const uint32_t | CARD_STATUS_CARD_ECC_DISABLED = 1UL << 14 |
| const uint32_t | CARD_STATUS_ERASE_RESET = 1UL << 13 |
| const uint32_t | CARD_STATUS_CURRENT_STATE = 0XF << 9 |
| const uint32_t | CARD_STATUS_CURRENT_STATE_SHIFT = 9 |
| const uint32_t | CARD_STATUS_READY_FOR_DATA = 1UL << 8 |
| const uint32_t | CARD_STATUS_FX_EVENT = 1UL << 6 |
| const uint32_t | CARD_STATUS_APP_CMD = 1UL << 5 |
| const uint32_t | CARD_STATUS_AKE_SEQ_ERROR = 1UL << 3 |
| const uint8_t | R1_READY_STATE = 0X00 |
| const uint8_t | R1_IDLE_STATE = 0X01 |
| const uint8_t | R1_ILLEGAL_COMMAND = 0X04 |
| const uint8_t | DATA_START_SECTOR = 0XFE |
| const uint8_t | STOP_TRAN_TOKEN = 0XFD |
| const uint8_t | WRITE_MULTIPLE_TOKEN = 0XFC |
| const uint8_t | DATA_RES_MASK = 0X1F |
| const uint8_t | DATA_RES_ACCEPTED = 0X05 |
| unsigned char | mid |
| char | oid [2] |
| char | pnm [5] |
| unsigned char | prv_m |
| unsigned char | prv_n |
| uint32_t | psn |
| unsigned char | mdt_year_high |
| unsigned char | reserved |
| unsigned char | mdt_month |
| unsigned char | mdt_year_low |
| unsigned char | always1 |
| unsigned char | crc |
| unsigned char | reserved1 |
| unsigned char | csd_ver |
| unsigned char | taac |
| unsigned char | nsac |
| unsigned char | tran_speed |
| unsigned char | ccc_high |
| unsigned char | read_bl_len |
| unsigned char | ccc_low |
| unsigned char | c_size_high |
| unsigned char | reserved2 |
| unsigned char | dsr_imp |
| unsigned char | read_blk_misalign |
| unsigned char | write_blk_misalign |
| unsigned char | read_bl_partial |
| unsigned char | c_size_mid |
| unsigned char | vdd_r_curr_max |
| unsigned char | vdd_r_curr_min |
| unsigned char | c_size_low |
| unsigned char | c_size_mult_high |
| unsigned char | vdd_w_cur_max |
| unsigned char | vdd_w_curr_min |
| unsigned char | sector_size_high |
| unsigned char | erase_blk_en |
| unsigned char | c_size_mult_low |
| unsigned char | wp_grp_size |
| unsigned char | sector_size_low |
| unsigned char | write_bl_len_high |
| unsigned char | r2w_factor |
| unsigned char | reserved3 |
| unsigned char | wp_grp_enable |
| unsigned char | reserved4 |
| unsigned char | write_partial |
| unsigned char | write_bl_len_low |
| unsigned char | reserved5 |
| unsigned char | file_format |
| unsigned char | tmp_write_protect |
| unsigned char | perm_write_protect |
| unsigned char | copy |
| unsigned char | file_format_grp |
| unsigned char | reserved6 |
| unsigned char | reserved7 |
| union csd_t | __attribute__ |
| typedef struct SdStatus SdStatus_t |
| struct CID __attribute__ | ( | (packed) | ) |
| void printSdErrorSymbol | ( | print_t * | pr, |
| uint8_t | code ) |
| void printSdErrorText | ( | print_t * | pr, |
| uint8_t | code ) |
|
inline |
| const uint8_t ACMD13 = 0X0D |
SD_STATUS - Send the SD Status.
| const uint8_t ACMD23 = 0X17 |
SET_WR_BLK_ERASE_COUNT - Set the number of write sectors to be pre-erased before writing
| const uint8_t ACMD41 = 0X29 |
SD_SEND_OP_COMD - Sends host capacity support information and activates the card's initialization process
| const uint8_t ACMD6 = 0X06 |
SET_BUS_WIDTH - Defines the data bus width for data transfer.
| unsigned char always1 |
not used always 1
| unsigned char c_size_high |
high part of card size
| unsigned char c_size_low |
low part of card size
| unsigned char c_size_mid |
middle part of card size
| unsigned char c_size_mult_high |
| unsigned char c_size_mult_low |
| const uint32_t CARD_STATUS_ADDRESS_ERROR = 1UL << 30 |
A misaligned address which did not match the sector length.
| const uint32_t CARD_STATUS_AKE_SEQ_ERROR = 1UL << 3 |
Error in the sequence of the authentication process.
| const uint32_t CARD_STATUS_APP_CMD = 1UL << 5 |
The card will expect ACMD, or the command has been interpreted as ACMD
| const uint32_t CARD_STATUS_CARD_ECC_DISABLED = 1UL << 14 |
The command has been executed without using the internal ECC.
| const uint32_t CARD_STATUS_CARD_ECC_FAILED = 1UL << 21 |
Card internal ECC was applied but failed to correct the data.
| const uint32_t CARD_STATUS_CARD_IS_LOCKED = 1UL << 25 |
When set, signals that the card is locked by the host.
| const uint32_t CARD_STATUS_CC_ERROR = 1UL << 20 |
Internal card controller error
| const uint32_t CARD_STATUS_COM_CRC_ERROR = 1UL << 23 |
The CRC check of the previous command failed.
| const uint32_t CARD_STATUS_CSD_OVERWRITE = 1UL << 16 |
Permanent WP set or attempt to change read only values of CSD.
| const uint32_t CARD_STATUS_CURRENT_STATE = 0XF << 9 |
The state of the card when receiving the command. 0 = idle 1 = ready 2 = ident 3 = stby 4 = tran 5 = data 6 = rcv 7 = prg 8 = dis 9-14 = reserved 15 = reserved for I/O mode
| const uint32_t CARD_STATUS_CURRENT_STATE_SHIFT = 9 |
Shift for current state.
| const uint32_t CARD_STATUS_ERASE_PARAM = 1UL << 27 |
An invalid selection of write-sectors for erase occurred.
| const uint32_t CARD_STATUS_ERASE_RESET = 1UL << 13 |
out of erase sequence command was received.
| const uint32_t CARD_STATUS_ERASE_SEQ_ERROR = 1UL << 28 |
An error in the sequence of erase commands occurred.
| const uint32_t CARD_STATUS_ERROR = 1UL << 19 |
A general or an unknown error occurred during the operation.
| const uint32_t CARD_STATUS_FX_EVENT = 1UL << 6 |
Extension Functions may set this bit to get host to deal with events.
| const uint32_t CARD_STATUS_ILLEGAL_COMMAND = 1UL << 22 |
Command not legal for the card state.
| const uint32_t CARD_STATUS_LOCK_UNLOCK_FAILED = 1UL << 24 |
Set when a sequence or password error has been detected.
| const uint32_t CARD_STATUS_OUT_OF_RANGE = 1UL << 31 |
The command's argument was out of the allowed range for this card.
| const uint32_t CARD_STATUS_READY_FOR_DATA = 1UL << 8 |
Corresponds to buffer empty signaling on the bus.
| const uint32_t CARD_STATUS_SECTOR_LEN_ERROR = 1UL << 29 |
The transferred sector length is not allowed for this card.
| const uint32_t CARD_STATUS_WP_ERASE_SKIP = 1UL << 15 |
partial address space was erased due to write protect.
| const uint32_t CARD_STATUS_WP_VIOLATION = 1UL << 26 |
Set when the host attempts to write to a protected sector.
| unsigned char ccc_high |
| unsigned char ccc_low |
| const uint8_t CMD0 = 0X00 |
GO_IDLE_STATE - init card in spi mode if CS low
| const uint8_t CMD10 = 0X0A |
SEND_CID - read the card identification information (CID register)
| const uint8_t CMD11 = 0X0B |
VOLTAGE_SWITCH -Switch to 1.8V bus signaling level.
| const uint8_t CMD12 = 0X0C |
STOP_TRANSMISSION - end multiple sector read sequence
| const uint8_t CMD13 = 0X0D |
SEND_STATUS - read the card status register
| const uint8_t CMD17 = 0X11 |
READ_SINGLE_SECTOR - read a single data sector from the card
| const uint8_t CMD18 = 0X12 |
READ_MULTIPLE_SECTOR - read multiple data sectors from the card
| const uint8_t CMD2 = 0X02 |
ALL_SEND_CID - Asks any card to send the CID.
| const uint8_t CMD24 = 0X18 |
WRITE_SECTOR - write a single data sector to the card
| const uint8_t CMD25 = 0X19 |
WRITE_MULTIPLE_SECTOR - write sectors of data until a STOP_TRANSMISSION
| const uint8_t CMD3 = 0X03 |
SEND_RELATIVE_ADDR - Ask the card to publish a new RCA.
| const uint8_t CMD32 = 0X20 |
ERASE_WR_BLK_START - sets the address of the first sector to be erased
| const uint8_t CMD33 = 0X21 |
ERASE_WR_BLK_END - sets the address of the last sector of the continuous range to be erased
| const uint8_t CMD38 = 0X26 |
ERASE - erase all previously selected sectors
| const uint8_t CMD55 = 0X37 |
APP_CMD - escape for application specific command
| const uint8_t CMD58 = 0X3A |
READ_OCR - read the OCR register of a card
| const uint8_t CMD59 = 0X3B |
CRC_ON_OFF - enable or disable CRC checking
| const uint8_t CMD6 = 0X06 |
SWITCH_FUNC - Switch Function Command
| const uint8_t CMD7 = 0X07 |
SELECT/DESELECT_CARD - toggles between the stand-by and transfer states.
| const uint8_t CMD8 = 0X08 |
SEND_IF_COND - verify SD Memory Card interface operating condition.
| const uint8_t CMD9 = 0X09 |
SEND_CSD - read the Card Specific Data (CSD register)
| unsigned char copy |
| unsigned char crc |
CRC7 checksum
checksum
| unsigned char csd_ver |
| const uint8_t DATA_RES_ACCEPTED = 0X05 |
write data accepted token
| const uint8_t DATA_RES_MASK = 0X1F |
mask for data response tokens after a write sector operation
| const uint8_t DATA_START_SECTOR = 0XFE |
start data token for read or write single sector
| unsigned char dsr_imp |
| unsigned char erase_blk_en |
fixed to 1 - erase single is supported
| unsigned char file_format |
Do not use always 0
| unsigned char file_format_grp |
Indicates the file format on the card
Do not use always 0
| unsigned char mdt_month |
Manufacturing date month
| unsigned char mdt_year_high |
Manufacturing date year high digit
| unsigned char mdt_year_low |
Manufacturing date year low digit
| unsigned char mid |
Manufacturer ID
| unsigned char nsac |
fixed to 0
| char oid[2] |
OEM/Application ID
| unsigned char perm_write_protect |
| char pnm[5] |
Product name
| unsigned char prv_m |
Product revision least significant digit
| unsigned char prv_n |
Product revision most significant digit
| uint32_t psn |
Product serial number
| const uint8_t R1_IDLE_STATE = 0X01 |
status for card in the idle state
| const uint8_t R1_ILLEGAL_COMMAND = 0X04 |
status bit for illegal command
| const uint8_t R1_READY_STATE = 0X00 |
status for card in the ready state
| unsigned char r2w_factor |
fixed value of 2
| unsigned char read_bl_len |
This field is fixed to 9h, which indicates READ_BL_LEN=512 Byte
| unsigned char read_bl_partial |
fixed to 0 - no partial read
| unsigned char read_blk_misalign |
fixed to 0
| unsigned char reserved |
not used
| unsigned char reserved1 |
| unsigned char reserved2 |
not used
| unsigned char reserved3 |
not used
| unsigned char reserved4 |
not used
| unsigned char reserved5 |
not used
| unsigned char reserved6 |
| unsigned char reserved7 |
| const uint8_t SD_CARD_TYPE_SD1 = 1 |
Standard capacity V1 SD card
| const uint8_t SD_CARD_TYPE_SD2 = 2 |
Standard capacity V2 SD card
| const uint8_t SD_CARD_TYPE_SDHC = 3 |
High Capacity SD card
| const uint8_t SD_CMD0_RETRY = 10 |
CMD0 retry count
| const uint16_t SD_CMD_TIMEOUT = 300 |
command timeout ms
| const uint16_t SD_ERASE_TIMEOUT = 10000 |
erase timeout ms
| const uint16_t SD_INIT_TIMEOUT = 2000 |
init timeout ms
| const uint16_t SD_READ_TIMEOUT = 300 |
read timeout ms
| const uint16_t SD_WRITE_TIMEOUT = 600 |
write time out ms
| unsigned char sector_size_high |
sector size is fixed at 64 KB
| unsigned char sector_size_low |
sector size is fixed at 64 KB
| const uint8_t STOP_TRAN_TOKEN = 0XFD |
stop token for write multiple sectors
| unsigned char taac |
fixed to 0X0E
| unsigned char tmp_write_protect |
| unsigned char tran_speed |
| unsigned char vdd_r_curr_max |
| unsigned char vdd_r_curr_min |
| unsigned char vdd_w_cur_max |
| unsigned char vdd_w_curr_min |
| unsigned char wp_grp_enable |
fixed value of 0 - no write protect groups
| unsigned char wp_grp_size |
| unsigned char write_bl_len_high |
write_bl_len fixed for 512 byte sectors
| unsigned char write_bl_len_low |
write_bl_len fixed for 512 byte sectors
| unsigned char write_blk_misalign |
fixed to 0
| const uint8_t WRITE_MULTIPLE_TOKEN = 0XFC |
start data token for write multiple sectors
| unsigned char write_partial |
always zero - no partial sector read