diff options
author | Camil Staps | 2017-01-31 23:15:28 +0100 |
---|---|---|
committer | Camil Staps | 2017-01-31 23:15:28 +0100 |
commit | 631204a1feffa8cf3795060370b14dfb9f53f533 (patch) | |
tree | 001d32e0157127607f7c088881f098c2eca841a1 /sd.h |
Diffstat (limited to 'sd.h')
-rw-r--r-- | sd.h | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +#include <stdint.h> + +#include "sd_config.h" + +#define SD_GO_IDLE_STATE 0 +#define SD_SEND_OP_COND 1 +#define SD_OP_COND_SDC 0xe9 +#define SD_SEND_IF_COND 8 +#define SD_SEND_CSD 9 +#define SD_SEND_CID 10 +#define SD_STOP_TRANSMISSION 12 +#define SD_SEND_STATUS 13 + +#define SD_SET_BLOCKLEN 16 +#define SD_READ_SINGLE_BLOCK 17 +#define SD_READ_MULTIPLE_BLOCK 18 + +#define SD_WRITE_BLOCK 24 +#define SD_WRITE_MULTIPLE_BLOCK 25 +#define SD_PROGRAM_CSD 27 + +#define SD_SET_WRITE_PROT 28 +#define SD_CLR_WRITE_PROT 29 +#define SD_SEND_WRITE_PROT 30 + +#define SD_ERASE_WR_BLK_START 32 +#define SD_ERASE_WR_BLK_END 33 +#define SD_ERASE 38 + +#define SD_APP_CMD 55 +#define SD_GEN_CMD 56 + +#define SD_READ_OCR 58 +#define SD_CRC_ON_OFF 59 + +#define SD_SD_STATUS 13 +#define SD_SEND_NUM_WR_BLOCKS 22 +#define SD_SET_WR_BLK_ERASE_COUNT 23 +#define SD_SD_APP_OP_COND 41 +#define SD_SET_CLR_CARD_DETECT 42 +#define SD_SEND_SCR 51 + +#define SD_IN_IDLE_STATE 0x01 +#define SD_ERASE_RESET 0x02 +#define SD_ILLEGAL_COMMAND 0x04 +#define SD_CRC_ERROR 0x08 +#define SD_ERASE_ERROR 0x10 +#define SD_ADDRESS_ERROR 0x20 +#define SD_PARAM_ERROR 0x40 + +#define SD_SELECT() (SD_CHIP_SELECT = 0) +#define SD_DESELECT() (SD_CHIP_SELECT = 1) + +uint8_t sd_send_command(uint8_t cmd, uint32_t data); +void sd_wait(void); +char sd_init(void); |