#define MMCMD_HOST 0x40
#define MMCMD_RESET_CRC 0x95
#define MMCMD_GO_IDLE_STATE 0
#define MMCMD_SEND_OP_COND 1
#define MMCMD_ALL_SEND_CID 2
#define MMCMD_SEND_RELATIVE_ADDR 3
#define MMCMD_SELECT_CARD 7
#define MMCMD_SEND_CSD 9
#define MMCMD_SEND_CID 10
#define MMCMD_STOP_TRANSMISSION 12
#define MMCMD_SEND_STATUS 13
#define MMCMD_SET_BLOCKLEN 16
#define MMCMD_READ_SINGLE_BLOCK 17
#define MMCMD_READ_MULTIPLE_BLOCK 18
#define MMCMD_WRITE_BLOCK 24
#define MMCMD_WRITE_MULTIPLE_BLOCK 25
#define MMCMD_PROGRAM_CSD 27
#define MMCMD_SET_WRITE_PROTECT 28
#define MMCMD_CLR_WRITE_PROTECT 29
#define MMCMD_SEND_WRITE_PROTECT 30
#define MMCMD_TAG_ERASE_GROUP_START 35
#define MMCMD_TAG_ERASE_GROUP_END 36
#define MMCMD_ERASE 38
#define MMCMD_SEND_APP_OP_COND 41
#define MMCMD_LOCK_UNLOCK 42
#define MMCMD_SEND_APP_CMD 55
#define MMCMD_READ_OCR 58
#define MMCMD_CRC_ON_OFF 59
#define MMR1_IDLE_STATE 0x00
#define MMR1_NOT_IDLE 0x01
#define MMR1_ERASE_RESET 0x02
#define MMR1_ILLEGAL_COMMAND 0x04
#define MMR1_COM_CRC_ERROR 0x08
#define MMR1_ERASE_SEQ_ERROR 0x10
#define MMR1_ADDRESS_ERROR 0x20
#define MMR1_PARAMETER_ERROR 0x40
#define MMR2_CARD_LOCKED 0x01
#define MMR2_WP_ERASE_SKIP 0x02
#define MMR2_ERROR 0x04
#define MMR2_CC_ERROR 0x08
#define MMR2_ECC_FAILED 0x10
#define MMR2_WP_VIOLATION 0x20
#define MMR2_ERASE_PARAMETER 0x40
#define MMR2_OUT_OF_RANGE 0x80
#define MMCSR_OUT_OF_RANGE 0x80000000
#define MMCSR_ADDRESS_ERROR 0x40000000
#define MMCSR_BLOCK_LEN_ERROR 0x20000000
#define MMCSR_ERASE_SEQ_ERROR 0x10000000
#define MMCSR_ERASE_PARAM 0x08000000
#define MMCSR_WP_VIOLATION 0x04000000
#define MMCSR_COM_CRC_ERROR 0x00800000
#define MMCSR_ILLEGAL_COMMAND 0x00400000
#define MMCSR_ERROR 0x00080000
#define MMCSR_CIDCSD_OVERWRITE 0x00010000
#define MMCSR_WP_ERASE_SKIP 0x00008000
#define MMCSR_CARD_ECC_DISABLED 0x00004000
#define MMCSR_ERASE_RESET 0x00002000
#define MMCSR_STATE_MASK 0x00001E00
#define MMCSR_READY_FOR_DATA 0x00000100
#define MMCSR_IS_IDLE 0x00000000
#define MMCSR_IS_READY 0x00000200
#define MMCSR_IS_IDENT 0x00000400
#define MMCSR_IS_STBY 0x00000600
#define MMCSR_IS_TRAN 0x00000800
#define MMCSR_IS_DATA 0x00000A00
#define MMCSR_IS_RCV 0x00000C00
#define MMCSR_IS_PRG 0x00000E00
#define MMCSR_IS_DIS 0x00001000
#define MMDR_ACCEPTED
#define MMDR_CRC_ERROR
#define MMDR_WRITE_ERROR
#define MMCERR_TIMEOUT 0x00000001
#define MMCOP_NBUSY 0x80000000
#define MMCARD_CIDR_SIZE 16
#define MMCARD_CSDR_SIZE 16
#define MMCARD_OCR_SIZE 32
#define MMCARD_165_195V 0x00000080
#define MMCARD_20_21V 0x00000100
#define MMCARD_21_22V 0x00000200
#define MMCARD_22_23V 0x00000400
#define MMCARD_23_24V 0x00000800
#define MMCARD_24_25V 0x00001000
#define MMCARD_25_26V 0x00002000
#define MMCARD_26_27V 0x00004000
#define MMCARD_27_28V 0x00008000
#define MMCARD_28_29V 0x00010000
#define MMCARD_29_30V 0x00020000
#define MMCARD_30_31V 0x00040000
#define MMCARD_31_32V 0x00080000
#define MMCARD_32_33V 0x00100000
#define MMCARD_33_34V 0x00200000
#define MMCARD_34_35V 0x00400000
#define MMCARD_35_36V 0x00800000
#define MMCARD_GETSTATUS 0x2001
#define MMCARD_GETOCR 0x2002
#define MMCARD_GETCID 0x2003
#define MMCARD_GETCSD 0x2004
struct _MMCIFC | |
{ | |
int (*mmcifc_in)(void); | |
uint8_t (*mmcifc_io)(uint8_t); | |
int (*mmcifc_cs)(int); | |
int (*mmcifc_cd)(void); | |
int (*mmcifc_wp)(void); | |
} |
struct _MMC_CID | |
{ | |
uint8_t mmcid_mid; | |
uint16_t mmcid_oid; | |
uint8_t mmcid_pnm[6]; | |
uint8_t mmcid_rev; | |
uint32_t mmcid_psn; | |
uint8_t mmcid_mdt; | |
uint8_t mmcid_crc; | |
} |
struct _MMC_CSD | |
{ | |
uint8_t mmcsd_spec; | |
uint8_t mmcsd_taac; | |
uint8_t mmcsd_nsac; | |
uint8_t mmcsd_speed; | |
uint8_t mmcsd_ccc_bl[2]; | |
uint8_t mmcsd_rfld[8]; | |
uint8_t mmcsd_pfld; | |
uint8_t mmcsd_crc; | |
} |