Information Technology Reference
In-Depth Information
function calls the ReadMedia and WriteSPI functions from Chapter 4 and
the SendSDCCmd function above.
// This macro writes FFh twice to send two CRC bytes.
// The code assumes CRC values are ignored (the default in SPI mode).
#define mSendCRC() WriteSPI(0xFF); WriteSPI(0xFF);
#define DATA_ACCEPTED 0b00000101
SDC_Error SectorWrite(dword sector_addr, byte* buffer)
{
byte
data_response;
word
index;
SDC_RESPONSE
response;
SDC_Error
status = sdcValid;
// Issue a WRITE_SINGLE_BLOCK command.
// Pass the address of the first byte to write 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(WRITE_SINGLE_BLOCK, (sector_addr << 9));
// A response of 00h indicates success.
if (response.r1._byte != 0x00)
status = sdcCardBadCmd;
Search WWH ::




Custom Search