1 | /* Arduino FAT16 Library
|
---|
2 | * Copyright (C) 2008 by William Greiman
|
---|
3 | *
|
---|
4 | * This file is part of the Arduino FAT16 Library
|
---|
5 | *
|
---|
6 | * This Library is free software: you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation, either version 3 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This Library is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 |
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with the Arduino Fat16 Library. If not, see
|
---|
18 | * <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #ifndef SdInfo_h
|
---|
21 | #define SdInfo_h
|
---|
22 | #include <stdint.h>
|
---|
23 | // Based on the document:
|
---|
24 | //
|
---|
25 | // SD Specifications
|
---|
26 | // Part 1
|
---|
27 | // Physical Layer
|
---|
28 | // Simplified Specification
|
---|
29 | // Version 2.00
|
---|
30 | // September 25, 2006
|
---|
31 | //
|
---|
32 | // www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf
|
---|
33 | //
|
---|
34 | // Card IDentification (CID) register
|
---|
35 | typedef struct CID {
|
---|
36 | // byte 0
|
---|
37 | uint8_t mid; // Manufacturer ID
|
---|
38 | // byte 1-2
|
---|
39 | char oid[2]; // OEM/Application ID
|
---|
40 | // byte 3-7
|
---|
41 | char pnm[5]; // Product name
|
---|
42 | // byte 8
|
---|
43 | unsigned prv_m : 4; // Product revision n.m
|
---|
44 | unsigned prv_n : 4;
|
---|
45 | // byte 9-12
|
---|
46 | uint32_t psn; // Product serial number
|
---|
47 | // byte 13
|
---|
48 | unsigned mdt_year_high : 4; // Manufacturing date
|
---|
49 | unsigned reserved : 4;
|
---|
50 | // byte 14
|
---|
51 | unsigned mdt_month : 4;
|
---|
52 | unsigned mdt_year_low :4;
|
---|
53 | // byte 15
|
---|
54 | unsigned always1 : 1;
|
---|
55 | unsigned crc : 7;
|
---|
56 | }cid_t;
|
---|
57 | // Card-Specific Data register
|
---|
58 | typedef struct CSD {
|
---|
59 | // byte 0
|
---|
60 | unsigned reserved1 : 6;
|
---|
61 | unsigned csd_ver : 2;
|
---|
62 | // byte 1
|
---|
63 | uint8_t taac;
|
---|
64 | // byte 2
|
---|
65 | uint8_t nsac;
|
---|
66 | // byte 3
|
---|
67 | uint8_t tran_speed;
|
---|
68 | // byte 4
|
---|
69 | uint8_t ccc_high;
|
---|
70 | // byte 5
|
---|
71 | unsigned read_bl_len : 4;
|
---|
72 | unsigned ccc_low : 4;
|
---|
73 | // byte 6
|
---|
74 | unsigned c_size_high : 2;
|
---|
75 | unsigned reserved2 : 2;
|
---|
76 | unsigned dsr_imp : 1;
|
---|
77 | unsigned read_blk_misalign :1;
|
---|
78 | unsigned write_blk_misalign : 1;
|
---|
79 | unsigned read_bl_partial : 1;
|
---|
80 | // byte 7
|
---|
81 | uint8_t c_size_mid;
|
---|
82 | // byte 8
|
---|
83 | unsigned vdd_r_curr_max : 3;
|
---|
84 | unsigned vdd_r_curr_min : 3;
|
---|
85 | unsigned c_size_low :2;
|
---|
86 | // byte 9
|
---|
87 | unsigned c_size_mult_high : 2;
|
---|
88 | unsigned vdd_w_cur_max : 3;
|
---|
89 | unsigned vdd_w_curr_min : 3;
|
---|
90 | // byte 10
|
---|
91 | unsigned sector_size_high : 6;
|
---|
92 | unsigned erase_blk_en : 1;
|
---|
93 | unsigned c_size_mult_low : 1;
|
---|
94 | // byte 11
|
---|
95 | unsigned wp_grp_size : 7;
|
---|
96 | unsigned sector_size_low : 1;
|
---|
97 | // byte 12
|
---|
98 | unsigned write_bl_len_high : 2;
|
---|
99 | unsigned r2w_factor : 3;
|
---|
100 | unsigned reserved3 : 2;
|
---|
101 | unsigned wp_grp_enable : 1;
|
---|
102 | // byte 13
|
---|
103 | unsigned reserved4 : 5;
|
---|
104 | unsigned write_partial : 1;
|
---|
105 | unsigned write_bl_len_low : 2;
|
---|
106 | // byte 14
|
---|
107 | unsigned reserved5: 2;
|
---|
108 | unsigned file_format : 2;
|
---|
109 | unsigned tmp_write_protect : 1;
|
---|
110 | unsigned perm_write_protect : 1;
|
---|
111 | unsigned copy : 1;
|
---|
112 | unsigned file_format_grp : 1;
|
---|
113 | // byte 15
|
---|
114 | unsigned always1 : 1;
|
---|
115 | unsigned crc : 7;
|
---|
116 | }csd_t;
|
---|
117 | #endif // SdInfo_h
|
---|