![]() |
Repetier-Firmware 0.2
|
00001 /* Arduino Sd2Card Library 00002 * Copyright (C) 2009 by William Greiman 00003 * 00004 * This file is part of the Arduino Sd2Card Library 00005 * 00006 * This Library is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This Library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with the Arduino Sd2Card Library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef SdInfo_h 00021 #define SdInfo_h 00022 #include <stdint.h> 00023 // Based on the document: 00024 // 00025 // SD Specifications 00026 // Part 1 00027 // Physical Layer 00028 // Simplified Specification 00029 // Version 2.00 00030 // September 25, 2006 00031 // 00032 // www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf 00033 //------------------------------------------------------------------------------ 00034 // SD card commands 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 // byte 0 00088 uint8_t mid; // Manufacturer ID 00089 // byte 1-2 00090 char oid[2]; // OEM/Application ID 00091 // byte 3-7 00092 char pnm[5]; // Product name 00093 // byte 8 00094 unsigned prv_m : 4; // Product revision n.m 00095 unsigned prv_n : 4; 00096 // byte 9-12 00097 uint32_t psn; // Product serial number 00098 // byte 13 00099 unsigned mdt_year_high : 4; // Manufacturing date 00100 unsigned reserved : 4; 00101 // byte 14 00102 unsigned mdt_month : 4; 00103 unsigned mdt_year_low :4; 00104 // byte 15 00105 unsigned always1 : 1; 00106 unsigned crc : 7; 00107 }cid_t; 00108 //------------------------------------------------------------------------------ 00109 // CSD for version 1.00 cards 00110 typedef struct CSDV1 { 00111 // byte 0 00112 unsigned reserved1 : 6; 00113 unsigned csd_ver : 2; 00114 // byte 1 00115 uint8_t taac; 00116 // byte 2 00117 uint8_t nsac; 00118 // byte 3 00119 uint8_t tran_speed; 00120 // byte 4 00121 uint8_t ccc_high; 00122 // byte 5 00123 unsigned read_bl_len : 4; 00124 unsigned ccc_low : 4; 00125 // byte 6 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 // byte 7 00133 uint8_t c_size_mid; 00134 // byte 8 00135 unsigned vdd_r_curr_max : 3; 00136 unsigned vdd_r_curr_min : 3; 00137 unsigned c_size_low :2; 00138 // byte 9 00139 unsigned c_size_mult_high : 2; 00140 unsigned vdd_w_cur_max : 3; 00141 unsigned vdd_w_curr_min : 3; 00142 // byte 10 00143 unsigned sector_size_high : 6; 00144 unsigned erase_blk_en : 1; 00145 unsigned c_size_mult_low : 1; 00146 // byte 11 00147 unsigned wp_grp_size : 7; 00148 unsigned sector_size_low : 1; 00149 // byte 12 00150 unsigned write_bl_len_high : 2; 00151 unsigned r2w_factor : 3; 00152 unsigned reserved3 : 2; 00153 unsigned wp_grp_enable : 1; 00154 // byte 13 00155 unsigned reserved4 : 5; 00156 unsigned write_partial : 1; 00157 unsigned write_bl_len_low : 2; 00158 // byte 14 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 // byte 15 00166 unsigned always1 : 1; 00167 unsigned crc : 7; 00168 }csd1_t; 00169 //------------------------------------------------------------------------------ 00170 // CSD for version 2.00 cards 00171 typedef struct CSDV2 { 00172 // byte 0 00173 unsigned reserved1 : 6; 00174 unsigned csd_ver : 2; 00175 // byte 1 00176 uint8_t taac; 00177 // byte 2 00178 uint8_t nsac; 00179 // byte 3 00180 uint8_t tran_speed; 00181 // byte 4 00182 uint8_t ccc_high; 00183 // byte 5 00184 unsigned read_bl_len : 4; 00185 unsigned ccc_low : 4; 00186 // byte 6 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 // byte 7 00193 unsigned reserved3 : 2; 00194 unsigned c_size_high : 6; 00195 // byte 8 00196 uint8_t c_size_mid; 00197 // byte 9 00198 uint8_t c_size_low; 00199 // byte 10 00200 unsigned sector_size_high : 6; 00201 unsigned erase_blk_en : 1; 00202 unsigned reserved4 : 1; 00203 // byte 11 00204 unsigned wp_grp_size : 7; 00205 unsigned sector_size_low : 1; 00206 // byte 12 00207 unsigned write_bl_len_high : 2; 00208 unsigned r2w_factor : 3; 00209 unsigned reserved5 : 2; 00210 unsigned wp_grp_enable : 1; 00211 // byte 13 00212 unsigned reserved6 : 5; 00213 unsigned write_partial : 1; 00214 unsigned write_bl_len_low : 2; 00215 // byte 14 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 // byte 15 00223 unsigned always1 : 1; 00224 unsigned crc : 7; 00225 }csd2_t; 00226 //------------------------------------------------------------------------------ 00227 // union of old and new style CSD register 00228 union csd_t { 00229 csd1_t v1; 00230 csd2_t v2; 00231 }; 00232 #endif // SdInfo_h