EZ-USB FX3 Technical Reference Manual, Document Number: 001-76074 Rev. *F 221
Storage Ports
9.6.2 Handling Card Detection in Software
The card detection method can be chosen in the firmware according to its support on the card as well as on the hardware.
The card detection method is chosen using the field cardDetType through API CyU3PSibSetIntfParams. Accordingly, the
interrupt will be enabled in the SDMMC_INTR_MASK register. The CARD_DETECT interrupt is enabled in the card detection
method based on GPIO, or the DAT3_STAT interrupt is enabled in the card detection method based on the DAT3 line.
intfParams.resetGpio = 0xFF; /* No GPIO control on SD/MMC power. */
intfParams.rstActHigh = CyTrue; /* Don't care as no GPIO is selected. */
intfParams.cardDetType = CY_U3P_SIB_DETECT_DAT_3; /* Card detect based
on SD_DAT[3]. */
intfParams.writeProtEnable = CyTrue; /* Write protect handling enabled.*/
intfParams.lowVoltage = CyTrue; /* Low voltage operation enabled. */
intfParams.voltageSwGpio = 45; /* Use GPIO_45 for voltage switch on
S0 port. */
intfParams.lvGpioState = CyFalse; /* Driving GPIO low selects 1.8 V on
SxVDDQ. */
intfParams.useDdr = CyTrue; /* DDR clocking enabled. */
intfParams.maxFreq = CY_U3P_SIB_FREQ_104MHZ; /* No S port clock
limitation. */
intfParams.cardInitDelay = 0; /* No delay required between SD card insertion before
initialization. */
status = CyU3PSibSetIntfParams (0, &intfParams);
The card detection mechanism supported is provided through the enumerated list CyU3PSibCardDetect, as follows. The card
detection can be disabled by selecting CY_U3P_SIB_DETECT_NONE.
/** \brief List of card detection methods.
**Description**\n
The card insertion and removal detection can be based on either GPIO card detect
or based on signal changes on the DAT3 line. */
typedef enum CyU3PSibCardDetect
{
CY_U3P_SIB_DETECT_NONE = 0, /**< Don't use any card detection mechanism */
CY_U3P_SIB_DETECT_GPIO, /**< Use a GPIO connected to a micro-switch on the
socket. This is
only supported for the S0 storage port. */
CY_U3P_SIB_DETECT_DAT_3 /**< Use voltage changes on the DAT[3] pin for card
detection. */
} CyU3PSibCardDetect;
If the card detect mechanism is chosen as GPIO based, then the GPIO44 is chosen as a default by the FX3S software driver
and library. The FX3S library and driver configure the GPIO in such a case by default, and the card detect interrupt will be
notified to the application firmware via the SIB callback registered (explained in 9.5.1.6 Handling SIB Events on page 208), as
shown in the following example. This is the case even with DAT3-based card detection.
Note: Any unused GPIO can be used for card detection, which can be configured similar to any simple GPIO in the
application firmware. Refer to 4.1 GPIO Pins on page 51 for more details.
/* Register a callback for SIB events. */
status = CyU3PSibRegisterCbk (CyFxSDIOUARTApplnSibCB);
/* SIB Callback for handling SIB events */
void