Information Technology Reference
In-Depth Information
// Select the card.
SDC_CS = 0;
// Store a command byte, address, and CRC value in the CMD_PACKET structure.
CmdPacket.cmd = sdmmc_cmdtable[cmd].CmdCode;
CmdPacket.address = address;
CmdPacket.crc = sdmmc_cmdtable[cmd].CRC;
// Send the command byte, address bytes, and CRC byte.
// The WriteSPI library function writes a byte on the SPI bus.
WriteSPI(CmdPacket.cmd);
WriteSPI(CmdPacket.addr3);
WriteSPI(CmdPacket.addr2);
WriteSPI(CmdPacket.addr1);
WriteSPI(CmdPacket.addr0);
WriteSPI(CmdPacket.crc);
// Read a byte from the card until the byte doesn't equal FFh or a timeout occurs.
do
{
response.r1._byte = ReadMedia();
timeout--;
} while ((response.r1._byte == 0xFF) && (timeout != 0));
// A response of 00h means the command was accepted.
if (response.r1._byte != 0x00)
{
status = sdcCardBadCmd;
}
Search WWH ::




Custom Search