RTEMS 6.1-rc2
|
SD Card LibI2C driver. More...
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <rtems.h>
#include <rtems/libi2c.h>
#include <rtems/libio.h>
#include <rtems/blkdev.h>
#include <libchip/spi-sd-card.h>
#include <rtems/status-checks.h>
Macros | |
#define | SD_CARD_BUSY_TOKEN 0 |
#define | SD_CARD_BLOCK_SIZE_DEFAULT 512 |
#define | SD_CARD_COMMAND_RESPONSE_START 7 |
#define | SD_CARD_INVALIDATE_RESPONSE_INDEX(e) e->response_index = SD_CARD_COMMAND_SIZE |
Commands | |
#define | SD_CARD_CMD_GO_IDLE_STATE 0 |
#define | SD_CARD_CMD_SEND_OP_COND 1 |
#define | SD_CARD_CMD_SEND_IF_COND 8 |
#define | SD_CARD_CMD_SEND_CSD 9 |
#define | SD_CARD_CMD_SEND_CID 10 |
#define | SD_CARD_CMD_STOP_TRANSMISSION 12 |
#define | SD_CARD_CMD_SEND_STATUS 13 |
#define | SD_CARD_CMD_SET_BLOCKLEN 16 |
#define | SD_CARD_CMD_READ_SINGLE_BLOCK 17 |
#define | SD_CARD_CMD_READ_MULTIPLE_BLOCK 18 |
#define | SD_CARD_CMD_SET_BLOCK_COUNT 23 |
#define | SD_CARD_CMD_WRITE_BLOCK 24 |
#define | SD_CARD_CMD_WRITE_MULTIPLE_BLOCK 25 |
#define | SD_CARD_CMD_PROGRAM_CSD 27 |
#define | SD_CARD_CMD_SET_WRITE_PROT 28 |
#define | SD_CARD_CMD_CLR_WRITE_PROT 29 |
#define | SD_CARD_CMD_SEND_WRITE_PROT 30 |
#define | SD_CARD_CMD_TAG_SECTOR_START 32 |
#define | SD_CARD_CMD_TAG_SECTOR_END 33 |
#define | SD_CARD_CMD_UNTAG_SECTOR 34 |
#define | SD_CARD_CMD_TAG_ERASE_GROUP_START 35 |
#define | SD_CARD_CMD_TAG_ERASE_GROUP_END 36 |
#define | SD_CARD_CMD_UNTAG_ERASE_GROUP 37 |
#define | SD_CARD_CMD_ERASE 38 |
#define | SD_CARD_CMD_LOCK_UNLOCK 42 |
#define | SD_CARD_CMD_APP_CMD 55 |
#define | SD_CARD_CMD_GEN_CND 56 |
#define | SD_CARD_CMD_READ_OCR 58 |
#define | SD_CARD_CMD_CRC_ON_OFF 59 |
Application Commands | |
#define | SD_CARD_ACMD_SD_SEND_OP_COND 41 |
Command Flags | |
#define | SD_CARD_FLAG_HCS 0x40000000U |
#define | SD_CARD_FLAG_VHS_2_7_TO_3_3 0x00000100U |
#define | SD_CARD_FLAG_CHECK_PATTERN 0x000000aaU |
Command Fields | |
#define | SD_CARD_COMMAND_SET_COMMAND(c, cmd) (c) [1] = (uint8_t) (0x40 + ((cmd) & 0x3f)) |
#define | SD_CARD_COMMAND_SET_ARGUMENT(c, arg) sd_card_put_uint32( (arg), &((c) [2])) |
#define | SD_CARD_COMMAND_SET_CRC7(c, crc7) ((c) [6] = ((crc7) << 1) | 1U) |
#define | SD_CARD_COMMAND_GET_CRC7(c) ((c) [6] >> 1) |
Response Fields | |
#define | SD_CARD_IS_RESPONSE(r) (((r) & 0x80) == 0) |
#define | SD_CARD_IS_ERRORLESS_RESPONSE(r) (((r) & 0x7e) == 0) |
#define | SD_CARD_IS_NOT_IDLE_RESPONSE(r) (((r) & 0x81) == 0) |
#define | SD_CARD_IS_DATA_ERROR(r) (((r) & 0xe0) == 0) |
#define | SD_CARD_IS_DATA_REJECTED(r) (((r) & 0x1f) != 0x05) |
Card Identification | |
#define | SD_CARD_CID_SIZE 16 |
#define | SD_CARD_CID_GET_MID(cid) ((cid) [0]) |
#define | SD_CARD_CID_GET_OID(cid) sd_card_get_uint16( cid + 1) |
#define | SD_CARD_CID_GET_PNM(cid, i) ((char) (cid) [3 + (i)]) |
#define | SD_CARD_CID_GET_PRV(cid) ((cid) [9]) |
#define | SD_CARD_CID_GET_PSN(cid) sd_card_get_uint32( cid + 10) |
#define | SD_CARD_CID_GET_MDT(cid) ((cid) [14]) |
#define | SD_CARD_CID_GET_CRC7(cid) ((cid) [15] >> 1) |
Card Specific Data | |
#define | SD_CARD_CSD_SIZE 16 |
#define | SD_CARD_CSD_GET_CSD_STRUCTURE(csd) ((csd) [0] >> 6) |
#define | SD_CARD_CSD_GET_SPEC_VERS(csd) (((csd) [0] >> 2) & 0xf) |
#define | SD_CARD_CSD_GET_TAAC(csd) ((csd) [1]) |
#define | SD_CARD_CSD_GET_NSAC(csd) ((uint32_t) (csd) [2]) |
#define | SD_CARD_CSD_GET_TRAN_SPEED(csd) ((csd) [3]) |
#define | SD_CARD_CSD_GET_C_SIZE(csd) ((((uint32_t) (csd) [6] & 0x3) << 10) + (((uint32_t) (csd) [7]) << 2) + ((((uint32_t) (csd) [8]) >> 6) & 0x3)) |
#define | SD_CARD_CSD_GET_C_SIZE_MULT(csd) ((((csd) [9] & 0x3) << 1) + (((csd) [10] >> 7) & 0x1)) |
#define | SD_CARD_CSD_GET_READ_BLK_LEN(csd) ((uint32_t) (csd) [5] & 0xf) |
#define | SD_CARD_CSD_GET_WRITE_BLK_LEN(csd) ((((uint32_t) (csd) [12] & 0x3) << 2) + ((((uint32_t) (csd) [13]) >> 6) & 0x3)) |
#define | SD_CARD_CSD_1_GET_C_SIZE(csd) ((((uint32_t) (csd) [7] & 0x3f) << 16) + (((uint32_t) (csd) [8]) << 8) + (uint32_t) (csd) [9]) |
Data Start and Stop Tokens | |
#define | SD_CARD_START_BLOCK_SINGLE_BLOCK_READ 0xfe |
#define | SD_CARD_START_BLOCK_MULTIPLE_BLOCK_READ 0xfe |
#define | SD_CARD_START_BLOCK_SINGLE_BLOCK_WRITE 0xfe |
#define | SD_CARD_START_BLOCK_MULTIPLE_BLOCK_WRITE 0xfc |
#define | SD_CARD_STOP_TRANSFER_MULTIPLE_BLOCK_WRITE 0xfd |
Functions | |
Integer to and from Byte-Stream Converter | |
Card Specific Data Functions | |
CRC functions | |
Communication Functions | |
Disk Driver Functions | |
rtems_status_code | sd_card_register (void) |
SD Card LibI2C driver.