#include <sdcard.h>
Definition at line 57 of file sdcard.h.
◆ appcmd()
void sdcard::appcmd |
( |
byte |
cc, |
|
|
uint32_t |
lba = 0 |
|
) |
| |
|
inline |
Definition at line 123 of file sdcard.h.
123 {
126 }
static ft_void_t ft_uint32_t * cmd
◆ begin()
Definition at line 128 of file sdcard.h.
129 {
132
133 pinMode(
pin, OUTPUT);
134 SPI.begin();
135 SPI.setClockDivider(SPI_CLOCK_DIV64);
137
140
141
142
143 byte r1,r;
144 do
145 {
147 do
148 {
149 if(cts>0) cts--; else
150 {
152 return 0;
153 }
154 }while ((r = SPI.transfer(0xff)) & 0x80);
156 SPI.transfer(0xff);
157 r1 = r;
158 }while(r1!=1);
159
160
161 byte sdhc = 0;
164 sdhc = (r1 == 1);
165
166
167
168
169 while (1) {
170 appcmd(41, sdhc ? (1UL << 30) : 0);
172 if ((r1 & 1) == 0)
173 break;
175 }
176
177
178 if (sdhc) {
182 ccs = 1UL & (OCR >> 30);
183
184 } else {
186 }
187
188
189 byte type_code =
rd(0x1be + 0x4);
190 switch (type_code) {
191 default:
193 break;
194 case 0x0b:
195 case 0x0c:
197 break;
198 }
199
200
205
206
207
208
214
216 } else {
221
222 o_fat = 512L * fat_begin_lba;
225 }
226 return 1;
227 }
uint32_t rd4(uint32_t off)
uint16_t rd2(uint32_t off)
uint16_t reserved_sectors
uint16_t max_root_dir_entries
void appcmd(byte cc, uint32_t lba=0)
uint32_t root_dir_first_cluster
uint16_t sectors_per_cluster
◆ cmd()
Definition at line 69 of file sdcard.h.
69 {
70#if VERBOSE
71 Serial.print("cmd ");
72 Serial.print(
cmd, DEC);
73 Serial.print(" ");
74 Serial.print(lba, HEX);
75 Serial.println();
76#endif
77
79 SPI.transfer(0xff);
80 SPI.transfer(0x40 |
cmd);
81 SPI.transfer(0xff & (lba >> 24));
82 SPI.transfer(0xff & (lba >> 16));
83 SPI.transfer(0xff & (lba >> 8));
84 SPI.transfer(0xff & (lba));
85 SPI.transfer(crc);
86 SPI.transfer(0xff);
87 }
◆ cmd17()
Definition at line 228 of file sdcard.h.
228 {
231 else
232 cmd(17, off & ~511L);
235 while (SPI.transfer(0xff) != 0xfe)
236 ;
237 }
◆ desel()
Definition at line 60 of file sdcard.h.
60 {
61 digitalWrite(
pin, HIGH);
62 SPI.transfer(0xff);
63 }
◆ R1()
Definition at line 89 of file sdcard.h.
90 {
91 byte r;
92
93 while ((r = SPI.transfer(0xff)) & 0x80);
95 SPI.transfer(0xff);
96 return r;
97 }
◆ rd()
Definition at line 263 of file sdcard.h.
263 {
264 byte r;
265 rdn((
byte*)&r, off,
sizeof(r));
266 return r;
267 }
void rdn(byte *d, uint32_t off, uint16_t n)
◆ rd2()
Definition at line 257 of file sdcard.h.
257 {
259 rdn((
byte*)&r, off,
sizeof(r));
260 return r;
261 }
◆ rd4()
Definition at line 251 of file sdcard.h.
251 {
253 rdn((
byte*)&r, off,
sizeof(r));
254 return r;
255 }
◆ rdn()
Definition at line 238 of file sdcard.h.
238 {
242 for (i = 0; i < bo; i++)
243 SPI.transfer(0xff);
244 for (i = 0; i < n; i++)
245 *
d++ = SPI.transfer(0xff);
246 for (i = 0; i < (514 - bo - n); i++)
247 SPI.transfer(0xff);
249 }
◆ sd_delay()
void sdcard::sd_delay |
( |
byte |
n | ) |
|
|
inline |
Definition at line 64 of file sdcard.h.
64 {
65 while (n--)
66 SPI.transfer(0xff);
67 }
◆ sdR3()
Definition at line 99 of file sdcard.h.
99 {
101 while ((r = SPI.transfer(0xff)) & 0x80)
102 ;
103 for (byte i = 4; i; i--)
104 ocr = (ocr << 8) | SPI.transfer(0xff);
105 SPI.transfer(0xff);
106
108 return r;
109 }
◆ sdR7()
Definition at line 111 of file sdcard.h.
111 {
113 while ((r = SPI.transfer(0xff)) & 0x80)
114 ;
115 for (byte i = 4; i; i--)
116
117 SPI.transfer(0xff);
119
120 return r;
121 }
◆ sel()
Definition at line 59 of file sdcard.h.
59{ digitalWrite(
pin, LOW); }
◆ ccs
◆ cluster_size
◆ max_root_dir_entries
◆ o_data
◆ o_fat
◆ o_partition
◆ o_root
◆ pin
◆ reserved_sectors
◆ root_dir_first_cluster
◆ sectors_per_cluster
◆ sectors_per_fat
◆ type
The documentation for this class was generated from the following file:
- D:/eclipse-workspace/BridgeTek/EveApps/EveApps/common/application/Arduino/sdcard.h