1 #ifndef __SD_H__ 2 #define __SD_H__ 3 4 #include <stdint.h> 5 6 /* SD/MMC Commands */ 7 #define GO_IDLE_STATE (0x40 + 0) // CMD0 8 #define SEND_OP_COND (0x40 + 1) 9 #define CMD8 (0x40 + 8) // CMD8 10 #define SEND_CSD (0x40 + 9) 11 #define SEND_CID (0x40 + 10) // CMD10 12 #define STOP_TRAN (0x40 + 12) // CMD12 13 #define SET_BLOCKLEN (0x40 + 16) // CMD16 14 #define READ_BLOCK (0x40 + 17) 15 #define READ_MULT_BLOCK (0x40 + 18) 16 #define WRITE_BLOCK (0x40 + 24) 17 #define WRITE_MULT_BLOCK (0x40 + 25) 18 #define APP_CMD (0x40 + 55) // CMD55 19 #define READ_OCR (0x40 + 58) // CMD58 20 #define CRC_ON_OFF (0x40 + 59) 21 #define SD_SEND_OP_COND (0xC0 + 41) // ACMD41 22 #define SD_STATUS (0xC0 + 13) // ACMD13, SD_STATUS (SDC) 23 #define SET_WR_BLK_ERASE_COUNT (0xC0 + 23) // ACMD23 (SDC) 24 25 /* Card type flags (CardType) */ 26 #define CT_NONE 0x00 27 #define CT_MMC 0x01 28 #define CT_SD1 0x02 29 #define CT_SD2 0x04 30 #define CT_SDC (CT_SD1|CT_SD2) 31 #define CT_BLOCK 0x08 32 33 /* MMC device configuration */ 34 typedef struct tagSDCFG 35 { 36 uint32_t sernum; // serial number 37 uint32_t size; // size=sectorsize*sectorcnt 38 uint32_t sectorcnt; // 39 uint32_t sectorsize; // 512 40 uint32_t blocksize; // erase block size 41 uint8_t ocr[4]; // OCR 42 uint8_t cid[16]; // CID 43 uint8_t csd[16]; // CSD 44 } SDCFG; 45 46 void rt_hw_sdcard_init(void); 47 48 #endif 49