mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Added sd_read64 to help with block reads and crc checking.
This commit is contained in:
parent
a95106b516
commit
fe0f6de2ab
@ -99,6 +99,25 @@ uint64_t sd_cmd(uint8_t cmd, uint32_t arg, uint8_t crc) {
|
||||
return r;
|
||||
} // sd_cmd
|
||||
|
||||
uint64_t sd_read64(uint16_t * crc) {
|
||||
uint64_t r;
|
||||
uint8_t rbyte;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
spi_sendbyte(0xFF);
|
||||
}
|
||||
|
||||
waittx();
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
rbyte = spi_readbyte();
|
||||
*crc = crc16(*crc, rbyte);
|
||||
r = r | (rbyte << ((8 - 1 - i)*8));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// Utility defines for CMD0, CMD8, CMD55, and ACMD41
|
||||
#define CMD0() sd_cmd( 0, 0x00000000, 0x95) // Reset SD card into IDLE state
|
||||
|
Loading…
Reference in New Issue
Block a user