59 void sel() { digitalWrite(
pin, LOW); }
61 digitalWrite(
pin, HIGH);
72 Serial.print(
cmd, DEC);
74 Serial.print(lba, HEX);
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));
93 while ((r = SPI.transfer(0xff)) & 0x80);
101 while ((r = SPI.transfer(0xff)) & 0x80)
103 for (
byte i = 4; i; i--)
104 ocr = (ocr << 8) | SPI.transfer(0xff);
113 while ((r = SPI.transfer(0xff)) & 0x80)
115 for (
byte i = 4; i; i--)
133 pinMode(
pin, OUTPUT);
135 SPI.setClockDivider(SPI_CLOCK_DIV64);
149 if(cts>0) cts--;
else
154 }
while ((r = SPI.transfer(0xff)) & 0x80);
170 appcmd(41, sdhc ? (1UL << 30) : 0);
182 ccs = 1UL & (OCR >> 30);
189 byte type_code =
rd(0x1be + 0x4);
222 o_fat = 512L * fat_begin_lba;
232 cmd(17, off & ~511L);
235 while (SPI.transfer(0xff) != 0xfe)
242 for (i = 0; i < bo; i++)
244 for (i = 0; i < n; i++)
245 *
d++ = SPI.transfer(0xff);
246 for (i = 0; i < (514 - bo - n); i++)
253 rdn((
byte*)&r, off,
sizeof(r));
259 rdn((
byte*)&r, off,
sizeof(r));
265 rdn((
byte*)&r, off,
sizeof(r));
286static void dos83(
byte dst[11],
const char *ps)
291 dst[i++] = toupper(*ps);
310 dos83(dosname, filename);
314 if (0 == memcmp(de.name, dosname, 11)) {
319 }
while (de.
name[0]);
337 Serial.print(
"nextcluster=");
368 Serial.print(
"off=0x");
369 Serial.println(off, HEX);
378 for (
int i = 0; i < 64; i++) {
379 *dst++ = SPI.transfer(0xff);
380 *dst++ = SPI.transfer(0xff);
381 *dst++ = SPI.transfer(0xff);
382 *dst++ = SPI.transfer(0xff);
383 *dst++ = SPI.transfer(0xff);
384 *dst++ = SPI.transfer(0xff);
385 *dst++ = SPI.transfer(0xff);
386 *dst++ = SPI.transfer(0xff);
static ft_void_t ft_uint32_t * cmd
int openfile(const char *filename)
void readsector(byte *dst)
uint32_t rd4(uint32_t off)
uint16_t rd2(uint32_t off)
uint16_t reserved_sectors
uint16_t max_root_dir_entries
void cmd(byte cmd, uint32_t lba=0, uint8_t crc=0x95)
void rdn(byte *d, uint32_t off, uint16_t n)
void appcmd(byte cc, uint32_t lba=0)
uint32_t root_dir_first_cluster
uint16_t sectors_per_cluster
static void dos83(byte dst[11], const char *ps)