00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SdInfo_h
00021 #define SdInfo_h
00022 #include <stdint.h>
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00036 uint8_t const CMD0 = 0X00;
00038 uint8_t const CMD8 = 0X08;
00040 uint8_t const CMD9 = 0X09;
00042 uint8_t const CMD10 = 0X0A;
00044 uint8_t const CMD13 = 0X0D;
00046 uint8_t const CMD17 = 0X11;
00048 uint8_t const CMD24 = 0X18;
00050 uint8_t const CMD25 = 0X19;
00052 uint8_t const CMD32 = 0X20;
00055 uint8_t const CMD33 = 0X21;
00057 uint8_t const CMD38 = 0X26;
00059 uint8_t const CMD55 = 0X37;
00061 uint8_t const CMD58 = 0X3A;
00064 uint8_t const ACMD23 = 0X17;
00067 uint8_t const ACMD41 = 0X29;
00068
00070 uint8_t const R1_READY_STATE = 0X00;
00072 uint8_t const R1_IDLE_STATE = 0X01;
00074 uint8_t const R1_ILLEGAL_COMMAND = 0X04;
00076 uint8_t const DATA_START_BLOCK = 0XFE;
00078 uint8_t const STOP_TRAN_TOKEN = 0XFD;
00080 uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC;
00082 uint8_t const DATA_RES_MASK = 0X1F;
00084 uint8_t const DATA_RES_ACCEPTED = 0X05;
00085
00086 typedef struct CID {
00087
00088 uint8_t mid;
00089
00090 char oid[2];
00091
00092 char pnm[5];
00093
00094 unsigned prv_m : 4;
00095 unsigned prv_n : 4;
00096
00097 uint32_t psn;
00098
00099 unsigned mdt_year_high : 4;
00100 unsigned reserved : 4;
00101
00102 unsigned mdt_month : 4;
00103 unsigned mdt_year_low :4;
00104
00105 unsigned always1 : 1;
00106 unsigned crc : 7;
00107 }cid_t;
00108
00109
00110 typedef struct CSDV1 {
00111
00112 unsigned reserved1 : 6;
00113 unsigned csd_ver : 2;
00114
00115 uint8_t taac;
00116
00117 uint8_t nsac;
00118
00119 uint8_t tran_speed;
00120
00121 uint8_t ccc_high;
00122
00123 unsigned read_bl_len : 4;
00124 unsigned ccc_low : 4;
00125
00126 unsigned c_size_high : 2;
00127 unsigned reserved2 : 2;
00128 unsigned dsr_imp : 1;
00129 unsigned read_blk_misalign :1;
00130 unsigned write_blk_misalign : 1;
00131 unsigned read_bl_partial : 1;
00132
00133 uint8_t c_size_mid;
00134
00135 unsigned vdd_r_curr_max : 3;
00136 unsigned vdd_r_curr_min : 3;
00137 unsigned c_size_low :2;
00138
00139 unsigned c_size_mult_high : 2;
00140 unsigned vdd_w_cur_max : 3;
00141 unsigned vdd_w_curr_min : 3;
00142
00143 unsigned sector_size_high : 6;
00144 unsigned erase_blk_en : 1;
00145 unsigned c_size_mult_low : 1;
00146
00147 unsigned wp_grp_size : 7;
00148 unsigned sector_size_low : 1;
00149
00150 unsigned write_bl_len_high : 2;
00151 unsigned r2w_factor : 3;
00152 unsigned reserved3 : 2;
00153 unsigned wp_grp_enable : 1;
00154
00155 unsigned reserved4 : 5;
00156 unsigned write_partial : 1;
00157 unsigned write_bl_len_low : 2;
00158
00159 unsigned reserved5: 2;
00160 unsigned file_format : 2;
00161 unsigned tmp_write_protect : 1;
00162 unsigned perm_write_protect : 1;
00163 unsigned copy : 1;
00164 unsigned file_format_grp : 1;
00165
00166 unsigned always1 : 1;
00167 unsigned crc : 7;
00168 }csd1_t;
00169
00170
00171 typedef struct CSDV2 {
00172
00173 unsigned reserved1 : 6;
00174 unsigned csd_ver : 2;
00175
00176 uint8_t taac;
00177
00178 uint8_t nsac;
00179
00180 uint8_t tran_speed;
00181
00182 uint8_t ccc_high;
00183
00184 unsigned read_bl_len : 4;
00185 unsigned ccc_low : 4;
00186
00187 unsigned reserved2 : 4;
00188 unsigned dsr_imp : 1;
00189 unsigned read_blk_misalign :1;
00190 unsigned write_blk_misalign : 1;
00191 unsigned read_bl_partial : 1;
00192
00193 unsigned reserved3 : 2;
00194 unsigned c_size_high : 6;
00195
00196 uint8_t c_size_mid;
00197
00198 uint8_t c_size_low;
00199
00200 unsigned sector_size_high : 6;
00201 unsigned erase_blk_en : 1;
00202 unsigned reserved4 : 1;
00203
00204 unsigned wp_grp_size : 7;
00205 unsigned sector_size_low : 1;
00206
00207 unsigned write_bl_len_high : 2;
00208 unsigned r2w_factor : 3;
00209 unsigned reserved5 : 2;
00210 unsigned wp_grp_enable : 1;
00211
00212 unsigned reserved6 : 5;
00213 unsigned write_partial : 1;
00214 unsigned write_bl_len_low : 2;
00215
00216 unsigned reserved7: 2;
00217 unsigned file_format : 2;
00218 unsigned tmp_write_protect : 1;
00219 unsigned perm_write_protect : 1;
00220 unsigned copy : 1;
00221 unsigned file_format_grp : 1;
00222
00223 unsigned always1 : 1;
00224 unsigned crc : 7;
00225 }csd2_t;
00226
00227
00228 union csd_t {
00229 csd1_t v1;
00230 csd2_t v2;
00231 };
00232 #endif // SdInfo_h