| Description | The function CheckMedia checks the SD/MMC Memory Card status. It reads the Card Detect (CD) and Write Protect (WP) digital inputs. If CD and WP digital inputs from SD Card socket are not connected, this function might be omitted. The function is part of the SPI Driver. The prototype is defined in the file File_Config.h. Developers must customize the function. |
| Example |
/* SPI Device Driver Control Block */
SPI_DRV spi0_drv = {
Init,
UnInit,
Send,
SendBuf,
RecBuf,
BusSpeed,
SetSS,
CheckMedia /* Can be NULL if not existing */
};
/* Read CardDetect and WriteProtect SD card socket pins. */
static U32 CheckMedia (void) {
U32 stat = 0;
if (!(IOPIN0 & 0x04)) {
stat |= M_INSERTED; /* Card is inserted (CD=0). */
}
if ((IOPIN0 & 0x20)) {
stat |= M_PROTECTED; /* Write Protect switch is active (WP=1). */
}
return (stat);
}
/* SPI Device Driver Control Block without CheckMedia */
SPI_DRV spi0_drv = {
Init,
UnInit,
Send,
SendBuf,
RecBuf,
BusSpeed,
SetSS,
NULL
};
|