Information Technology Reference
In-Depth Information
else {
// The command succeeded.
// Read the CSD register.
CSDstatus = CSDRead();
if (!CSDstatus)
// The response was zero. The CSD was read successfully.
// OK to increase the clock speed.
OpenSPI(SPI_FOSC_4, MODE_11, SMPMID);
else
// Unable to read the CSD.
status = sdcCardTypeInvalid;
}
// Issue the SET_BLOCKLEN command to set the block length to 512.
// (Optional, since this is the default.)
SendSDCCmd(SET_BLOCKLEN, 512);
// Set a bit in the SDCSTATE structure if the card is write-protected.
if (IsWriteProtected())
Flag -> isWP = TRUE;
// Read sector zero from the card into msd_buffer until success or a timeout.
// Some cards require multiple attempts.
for (timeout = 0xFF;
timeout > 0 && SectorRead(0x0, (byte*)msd_buffer) != sdcValid;
timeout--)
Search WWH ::




Custom Search