SD card data transfer functions.
More...
#include <util/crc16.h>
#include "spi.h"
#include "sdcmd.h"
Detailed Description
SD card data transfer functions.
Function Documentation
uint8_t sd_recv_data |
( |
uint8_t * |
data, |
|
|
sd_blen_t |
blocklen | |
|
) |
| | |
read data from SD card
- Parameters:
-
| data | pointer to buffer for data |
| blocklen | number of bytes to receive |
{
uint16_t crc = 0x0000;
uint16_t crc_read;
sd_blen_t i;
uint8_t t;
do {
t = spi_transfer (0xff, 0, 1);
} while (t == 0xff);
for (i=blocklen; i; i--) {
uint8_t b = spi_transfer (0xff, 0, 1);
*data++ = b;
crc = _crc_xmodem_update (crc, b);
}
crc_read = spi_transfer (0xff, 0, 1); crc_read <<= 8;
crc_read |= spi_transfer (0xff, 0, 1);
return crc_read == crc;
}
void sd_send_data |
( |
const uint8_t * |
data, |
|
|
sd_blen_t |
blocklen, |
|
|
uint8_t |
token | |
|
) |
| | |
write data to SD card
- Parameters:
-
| data | pointer to buffer with data |
| blocklen | number of bytes to send |
| token | token value to start transmission |