SdInfo.h

Sat, 07 Nov 2015 13:24:46 +0100

author
mbayer
date
Sat, 07 Nov 2015 13:24:46 +0100
changeset 1
b584642d4f58
parent 0
2c8ba1964db7
permissions
-rw-r--r--

several modifications to support laser enable - still needs cleanup

0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1 /* Arduino Sd2Card Library
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
2 * Copyright (C) 2009 by William Greiman
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
3 *
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
4 * This file is part of the Arduino Sd2Card Library
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
5 *
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
6 * This Library is free software: you can redistribute it and/or modify
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
9 * (at your option) any later version.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
10 *
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
11 * This Library is distributed in the hope that it will be useful,
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
14 * GNU General Public License for more details.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
15 *
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
17 * along with the Arduino Sd2Card Library. If not, see
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
18 * <http://www.gnu.org/licenses/>.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
19 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
20 #include "Marlin.h"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
21 #ifdef SDSUPPORT
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
22
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
23 #ifndef SdInfo_h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
24 #define SdInfo_h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
25 #include <stdint.h>
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
26 // Based on the document:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
27 //
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
28 // SD Specifications
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
29 // Part 1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
30 // Physical Layer
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
31 // Simplified Specification
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
32 // Version 3.01
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
33 // May 18, 2010
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
34 //
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
35 // http://www.sdcard.org/developers/tech/sdcard/pls/simplified_specs
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
36 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
37 // SD card commands
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
38 /** GO_IDLE_STATE - init card in spi mode if CS low */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
39 uint8_t const CMD0 = 0X00;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
40 /** SEND_IF_COND - verify SD Memory Card interface operating condition.*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
41 uint8_t const CMD8 = 0X08;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
42 /** SEND_CSD - read the Card Specific Data (CSD register) */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
43 uint8_t const CMD9 = 0X09;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
44 /** SEND_CID - read the card identification information (CID register) */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
45 uint8_t const CMD10 = 0X0A;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
46 /** STOP_TRANSMISSION - end multiple block read sequence */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
47 uint8_t const CMD12 = 0X0C;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
48 /** SEND_STATUS - read the card status register */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
49 uint8_t const CMD13 = 0X0D;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
50 /** READ_SINGLE_BLOCK - read a single data block from the card */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
51 uint8_t const CMD17 = 0X11;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
52 /** READ_MULTIPLE_BLOCK - read a multiple data blocks from the card */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
53 uint8_t const CMD18 = 0X12;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
54 /** WRITE_BLOCK - write a single data block to the card */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
55 uint8_t const CMD24 = 0X18;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
56 /** WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
57 uint8_t const CMD25 = 0X19;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
58 /** ERASE_WR_BLK_START - sets the address of the first block to be erased */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
59 uint8_t const CMD32 = 0X20;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
60 /** ERASE_WR_BLK_END - sets the address of the last block of the continuous
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
61 range to be erased*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
62 uint8_t const CMD33 = 0X21;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
63 /** ERASE - erase all previously selected blocks */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
64 uint8_t const CMD38 = 0X26;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
65 /** APP_CMD - escape for application specific command */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
66 uint8_t const CMD55 = 0X37;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
67 /** READ_OCR - read the OCR register of a card */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
68 uint8_t const CMD58 = 0X3A;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
69 /** SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
70 pre-erased before writing */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
71 uint8_t const ACMD23 = 0X17;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
72 /** SD_SEND_OP_COMD - Sends host capacity support information and
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
73 activates the card's initialization process */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
74 uint8_t const ACMD41 = 0X29;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
75 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
76 /** status for card in the ready state */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
77 uint8_t const R1_READY_STATE = 0X00;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
78 /** status for card in the idle state */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
79 uint8_t const R1_IDLE_STATE = 0X01;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
80 /** status bit for illegal command */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
81 uint8_t const R1_ILLEGAL_COMMAND = 0X04;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
82 /** start data token for read or write single block*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
83 uint8_t const DATA_START_BLOCK = 0XFE;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
84 /** stop token for write multiple blocks*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
85 uint8_t const STOP_TRAN_TOKEN = 0XFD;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
86 /** start data token for write multiple blocks*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
87 uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
88 /** mask for data response tokens after a write block operation */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
89 uint8_t const DATA_RES_MASK = 0X1F;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
90 /** write data accepted token */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
91 uint8_t const DATA_RES_ACCEPTED = 0X05;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
92 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
93 /** Card IDentification (CID) register */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
94 typedef struct CID {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
95 // byte 0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
96 /** Manufacturer ID */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
97 unsigned char mid;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
98 // byte 1-2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
99 /** OEM/Application ID */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
100 char oid[2];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
101 // byte 3-7
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
102 /** Product name */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
103 char pnm[5];
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
104 // byte 8
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
105 /** Product revision least significant digit */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
106 unsigned char prv_m : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
107 /** Product revision most significant digit */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
108 unsigned char prv_n : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
109 // byte 9-12
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
110 /** Product serial number */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
111 uint32_t psn;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
112 // byte 13
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
113 /** Manufacturing date year low digit */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
114 unsigned char mdt_year_high : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
115 /** not used */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
116 unsigned char reserved : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
117 // byte 14
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
118 /** Manufacturing date month */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
119 unsigned char mdt_month : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
120 /** Manufacturing date year low digit */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
121 unsigned char mdt_year_low :4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
122 // byte 15
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
123 /** not used always 1 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
124 unsigned char always1 : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
125 /** CRC7 checksum */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
126 unsigned char crc : 7;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
127 }cid_t;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
128 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
129 /** CSD for version 1.00 cards */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
130 typedef struct CSDV1 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
131 // byte 0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
132 unsigned char reserved1 : 6;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
133 unsigned char csd_ver : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
134 // byte 1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
135 unsigned char taac;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
136 // byte 2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
137 unsigned char nsac;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
138 // byte 3
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
139 unsigned char tran_speed;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
140 // byte 4
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
141 unsigned char ccc_high;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
142 // byte 5
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
143 unsigned char read_bl_len : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
144 unsigned char ccc_low : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
145 // byte 6
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
146 unsigned char c_size_high : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
147 unsigned char reserved2 : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
148 unsigned char dsr_imp : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
149 unsigned char read_blk_misalign :1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
150 unsigned char write_blk_misalign : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
151 unsigned char read_bl_partial : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
152 // byte 7
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
153 unsigned char c_size_mid;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
154 // byte 8
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
155 unsigned char vdd_r_curr_max : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
156 unsigned char vdd_r_curr_min : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
157 unsigned char c_size_low :2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
158 // byte 9
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
159 unsigned char c_size_mult_high : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
160 unsigned char vdd_w_cur_max : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
161 unsigned char vdd_w_curr_min : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
162 // byte 10
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
163 unsigned char sector_size_high : 6;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
164 unsigned char erase_blk_en : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
165 unsigned char c_size_mult_low : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
166 // byte 11
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
167 unsigned char wp_grp_size : 7;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
168 unsigned char sector_size_low : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
169 // byte 12
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
170 unsigned char write_bl_len_high : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
171 unsigned char r2w_factor : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
172 unsigned char reserved3 : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
173 unsigned char wp_grp_enable : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
174 // byte 13
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
175 unsigned char reserved4 : 5;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
176 unsigned char write_partial : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
177 unsigned char write_bl_len_low : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
178 // byte 14
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
179 unsigned char reserved5: 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
180 unsigned char file_format : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
181 unsigned char tmp_write_protect : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
182 unsigned char perm_write_protect : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
183 unsigned char copy : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
184 /** Indicates the file format on the card */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
185 unsigned char file_format_grp : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
186 // byte 15
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
187 unsigned char always1 : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
188 unsigned char crc : 7;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
189 }csd1_t;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
190 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
191 /** CSD for version 2.00 cards */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
192 typedef struct CSDV2 {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
193 // byte 0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
194 unsigned char reserved1 : 6;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
195 unsigned char csd_ver : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
196 // byte 1
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
197 /** fixed to 0X0E */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
198 unsigned char taac;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
199 // byte 2
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
200 /** fixed to 0 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
201 unsigned char nsac;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
202 // byte 3
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
203 unsigned char tran_speed;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
204 // byte 4
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
205 unsigned char ccc_high;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
206 // byte 5
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
207 /** This field is fixed to 9h, which indicates READ_BL_LEN=512 Byte */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
208 unsigned char read_bl_len : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
209 unsigned char ccc_low : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
210 // byte 6
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
211 /** not used */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
212 unsigned char reserved2 : 4;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
213 unsigned char dsr_imp : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
214 /** fixed to 0 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
215 unsigned char read_blk_misalign :1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
216 /** fixed to 0 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
217 unsigned char write_blk_misalign : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
218 /** fixed to 0 - no partial read */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
219 unsigned char read_bl_partial : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
220 // byte 7
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
221 /** not used */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
222 unsigned char reserved3 : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
223 /** high part of card size */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
224 unsigned char c_size_high : 6;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
225 // byte 8
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
226 /** middle part of card size */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
227 unsigned char c_size_mid;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
228 // byte 9
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
229 /** low part of card size */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
230 unsigned char c_size_low;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
231 // byte 10
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
232 /** sector size is fixed at 64 KB */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
233 unsigned char sector_size_high : 6;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
234 /** fixed to 1 - erase single is supported */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
235 unsigned char erase_blk_en : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
236 /** not used */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
237 unsigned char reserved4 : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
238 // byte 11
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
239 unsigned char wp_grp_size : 7;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
240 /** sector size is fixed at 64 KB */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
241 unsigned char sector_size_low : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
242 // byte 12
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
243 /** write_bl_len fixed for 512 byte blocks */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
244 unsigned char write_bl_len_high : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
245 /** fixed value of 2 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
246 unsigned char r2w_factor : 3;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
247 /** not used */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
248 unsigned char reserved5 : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
249 /** fixed value of 0 - no write protect groups */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
250 unsigned char wp_grp_enable : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
251 // byte 13
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
252 unsigned char reserved6 : 5;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
253 /** always zero - no partial block read*/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
254 unsigned char write_partial : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
255 /** write_bl_len fixed for 512 byte blocks */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
256 unsigned char write_bl_len_low : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
257 // byte 14
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
258 unsigned char reserved7: 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
259 /** Do not use always 0 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
260 unsigned char file_format : 2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
261 unsigned char tmp_write_protect : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
262 unsigned char perm_write_protect : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
263 unsigned char copy : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
264 /** Do not use always 0 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
265 unsigned char file_format_grp : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
266 // byte 15
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
267 /** not used always 1 */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
268 unsigned char always1 : 1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
269 /** checksum */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
270 unsigned char crc : 7;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
271 }csd2_t;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
272 //------------------------------------------------------------------------------
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
273 /** union of old and new style CSD register */
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
274 union csd_t {
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
275 csd1_t v1;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
276 csd2_t v2;
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
277 };
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
278 #endif // SdInfo_h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
279
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
280 #endif

mercurial