123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- #include "Marlin.h"
- #ifdef SDSUPPORT
- #ifndef SdInfo_h
- #define SdInfo_h
- #include <stdint.h>
- uint8_t const CMD0 = 0X00;
- uint8_t const CMD8 = 0X08;
- uint8_t const CMD9 = 0X09;
- uint8_t const CMD10 = 0X0A;
- uint8_t const CMD12 = 0X0C;
- uint8_t const CMD13 = 0X0D;
- uint8_t const CMD17 = 0X11;
- uint8_t const CMD18 = 0X12;
- uint8_t const CMD24 = 0X18;
- uint8_t const CMD25 = 0X19;
- uint8_t const CMD32 = 0X20;
- uint8_t const CMD33 = 0X21;
- uint8_t const CMD38 = 0X26;
- uint8_t const CMD48 = 0x30;
- uint8_t const CMD49 = 0x31;
- uint8_t const CMD55 = 0X37;
- uint8_t const CMD58 = 0X3A;
- uint8_t const ACMD23 = 0X17;
- uint8_t const ACMD41 = 0X29;
- uint8_t const R1_READY_STATE = 0X00;
- uint8_t const R1_IDLE_STATE = 0X01;
- uint8_t const R1_ILLEGAL_COMMAND = 0X04;
- uint8_t const DATA_START_BLOCK = 0XFE;
- uint8_t const STOP_TRAN_TOKEN = 0XFD;
- uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC;
- uint8_t const DATA_RES_MASK = 0X1F;
- uint8_t const DATA_RES_ACCEPTED = 0X05;
- typedef struct CID {
-
-
- unsigned char mid;
-
-
- char oid[2];
-
-
- char pnm[5];
-
-
- unsigned char prv_m : 4;
-
- unsigned char prv_n : 4;
-
-
- uint32_t psn;
-
-
- unsigned char mdt_year_high : 4;
-
- unsigned char reserved : 4;
-
-
- unsigned char mdt_month : 4;
-
- unsigned char mdt_year_low :4;
-
-
- unsigned char always1 : 1;
-
- unsigned char crc : 7;
- }cid_t;
- typedef struct CSDV1 {
-
- unsigned char reserved1 : 6;
- unsigned char csd_ver : 2;
-
- unsigned char taac;
-
- unsigned char nsac;
-
- unsigned char tran_speed;
-
- unsigned char ccc_high;
-
- unsigned char read_bl_len : 4;
- unsigned char ccc_low : 4;
-
- unsigned char c_size_high : 2;
- unsigned char reserved2 : 2;
- unsigned char dsr_imp : 1;
- unsigned char read_blk_misalign :1;
- unsigned char write_blk_misalign : 1;
- unsigned char read_bl_partial : 1;
-
- unsigned char c_size_mid;
-
- unsigned char vdd_r_curr_max : 3;
- unsigned char vdd_r_curr_min : 3;
- unsigned char c_size_low :2;
-
- unsigned char c_size_mult_high : 2;
- unsigned char vdd_w_cur_max : 3;
- unsigned char vdd_w_curr_min : 3;
-
- unsigned char sector_size_high : 6;
- unsigned char erase_blk_en : 1;
- unsigned char c_size_mult_low : 1;
-
- unsigned char wp_grp_size : 7;
- unsigned char sector_size_low : 1;
-
- unsigned char write_bl_len_high : 2;
- unsigned char r2w_factor : 3;
- unsigned char reserved3 : 2;
- unsigned char wp_grp_enable : 1;
-
- unsigned char reserved4 : 5;
- unsigned char write_partial : 1;
- unsigned char write_bl_len_low : 2;
-
- unsigned char reserved5: 2;
- unsigned char file_format : 2;
- unsigned char tmp_write_protect : 1;
- unsigned char perm_write_protect : 1;
- unsigned char copy : 1;
-
- unsigned char file_format_grp : 1;
-
- unsigned char always1 : 1;
- unsigned char crc : 7;
- }csd1_t;
- typedef struct CSDV2 {
-
- unsigned char reserved1 : 6;
- unsigned char csd_ver : 2;
-
-
- unsigned char taac;
-
-
- unsigned char nsac;
-
- unsigned char tran_speed;
-
- unsigned char ccc_high;
-
-
- unsigned char read_bl_len : 4;
- unsigned char ccc_low : 4;
-
-
- unsigned char reserved2 : 4;
- unsigned char dsr_imp : 1;
-
- unsigned char read_blk_misalign :1;
-
- unsigned char write_blk_misalign : 1;
-
- unsigned char read_bl_partial : 1;
-
-
- unsigned char reserved3 : 2;
-
- unsigned char c_size_high : 6;
-
-
- unsigned char c_size_mid;
-
-
- unsigned char c_size_low;
-
-
- unsigned char sector_size_high : 6;
-
- unsigned char erase_blk_en : 1;
-
- unsigned char reserved4 : 1;
-
- unsigned char wp_grp_size : 7;
-
- unsigned char sector_size_low : 1;
-
-
- unsigned char write_bl_len_high : 2;
-
- unsigned char r2w_factor : 3;
-
- unsigned char reserved5 : 2;
-
- unsigned char wp_grp_enable : 1;
-
- unsigned char reserved6 : 5;
-
- unsigned char write_partial : 1;
-
- unsigned char write_bl_len_low : 2;
-
- unsigned char reserved7: 2;
-
- unsigned char file_format : 2;
- unsigned char tmp_write_protect : 1;
- unsigned char perm_write_protect : 1;
- unsigned char copy : 1;
-
- unsigned char file_format_grp : 1;
-
-
- unsigned char always1 : 1;
-
- unsigned char crc : 7;
- }csd2_t;
- union csd_t {
- csd1_t v1;
- csd2_t v2;
- };
- #endif
- #endif
|