Information Technology Reference
In-Depth Information
Reading the CSD Register
When initializing communications, the host must read the card's CSD regis-
ter. The CSD union below defines the contents of the CSD register as 4
dwords or 16 bytes. For brevity, I didn't include a union component with a
field for each of the CSD's 37 items.
typedef union
{
struct
{
DWORD _u320;
DWORD _u321;
DWORD _u322;
DWORD _u323;
};
struct
{
byte _byte[16];
};
} CSD;
The CSDRead function issues the SEND_CSD command and waits for the
card to send the register's 16 bytes. Much of the function is similar to the
SendSDCCmd function above. A difference is that the function retrieves
data from the card after sending the command.
#define CSD_SIZE 16
#define DATA_START_TOKEN 0xFE // The Start Block token
CSD gblCSDReg;
SDC_Error CSDRead()
{
dword
address = 0x00;
byte
cmd = SEND_CSD;
CMD_PACKET
CmdPacket;
byte
data_token;
word
index;
SDC_RESPONSE
response;
SDC_Error
status = sdcValid;
word
timeout = 0x2ff;
Search WWH ::




Custom Search