SdFat
|
Definitions for SD cards. More...
Classes | |
class | cid_t |
Card Identification (CID) register. More... | |
class | csd_t |
Union of old and new style CSD register. More... | |
class | scr_t |
SCR register. More... | |
class | sds_t |
SD Status. More... | |
Macros | |
#define | SD_CARD_ERROR(e, m) SD_CARD_ERROR_##e, |
#define | SD_ERROR_CODE_LIST |
Functions | |
void | printSdErrorSymbol (print_t *pr, uint8_t code) |
void | printSdErrorText (print_t *pr, uint8_t code) |
Variables | |
const uint8_t | ACMD13 = 0X0D |
const uint8_t | ACMD23 = 0X17 |
const uint8_t | ACMD41 = 0X29 |
const uint8_t | ACMD51 = 0X33 |
const uint8_t | ACMD6 = 0X06 |
const uint32_t | CARD_STATUS_ADDRESS_ERROR = 1UL << 30 |
const uint32_t | CARD_STATUS_AKE_SEQ_ERROR = 1UL << 3 |
const uint32_t | CARD_STATUS_APP_CMD = 1UL << 5 |
const uint32_t | CARD_STATUS_CARD_ECC_DISABLED = 1UL << 14 |
const uint32_t | CARD_STATUS_CARD_ECC_FAILED = 1UL << 21 |
const uint32_t | CARD_STATUS_CARD_IS_LOCKED = 1UL << 25 |
const uint32_t | CARD_STATUS_CC_ERROR = 1UL << 20 |
const uint32_t | CARD_STATUS_COM_CRC_ERROR = 1UL << 23 |
const uint32_t | CARD_STATUS_CSD_OVERWRITE = 1UL << 16 |
const uint32_t | CARD_STATUS_CURRENT_STATE = 0XF << 9 |
const uint32_t | CARD_STATUS_CURRENT_STATE_SHIFT = 9 |
const uint32_t | CARD_STATUS_ERASE_PARAM = 1UL << 27 |
const uint32_t | CARD_STATUS_ERASE_RESET = 1UL << 13 |
const uint32_t | CARD_STATUS_ERASE_SEQ_ERROR = 1UL << 28 |
const uint32_t | CARD_STATUS_ERROR = 1UL << 19 |
const uint32_t | CARD_STATUS_FX_EVENT = 1UL << 6 |
const uint32_t | CARD_STATUS_ILLEGAL_COMMAND = 1UL << 22 |
const uint32_t | CARD_STATUS_LOCK_UNLOCK_FAILED = 1UL << 24 |
const uint32_t | CARD_STATUS_OUT_OF_RANGE = 1UL << 31 |
const uint32_t | CARD_STATUS_READY_FOR_DATA = 1UL << 8 |
const uint32_t | CARD_STATUS_SECTOR_LEN_ERROR = 1UL << 29 |
const uint32_t | CARD_STATUS_WP_ERASE_SKIP = 1UL << 15 |
const uint32_t | CARD_STATUS_WP_VIOLATION = 1UL << 26 |
const uint8_t | CMD0 = 0X00 |
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 | CMD2 = 0X02 |
const uint8_t | CMD24 = 0X18 |
const uint8_t | CMD25 = 0X19 |
const uint8_t | CMD3 = 0X03 |
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 | CMD6 = 0X06 |
const uint8_t | CMD7 = 0X07 |
const uint8_t | CMD8 = 0X08 |
const uint8_t | CMD9 = 0X09 |
const uint8_t | DATA_RES_ACCEPTED = 0X05 |
const uint8_t | DATA_RES_MASK = 0X1F |
const uint8_t | DATA_START_SECTOR = 0XFE |
const uint8_t | R1_IDLE_STATE = 0X01 |
const uint8_t | R1_ILLEGAL_COMMAND = 0X04 |
const uint8_t | R1_READY_STATE = 0X00 |
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 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 | STOP_TRAN_TOKEN = 0XFD |
const uint8_t | WRITE_MULTIPLE_TOKEN = 0XFC |
Definitions for SD cards.
Copyright (c) 2011-2022 Bill Greiman This file is part of the SdFat library for SD memory cards.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SD_CARD_ERROR | ( | e, | |
m | |||
) | SD_CARD_ERROR_##e, |
Macro for generation of error codes using an enum.
#define SD_ERROR_CODE_LIST |
Define error codes and brief description.
void printSdErrorSymbol | ( | print_t * | pr, |
uint8_t | code | ||
) |
Print the enum symbol for an error code.
[in] | pr | Print stream. |
[in] | code | enum value for error. |
void printSdErrorText | ( | print_t * | pr, |
uint8_t | code | ||
) |
Print text for an error code.
[in] | pr | Print stream. |
[in] | code | enum value for error. |
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 ACMD51 = 0X33 |
Reads the SD Configuration Register (SCR).
const uint8_t ACMD6 = 0X06 |
SET_BUS_WIDTH - Defines the data bus width for data transfer.
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.
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)
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
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
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 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
const uint8_t STOP_TRAN_TOKEN = 0XFD |
stop token for write multiple sectors
const uint8_t WRITE_MULTIPLE_TOKEN = 0XFC |
start data token for write multiple sectors