Information Technology Reference
In-Depth Information
Error:
// On error or completion of the delay, turn off the timer and disable its interrupt.
TMR1ON = 0;
TMR1IE = 0;
}
A Function for Initializing
The MediaInitialize function performs initialization tasks and returns status
in an SDC_Error structure. The function accepts a pointer to an SDC-
STATE structure and sets the states of the structure's two members. The
function uses the 512-byte msd_buffer array introduced in Chapter 3 to
hold data read from the card's storage media. The function calls the Open-
SPI function from Chapter 4.
SDC_Error MediaInitialize(SDCSTATE *Flag)
{
SDC_Error
CSDstatus = sdcValid;
SDC_RESPONSE
response;
SDC_Error
status = sdcValid;
word
timeout;
Flag -> _byte = 0x0;
// Deselect the card.
SDC_CS = 1;
// Open the SPI port.
// Clock speed must be <= 400 kHz until the card is initialized
// and the CSD register has been read.
// MultiMediaCards require CKE = 0, CKP = 1,
// and sampling DataOut in the middle of a clock cyle.
OpenSPI(SPI_FOSC_64, MODE_11, SMPMID);
// Allow the card time to initialize.
Delayms(100);
Search WWH ::




Custom Search