Information Technology Reference
In-Depth Information
fies the sector to read (sector_addr) and a pointer to a buffer that will store
the data read from the card (buffer). The function returns a status code.
// This macro writes FFh twice to clock in two CRC bytes.
#define mReadCRC() WriteSPI(0xFF); WriteSPI(0xFF);
#define SDC_FLOATING_BUS 0xFF
#define SDC_BAD_RESPONSE SDC_FLOATING_BUS
#define SDC_SECTOR_SIZE 512
SDC_Error SectorRead(dword sector_addr, byte* buffer)
{
byte
data_token;
word
index;
SDC_RESPONSE
response;
SDC_Error
status = sdcValid;
// Issue a READ_SINGLE_BLOCK command.
// Specify the address of the first byte to read in the media.
// To obtain the address of a sector's first byte,
// shift the sector address left 9 times to multiply by 512 (sector size).
response = SendSDCCmd(READ_SINGLE_BLOCK, (sector_addr << 9));
// A response of 00h indicates success.
if (response.r1._byte != 0x00)
{
status = sdcCardBadCmd;
}
else
{
// The command was accepted.
index = 0x2FF;
Search WWH ::




Custom Search