Functions
SDIO Functions
SDIO

Functions

CSL_Status SDIO_init (void)
CSL_SdioHandle SDIO_open (CSL_SdioControllerObj *pSdioContObj, CSL_SdioInstId instId, CSL_Status *status)
CSL_Status SDIO_close (CSL_SdioHandle hSdio)
CSL_Status SDIO_config (CSL_SdioHandle hSdio, CSL_SdioConfig *pSdioConfig)
CSL_Status SDIO_detectCard (CSL_SdioHandle hSdio, CSL_SdioCardObj *pSdioCardObj)
CSL_Status SDIO_initCard (CSL_SdioHandle hSdio, Uint32 OpCondReg, Bool initMem)
CSL_Status SDIO_resetCard (CSL_SdioHandle hSdio)
CSL_Status SDIO_getRca (CSL_SdioHandle hSdio, Uint16 *pRCardAddr)
CSL_Status SDIO_deselectCard (CSL_SdioHandle hSdio)
CSL_Status SDIO_selectCard (CSL_SdioHandle hSdio, Uint16 rca)
CSL_Status SDIO_sendCommand (CSL_SdioHandle hSdio, Uint32 cmd, Uint32 arg, Uint16 respTimeout)
CSL_Status SDIO_getResponse (CSL_SdioHandle hSdio, CSL_SdioRespType respType, CSL_SdioResponse *pResponse)
CSL_Status SDIO_clearResponse (CSL_SdioHandle hSdio)
Uint32 SDIO_getStatus (CSL_SdioHandle hSdio, Uint32 maskValue, CSL_Status *pStatus)
Uint32 SDIO_getSdioStatus (CSL_SdioHandle hSdio, Uint32 maskValue, CSL_Status *pStatus)
CSL_Status SDIO_eventEnable (CSL_SdioHandle hSdio, CSL_SdioEventType sdioEvent)
CSL_Status SDIO_eventDisable (CSL_SdioHandle hSdio, CSL_SdioEventType sdioEvent)
CSL_Status SDIO_readWaitEnable (CSL_SdioHandle hSdio)
CSL_Status SDIO_readWaitDisable (CSL_SdioHandle hSdio)
CSL_Status SDIO_readSingleByte (CSL_SdioHandle hSdio, Uint32 readAddr, Uint8 funNum, Uint8 *pReadData)
CSL_Status SDIO_writeSingleByte (CSL_SdioHandle hSdio, Uint32 writeAddr, Uint8 funNum, Uint8 writeData)
CSL_Status SDIO_readBytes (CSL_SdioHandle hSdio, Uint32 readAddr, Uint8 funNum, Bool opCode, Uint16 noOfBytes, Uint16 *pReadBuf)
CSL_Status SDIO_writeBytes (CSL_SdioHandle hSdio, Uint32 writeAddr, Uint8 funNum, Bool opCode, Uint16 noOfBytes, Uint16 *pWriteBuf)
CSL_Status SDIO_readBlocks (CSL_SdioHandle hSdio, Uint32 readAddr, Uint8 funNum, Bool opCode, Uint16 noOfBlocks, Uint16 blockSize, Uint16 *pReadBuf)
CSL_Status SDIO_writeBlocks (CSL_SdioHandle hSdio, Uint32 writeAddr, Uint8 funNum, Bool opCode, Uint16 noOfBlocks, Uint16 blockSize, Uint16 *pWriteBuf)
CSL_Status SDIO_setEndianMode (CSL_SdioHandle hSdio, CSL_SdioEndianMode writeEndianMode, CSL_SdioEndianMode readEndianMode)
CSL_Status SDIO_setClock (CSL_SdioHandle hSdio, Uint16 clockRate)

Function Documentation

CSL_Status SDIO_clearResponse ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_clearResponse

Description
This function is used to clear all the response registers.

Arguments

            hSdio          Handle to the SDIO.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
None

Modifies
Response structure

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            CSL_SdioResponse         response;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_clearResponse(hSdio);
     

===========================================================================

References CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_close ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_close

Description
This function closes the specified handle to SDIO.

Arguments

            hSdio            Handle to the SDIO
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
SDIO_open() API should be called successfully before this function.

Post Condition
None

Modifies
SDIO handle

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_close(hSdio);
     

===========================================================================

References CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_config ( CSL_SdioHandle  hSdio,
CSL_SdioConfig pSdioConfig 
)

===========================================================================
SDIO_config

Description
This function configures the SDIO controller hardware registers.

Arguments

            hSdio              Handle to the SDIO.
            pSdioConfig        Pointer to the SDIO config Parameter.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
SDIO_open() API should be called before this function.

Post Condition
None

Modifies
SDIO Registers.

Example


            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            CSL_SdioConfig           sdioConfig;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            // Initialize SDIO configuration structure
            sdioConfig.mmcctl  = .... ;
            ...
            ...
            sdioConfig.sdioien = .... ;


            // Configure SDIO
            status = SDIO_config(hSdio, &sdioConfig);
     

===========================================================================

References CSL_SdioConfig::mmcblen, CSL_SdioConfig::mmcclk, CSL_SdioConfig::mmcctl, CSL_SdioConfig::mmcfifoctl, CSL_SdioConfig::mmcim, CSL_SdioConfig::mmcnblk, CSL_SdioConfig::mmctod, CSL_SdioConfig::mmctor, CSL_SdioConfig::sdioctl, CSL_SdioConfig::sdioien, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_deselectCard ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_deselectCard

Description
This function is used to deselect SDIO which has been selected earlier. CMD7 shall be sent to the SDIO card with the relative card address set to 0x0000.

Arguments

            hSdio      Handle to the SDIO.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called.
3:Card should be active

Post Condition
Deselects the SDIO card

Modifies
None

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            CSL_SdioCardObj          sdioCardObj;
            Uint32                   ocr;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            status = SDIO_deselectCard(hSdio);
     

===========================================================================

References CSL_SdioCardObj::cardActive, CSL_SDIO_CARD_DESELECT_RCA, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_STUFF_BITS, CSL_SdioControllerObj::pSdioCardObj, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_detectCard ( CSL_SdioHandle  hSdio,
CSL_SdioCardObj pSdioCardObj 
)

===========================================================================
SDIO_detectCard

Description
This function is used to detect type of the SDIO card inserted. This function sends SDIO specification defined command sequence to detect type of the card. Type of the card shall be populated in pSdioCardObj. This function also populates other fields of card object structure. Address pointed by 'pSdioCardObj' should be global structure variable which persists till end of the program since it is stored by SDIO CSL for reference in other APIs. This API returns success only incase of SDIO card inserted into the MMC/SD slot of the EVM. For the SDIO cards which returns OCR value as 0, card type will be set to 'CSL_SDIO_INVALID_CARD'. Application/Driver programs should validate card type and ocr value updated in the card object structure to proceed further.

Arguments

            hSdio              Handle to the SDIO.
            pSdioCardObj       Pointer to SDIO card object structure
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESYS_FAIL - Card detection failed
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
SDIO_open() API should be called before this function.

Post Condition
None

Modifies
pSdioCardObj

Example


            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            CSL_SdioCardObj          sdioCardObj;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);
     

===========================================================================

References CSL_SdioCardObj::cardReady, CSL_SdioControllerObj::cmd8Resp, CSL_SDIO_CARD_NONE, CSL_SDIO_CLK_DIV_INIT, CSL_SDIO_CMD_0, CSL_SDIO_CMD_5, CSL_SDIO_CMD_8, CSL_SDIO_CMD_8_ARG, CSL_SDIO_CMD_RETRY_COUNT, CSL_SDIO_COMBO_CARD, CSL_SDIO_DATA_RW_TIMEOUT, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR, CSL_SDIO_EVENT_ERROR_CMDCRC, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_GET_C, CSL_SDIO_GET_FUNCNT, CSL_SDIO_GET_MEM, CSL_SDIO_GET_OCR, CSL_SDIO_INVALID_CARD, CSL_SDIO_IO_CARD, CSL_SDIO_LSHIFT, CSL_SDIO_MASK_WORD, CSL_SDIO_RESPONSE_TIMEOUT, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_WORD, CSL_SDIO_STUFF_BITS, CSL_SdioCardObj::funCount, CSL_SdioCardObj::ocr, CSL_SdioControllerObj::pSdioCardObj, CSL_SdioCardObj::sdioCardType, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_eventDisable ( CSL_SdioHandle  hSdio,
CSL_SdioEventType  sdioEvent 
)

===========================================================================
SDIO_eventDisable

Description
This function will disable the events in the MMC interrupt mask register and SDIO interrupt enable register.

Arguments

            hSdio         Handle to the SDIO.
            sdioEvent     Event type.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
Disables the given event

Modifies
MMC/SDIO Interrupt Mask Register

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_eventDisable(hSdio, CSL_SDIO_EDRRDY_INTERRUPT);
     

===========================================================================

References CSL_SDIO_CARD_INTERRUPT, CSL_SDIO_EBSYDNE_INTERRUPT, CSL_SDIO_ECRCRD_INTERRUPT, CSL_SDIO_ECRCRS_INTERRUPT, CSL_SDIO_ECRCWR_INTERRUPT, CSL_SDIO_EDATDNE_INTERRUPT, CSL_SDIO_EDATED_INTERRUPT, CSL_SDIO_EDRRDY_INTERRUPT, CSL_SDIO_EDXRDY_INTERRUPT, CSL_SDIO_ERSPDNE_INTERRUPT, CSL_SDIO_ETOUTRD_INTERRUPT, CSL_SDIO_ETOUTRS_INTERRUPT, CSL_SDIO_ETRNDNE_INTERRUPT, CSL_SDIO_MMCIM_ALL_INTERRUPT, CSL_SDIO_MMCIM_REG_MASK, CSL_SDIO_READWAIT_INTERRUPT, CSL_SDIO_SDIOIEN_ALL_INTERRUPT, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_eventEnable ( CSL_SdioHandle  hSdio,
CSL_SdioEventType  sdioEvent 
)

===========================================================================
SDIO_eventEnable

Description
This function will enable the events in the MMC interrupt mask register and SDIO interrupt enable register.

Arguments

            hSdio         Handle to the SDIO.
            sdioEvent     Event type.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
Enables the given event

Modifies
MMC/SDIO Interrupt Mask Registers

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_eventEnable(hSdio, CSL_SDIO_EDRRDY_INTERRUPT);
     

===========================================================================

References CSL_SDIO_CARD_INTERRUPT, CSL_SDIO_EBSYDNE_INTERRUPT, CSL_SDIO_ECRCRD_INTERRUPT, CSL_SDIO_ECRCRS_INTERRUPT, CSL_SDIO_ECRCWR_INTERRUPT, CSL_SDIO_EDATDNE_INTERRUPT, CSL_SDIO_EDATED_INTERRUPT, CSL_SDIO_EDRRDY_INTERRUPT, CSL_SDIO_EDXRDY_INTERRUPT, CSL_SDIO_ERSPDNE_INTERRUPT, CSL_SDIO_ETOUTRD_INTERRUPT, CSL_SDIO_ETOUTRS_INTERRUPT, CSL_SDIO_ETRNDNE_INTERRUPT, CSL_SDIO_MMCIM_ALL_INTERRUPT, CSL_SDIO_MMCIM_REG_MASK, CSL_SDIO_READWAIT_INTERRUPT, CSL_SDIO_SDIOIEN_ALL_INTERRUPT, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_getRca ( CSL_SdioHandle  hSdio,
Uint16 *  pRCardAddr 
)

===========================================================================
SDIO_getRca

Description
This function is used to read new relative card address from the card. This function sends CMD3 and reads relative card address. RCA read from the card will be populated to the pRCardAddr and card object structure in SDIO handle.

Arguments

            hSdio            Handle to the SDIO.
            pRCardAddr       Relative card address.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called.

Post Condition
None

Modifies
pRCardAddr variable will be populated.

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint16                   rca;
            Uint32                   ocr;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            status = SDIO_getRca(hSdio, &rca);

     

===========================================================================

References CSL_SDIO_CMD_3, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_STUFF_BITS, CSL_SdioControllerObj::pSdioCardObj, CSL_SdioCardObj::rca, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_getResponse ( CSL_SdioHandle  hSdio,
CSL_SdioRespType  respType,
CSL_SdioResponse pResponse 
)

===========================================================================
SDIO_getResponse

Description
This function is used to read the response registers. This function reads response registers based on the response type and populates the response structure. Response registers are not cleared by this function.


Response type Response bits Resp buf Fields populated
============== ============ =========================
R1,R3,R4,R5,R6 [23:8] pResponse->respBuf[6]
[39:24] pResponse->respBuf[7]

R2 [15:0] pResponse->respBuf[0]
[31:16] pResponse->respBuf[1]
[47:32] pResponse->respBuf[2]
[63:48] pResponse->respBuf[3]
[79:64] pResponse->respBuf[4]
[95:80] pResponse->respBuf[5]
[111:96] pResponse->respBuf[6]
[127:112] pResponse->respBuf[7]

NOTE: IF RESPONSE TYPE SENT IS NOT RECOGNIZED BY THIS API ALL THE RESPONSE REGISTERS ARE POPULATED IN THE SAME FORMAT MENTIONED ABOVE FOR R2 RESPONSE.

Arguments

            hSdio          Handle to the SDIO.
            respType       Type of the response
            pResponse      Pointer to response structure
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter

Pre Condition
SDIO_sendCommand() API should be called successfully.

Post Condition
None

Modifies
Response structure

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   cmd;
            Uint32                   arg;
            Uint16                   respTimeout;
            CSL_SdioResponse         response;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            //Send Command 5
            cmd         = 0x205;
            arg         = 0;
            respTimeout = 0xFFFF;
            status = SDIO_sendCommand(hSdio, cmd, arg, respTimeout);

            status = SDIO_getResponse(hSdio, CSL_SDIO_RESPTYPE_R4, &response);
     

===========================================================================

References CSL_SDIO_RESPTYPE_R1, CSL_SDIO_RESPTYPE_R2, CSL_SDIO_RESPTYPE_R3, CSL_SDIO_RESPTYPE_R4, CSL_SDIO_RESPTYPE_R5, CSL_SDIO_RESPTYPE_R6, CSL_SdioResponse::respBuf, and CSL_SdioControllerObj::sdioRegs.

Uint32 SDIO_getSdioStatus ( CSL_SdioHandle  hSdio,
Uint32  maskValue,
CSL_Status *  pStatus 
)

===========================================================================
SDIO_getSdioStatus

Description
This function reads SDIOST0 and SDIOIST registers and returns the value. When mask value is set to 0xFFFFFFFF, value of SDIOST0 will be stored in lower 16 bits and value of SDIOIST will be store in upper 16 bits. Value of a particular bit in the passed mask should be set to '1' to read the corresponding bit in the SDIO status register.

Arguments

            hSdio          Handle to the SDIO.
            maskValue      Mask value to specify the field.
            pStatus        status of API Success of Failed.
     

Return Value Uint32 Status - SDIOST0 and SDIOIST register value.

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
None

Modifies
None

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   sdiostatus;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            sdiostatus = SDIO_getSdioStatus(hSdio, 0xFFFF, &status);
     

===========================================================================

References CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.

Uint32 SDIO_getStatus ( CSL_SdioHandle  hSdio,
Uint32  maskValue,
CSL_Status *  pStatus 
)

===========================================================================
SDIO_getStatus

Description
This function reads MMCST0 and MMCST1 registers and returns the value. When mask value is set to 0xFFFFFFFF, value of MMCST0 will be stored in lower 16 bits and value of MMCST1 will be store in upper 16 bits. Value of a particular bit in the passed mask should be set to '1' to read the corresponding bit in the MMC status register.

Arguments

            hSdio          Handle to the SDIO.
            maskValue      Mask value to specify the field.
            pStatus        Status of API Success or Failed.
     

Return Value Uint32 Status - MMCST0 and MMCST1 register value.

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
None

Modifies
None

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   mmcstatus;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            mmcstatus = SDIO_getStatus(hSdio, 0xFFFF, &status);
     

===========================================================================

References CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_init ( void  )

===========================================================================
SDIO_init

Description
This is the initialization function for the SDIO CSL. The function must be called before calling any other API from this CSL. This function is for enabling the clock to the SDIO Controller. This function should be called only once during system initialization time. This function gates the clock for the two MMCSD modules. Application programs may disable the clocks for MMCSD module which is not in use.

NOTE: Calling this function is not required if MMC_init is called since both functions use the same MMCSD controller

Arguments

     

Return Value CSL_Status

  • CSL_SOK - Always returns

Pre Condition
This should be called before calling any other SDIO Function.

Post Condition
Enables clock for MMCSD controller

Modifies
None

Example

            CSL_status       status;

            status = SDIO_init();
     

===========================================================================

References CSL_SDIO_RESET_COUNT.

CSL_Status SDIO_initCard ( CSL_SdioHandle  hSdio,
Uint32  OpCondReg,
Bool  initMem 
)

===========================================================================
SDIO_initCard

Description
This function is used to initialize the SDIO card inserted. This function sends SDIO specification defined command sequence to initialize the SDIO card. Proper OCR value should be sent to this function based on the OCR value received from the card during card detection. SDIO card shall be ready to use after successful execution of this function. This function also supports initializing memory portion of the COMBO SDIO card. Parameter 'initMem' is useful to select(initMem = 1) or skip(initMem = 0) the initialization of COMBO SDIO cards. This function returns with error incase of IO portion or memory(COMBO) portion of the card is not ready.

Arguments

            hSdio        Handle to the SDIO.
            OpCondReg    Operation Conditions Regsiter(OCR) value
            initMem      Flag to select/skip memory initialization
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error
  • CSL_ESDIO_IO_NOTREADY - Card IO is not ready
  • CSL_ESDIO_MEM_NOTREADY - Card memory is not ready

Pre Condition
SDIO_detectCard() API should be called before this function.

Post Condition
Initializes SDIO card

Modifies
SDIO card registers

Example


            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            CSL_SdioCardObj          sdioCardObj;
            Uint32                   ocr;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);
     

===========================================================================

References CSL_SdioCardObj::cardActive, CSL_SdioCardObj::cardReady, CSL_SdioControllerObj::cmd8Resp, CSL_ESDIO_IO_NOTREADY, CSL_ESDIO_MEM_NOTREADY, CSL_SDIO_CMD41_RESP, CSL_SDIO_CMD_3, CSL_SDIO_CMD_41, CSL_SDIO_CMD_41_ARG, CSL_SDIO_CMD_41_HCS_ARG, CSL_SDIO_CMD_5, CSL_SDIO_CMD_55, CSL_SDIO_CMD_7, CSL_SDIO_CMD_RETRY_COUNT, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_COMBO_CARD, CSL_SDIO_EVENT_CARD_EXITBUSY, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_GET_C, CSL_SDIO_LSHIFT, CSL_SDIO_MASK_WORD, CSL_SDIO_RSHIFT, CSL_SDIO_SDHC_RESP, CSL_SDIO_SHIFT_WORD, CSL_SDIO_STUFF_BITS, CSL_SdioControllerObj::pSdioCardObj, CSL_SdioCardObj::rca, CSL_SdioCardObj::sdHcDetected, CSL_SdioCardObj::sdioCardType, and CSL_SdioControllerObj::sdioRegs.

CSL_SdioHandle SDIO_open ( CSL_SdioControllerObj pSdioContObj,
CSL_SdioInstId  instId,
CSL_Status *  status 
)

===========================================================================
SDIO_open

Description
This function opens the CSL SDIO module and returns handle to the SDIO object structure.

NOTE: THIS API SETS THE ENDIAN MODE OF SDIO READ AND WRITE OPERATIONS TO LITTLE ENDIAN. USE SDIO_setEndianMode() TO CHANGE ENDIAN MODE.

Arguments

            pSdioContObj    SDIO Controller object structure
            instId          Instance number for SDIO
            status          Status of the function
     

Return Value CSL_SdioHandle
Valid SDIO handle will be returned if status value is equal to CSL_SOK.

Pre Condition
SDIO_init() API should be called before SDIO_open().

Post Condition
1. The status is returned in the status variable. If status returned is

  • CSL_SOK - Valid SDIO handle is returned
  • CSL_ESYS_INVPARAMS - Resource is already in use
    2. CSL_SdioObj object structure is populated

Modifies
1. Status variable
2. CSL_SdioObj object structure

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio = SDIO_open(&sdioContObj, instId, &status);
            ...
    

===========================================================================

References CSL_SDIO_ENDIAN_LITTLE, CSL_SDIO_INST0, CSL_SDIO_INST1, CSL_SdioControllerObj::readEndianMode, CSL_SdioControllerObj::sdioRegs, and CSL_SdioControllerObj::writeEndianMode.

CSL_Status SDIO_readBlocks ( CSL_SdioHandle  hSdio,
Uint32  readAddr,
Uint8  funNum,
Bool  opCode,
Uint16  noOfBlocks,
Uint16  blockSize,
Uint16 *  pReadBuf 
)

===========================================================================
SDIO_readBlocks

Description
This function reads requested number of blocks of data from SDIO card. 'readAddr' is address on the SDIO card from where the reading starts. Block size of IO function to read data should be configured before calling this function.

Reading of data can be done from a fixed address(opCode = 0) or incrementing address(opCode = 1). Fixed mode data read is useful when I/O data is transferred using a FIFO inside SDIO card. Opcode should be 1 for the SDIO cards which doesn't have support for FIFO.

NOTE: Endian mode of the data transfer depends on the parameter 'readEndianMode' in the SDIO handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during SDIO open. Endian mode can be configured using SDIO_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

Arguments

            hSdio          Handle to the SDIO.
            readAddr       Location to read from.
            funNum         IO function number to read data
            opCode         Bit to decide source address mode
                           - Fixed/Incrementing
            noOfBlocks     Number of blocks to read.
            blockSize      Size of each block
            pReadBuf       pointer to a buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Reads data from the SDIO card

Modifies
readBuffer will be populated.

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   ocr;
            Uint16                   readBuf[512];
            Uint32                   readAddr;
            Uint16                   noOfBlocks;
            Bool                     opCode;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            readAddr   = 0x0;
            noOfBlocks = 2;
            opCode     = 1;
            funNum     = 0;

            status = SDIO_readBlocks(hSdio, readAddr, funNum, opCode,
                                     noOfBlocks, 256, readBuf);
     

===========================================================================

References CSL_SDIO_CMD_53_READ, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_DATA_TOUT_CRC_ERROR, CSL_SDIO_ENDIAN_LITTLE, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_EVENT_ERROR_DATATIMEOUT, CSL_SDIO_MAKE_CMD53_ARG, CSL_SDIO_MASK_BYTE, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_BLOCK_COUNT, CSL_SDIO_MAX_BLOCK_SIZE, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_READ_FIFO_LEVEL, CSL_SDIO_READ_READY, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_BYTE, CSL_SDIO_SHIFT_WORD, CSL_SdioControllerObj::readEndianMode, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_readBytes ( CSL_SdioHandle  hSdio,
Uint32  readAddr,
Uint8  funNum,
Bool  opCode,
Uint16  noOfBytes,
Uint16 *  pReadBuf 
)

===========================================================================
SDIO_readBytes

Description
This function reads requested number of bytes from the SDIO card. 'readAddr' is address on the SDIO card from where the reading starts. This function reads multiple bytes of data from the given address and populates into read buffer. Maximum number of bytes that can be read using this function are 512.

Reading of data can be done from a fixed address(opCode = 0) or incrementing address(opCode = 1). Fixed mode data read is useful when I/O data is transferred using a FIFO inside SDIO card. Opcode should be 1 for the SDIO cards which doesn't have support for FIFO.

NOTE: Endian mode of the data transfer depends on the parameter 'readEndianMode' in the SDIO handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during SDIO open. Endian mode can be configured using SDIO_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

Arguments

            hSdio          Handle to the SDIO.
            readAddr       Location to read from.
            funNum         IO function number to read data
            opCode         Bit to decide source address mode
                             - Fixed/Incrementing
            noOfBytes      no of bytes to read.
            pReadBuf       pointer to a buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Reads data from the SDIO card

Modifies
readBuffer will be populated.

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint16                   rca;
            Uint32                   ocr;
            Uint16                   readBuf[512];
            Uint32                   readAddr;
            Uint16                   noOfBytes;
            Bool                     opCode;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            readAddr  = 0x0;
            noOfBytes = 16;
            opCode    = 1;
            funNum    = 0;

            status = SDIO_readBytes(hSdio, readAddr, funNum, opCode,
                                    noOfBytes, readBuf);
     

===========================================================================

References CSL_SDIO_CMD_53_READ, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_DATA_TOUT_CRC_ERROR, CSL_SDIO_ENDIAN_LITTLE, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_EVENT_ERROR_DATATIMEOUT, CSL_SDIO_MAKE_CMD53_ARG, CSL_SDIO_MASK_BYTE, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_BYTE_COUNT, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_READ_FIFO_LEVEL, CSL_SDIO_READ_READY, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_BYTE, CSL_SDIO_SHIFT_WORD, CSL_SdioControllerObj::readEndianMode, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_readSingleByte ( CSL_SdioHandle  hSdio,
Uint32  readAddr,
Uint8  funNum,
Uint8 *  pReadData 
)

===========================================================================
SDIO_readSingleByte

Description
This function reads a single byte of data from the SDIO card. 'readAddr' is address on the SDIO card from where data byte will be read. Command 52 (IO_RW_DIRECT Command) is used to read the data.

Arguments

            hSdio          Handle to the SDIO.
            readAddr       Location to read from.
            funNum         IO function number to read data
            pReadData      Pointer to populate data read
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Reads a byte of data from the SDIO card

Modifies
Read data pointer will be populated.

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint16                   rca;
            Uint32                   ocr;
            Uint8                    readData;
            Uint32                   readAddr;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            readAddr  = 0x0;
            funNum    = 0;

            status = SDIO_readSingleByte(hSdio, readAddr, funNum, &readData);
     

===========================================================================

References CSL_SDIO_CMD_52, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_MAKE_CMD52_READ_ARG, CSL_SDIO_MASK_BYTE, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_readWaitDisable ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_readWaitDisable

Description
This function is used to disable SDIO read-wait bit in SDIO control register.

Arguments

            hSdio             Handle to the SDIO.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
Disables the sdio read-wait

Modifies
SDIO control Register

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_readWaitDisable(hSdio);
     

===========================================================================

References CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_readWaitEnable ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_readWaitEnable

Description
This function is used to enable SDIO read-wait bit in SDIO control register.

Arguments

            hSdio             Handle to the SDIO.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
Enables the sdio read-wait

Modifies
SDIO control Register

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_readWaitEnable(hSdio);
     

===========================================================================

References CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_resetCard ( CSL_SdioHandle  hSdio)

===========================================================================
SDIO_resetCard

Description
This function is used to reset the SDIO card. This function uses CMD52 to reset SDIO card. After execution of this function SDIO card will not receive any commands except CMD5.

Arguments

            hSdio              Handle to the SDIO.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
SDIO_open() API should be called before this function.

Post Condition
Resets SDIO card

Modifies
SDIO card registers

Example


            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_resetCard(hSdio);
     

===========================================================================

References CSL_SDIO_CMD_52, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_MAKE_CMD52_WRITE_ARG, CSL_SDIO_MASK_WORD, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_selectCard ( CSL_SdioHandle  hSdio,
Uint16  rca 
)

===========================================================================
SDIO_selectCard

Description
This function is used to select SDIO card. CMD7 shall be sent to the SDIO card along with the relative card address to select the card. RCA value should be the one published by the card. Sending CMD7 with invalid RCA will put the card into standby/disabled state.

Arguments

            hSdio      Handle to the SDIO.
            rca        Relative card address.
     

Return Value CSL_Status

  • CSL_SOK - successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called.

Post Condition
Selects the SDIO card

Modifies
rca

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint16                   rca;
            Uint32                   ocr;
            CSL_SdioCardObj          sdioCardObj;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            rca = sdioCardObj.rca;

            status = SDIO_initCard(hSdio, ocr, TRUE);

            status = SDIO_selectCard(hSdio, rca);

     

===========================================================================

References CSL_SdioCardObj::cardActive, CSL_SDIO_CMD_7, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_CARD_EXITBUSY, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_STUFF_BITS, CSL_SdioControllerObj::pSdioCardObj, CSL_SdioCardObj::rca, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_sendCommand ( CSL_SdioHandle  hSdio,
Uint32  cmd,
Uint32  arg,
Uint16  respTimeout 
)

===========================================================================
SDIO_sendCommand

Description
This function is used to send commands to the SDIO card. This function sends given command to the card and waits for the response. Lower 16 bits of the parameter 'cmd' should contain the command that needs to be written to MMCCMD1 register. Upper 16 bits of the 'cmd' should contain the data that needs to be written to MMCCMD2 register.

NOTE:SETTING THE MMCCMD2 VALUE TO '1' IS ALLOWED ONLY FOR DATA WRITE COMMANDS THAT USES DMA FOR DATA TRANSFER. FOR OTHER COMMANDS UPPER 16 BITS OF 'CMD' SHOULD ALWAYS BE ZERO.

Arguments

            hSdio          Handle to the SDIO.
            cmd            MMCCMD1 and MMCCMD2 register value.
            arg            Command argument.
            respTimeout    Timeout value for the response.
     

Return Value CSL_Status

  • CSL_SOK - Successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
SDIO_open() API should be called successfully.

Post Condition
Sends command to the card

Modifies
Card Command registers

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   cmd;
            Uint32                   arg;
            Uint16                   respTimeout;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            //Send Command 5
            cmd         = 0x205;
            arg         = 0;
            respTimeout = 0xFFFF;
            status = SDIO_sendCommand(hSdio, cmd, arg, respTimeout);
     

===========================================================================

References CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_MASK_WORD, CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_setClock ( CSL_SdioHandle  hSdio,
Uint16  clockRate 
)

===========================================================================
SDIO_setClock

Description
This function is used to set SDIO controller clock divider value. Clock controller register bits are configured by this function. Clock rate or clock divider value can range from 0 to 0xFF.

Arguments

            hSdio        Handle to the SDIO.
            clockRate    Value of clock rate
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters

Pre Condition
SDIO_open() function should be called successfully

Post Condition
Sets SDIO clock

Modifies
SDIO clock control register

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_setClock(hSdio, 5);
    

===========================================================================

References CSL_SDIO_MAX_CLKRATE, and CSL_SdioControllerObj::sdioRegs.

CSL_Status SDIO_setEndianMode ( CSL_SdioHandle  hSdio,
CSL_SdioEndianMode  writeEndianMode,
CSL_SdioEndianMode  readEndianMode 
)

===========================================================================
SDIO_setEndianMode

Description
This function is used to set endian mode of the SDIO controller. Endian mode set using this API decides the way in which data is transferred from FIFO to storage device.

Default endianness of SDIO controller: Chip C5504 and C5505: LITTLE ENDIAN. Chip C5514 and C5515: BIG ENDIAN.

Arguments

            hSdio              Handle to the SDIO.
            writeEndianMode    Endian mode for SDIO write operation
            readEndianMode     Endian mode for SDIO read operation
     

Return Value

  • CSL_SOK - Returned for Success
  • CSL_ESYS_BADHANDLE - Invalid MMSDC handle
  • CSL_ESYS_INVPARAMS - Invalid input parameters

Pre Condition
SDIO_open() function should be called successfully

Post Condition
Sets SDIO endian mode for write and read operations

Modifies
SDIO control register

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_setEndianMode(hSdio, CSL_SDIO_ENDIAN_LITTLE,
                                        CSL_SDIO_ENDIAN_LITTLE);
            ...
    

===========================================================================

References CSL_SDIO_ENDIAN_BIG, CSL_SDIO_ENDIAN_LITTLE, CSL_SdioControllerObj::readEndianMode, CSL_SdioControllerObj::sdioRegs, and CSL_SdioControllerObj::writeEndianMode.

CSL_Status SDIO_writeBlocks ( CSL_SdioHandle  hSdio,
Uint32  writeAddr,
Uint8  funNum,
Bool  opCode,
Uint16  noOfBlocks,
Uint16  blockSize,
Uint16 *  pWriteBuf 
)

===========================================================================
SDIO_writeBlocks

Description
This function writes requested number of blocks of data to SDIO card. 'writeAddr' is address on the SDIO card from where the writing starts. Block size of IO function to write data should be configured before calling this function.

Writing of data can be done to a fixed address(opCode = 0) or incrementing address(opCode = 1). Fixed mode data write is useful when I/O data is transferred using a FIFO inside SDIO card. Opcode should be 1 for the SDIO cards which doesn't have support for FIFO.

NOTE: Endian mode of the data transfer depends on the parameter 'writeEndianMode' in the SDIO handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during SDIO open. Endian mode can be configured using SDIO_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

Arguments

            hSdio          Handle to the SDIO.
            writeAddr      Location to write to.
            funNum         IO function number to write data
            opCode         Bit to decide destination address mode
                             - Fixed/Incrementing
            noOfBlocks     Number of blocks to write.
            blockSize      Size of each block
            pWriteBuf      Pointer to write buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Writes data to the SDIO card

Modifies
Data registers

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   ocr;
            Uint16                   writeBuf[512];
            Uint32                   writeAddr;
            Uint16                   noOfBlocks;
            Bool                     opCode;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            writeAddr  = 0x110;
            noOfBlocks = 2;
            opCode     = 1;
            funNum     = 0;

            status = SDIO_writeBlocks(hSdio, writeAddr, funNum, opCode,
                                      noOfBlocks, 256, writeBuf);
     

===========================================================================

References CSL_SDIO_CMD_53_WRITE, CSL_SDIO_ENDIAN_LITTLE, CSL_SDIO_EVENT_BLOCK_XFERRED, CSL_SDIO_EVENT_ERROR, CSL_SDIO_EVENT_ERROR_DATACRC, CSL_SDIO_MAKE_CMD53_ARG, CSL_SDIO_MASK_BYTE, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_BLOCK_COUNT, CSL_SDIO_MAX_BLOCK_SIZE, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_BYTE, CSL_SDIO_SHIFT_WORD, CSL_SDIO_WRITE_FIFO_LEVEL, CSL_SDIO_WRITE_READY, CSL_SdioControllerObj::readEndianMode, CSL_SdioControllerObj::sdioRegs, and CSL_SdioControllerObj::writeEndianMode.

CSL_Status SDIO_writeBytes ( CSL_SdioHandle  hSdio,
Uint32  writeAddr,
Uint8  funNum,
Bool  opCode,
Uint16  noOfBytes,
Uint16 *  pWriteBuf 
)

===========================================================================
SDIO_writeBytes

Description
This function writes requested number of bytes to the SDIO card. 'writeAddr' is address on the SDIO card from where the writing starts. Maximum length of the data that can be written using this function is 512 bytes.

Writing of data can be done to a fixed address(opCode = 0) or incrementing address(opCode = 1). Fixed mode data write is useful when I/O data is transferred using a FIFO inside SDIO card. Opcode should be 1 for the SDIO cards which doesn't have support for FIFO.

NOTE: Endian mode of the data transfer depends on the parameter 'writeEndianMode' in the SDIO handle. Default value for the endian mode is 'LITTLE ENDIAN' which will be set during SDIO open. Endian mode can be configured using SDIO_setEndianMode(). DO NOT CHANGE THE ENDIAN MODE WITH OUT USING THIS API.

Arguments

            hSdio          Handle to the SDIO.
            writeAddr      Location to write to.
            funNum         IO function number to write data
            opCode         Bit to decide destination address mode
                             - Fixed/Incrementing
            noOfBytes      Number of bytes to write.
            pWriteBuf      Pointer to write buffer.
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Writes data to the SDIO card

Modifies
Data registers

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint32                   ocr;
            Uint16                   writeBuf[512];
            Uint32                   writeAddr;
            Uint16                   noOfBytes;
            Bool                     opCode;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            writeAddr  = 0x07;
            noOfBytes  = 1;
            opCode     = 1;
            funNum     = 0;

            status = SDIO_writeBytes(hSdio, writeAddr, funNum, opCode,
                                     noOfBytes, writeBuf);
     

===========================================================================

References CSL_SDIO_CMD_53_WRITE, CSL_SDIO_ENDIAN_LITTLE, CSL_SDIO_EVENT_BLOCK_XFERRED, CSL_SDIO_EVENT_ERROR, CSL_SDIO_EVENT_ERROR_DATACRC, CSL_SDIO_MAKE_CMD53_ARG, CSL_SDIO_MASK_BYTE, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_BYTE_COUNT, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_BYTE, CSL_SDIO_SHIFT_WORD, CSL_SDIO_WRITE_FIFO_LEVEL, CSL_SDIO_WRITE_READY, CSL_SdioControllerObj::readEndianMode, CSL_SdioControllerObj::sdioRegs, and CSL_SdioControllerObj::writeEndianMode.

CSL_Status SDIO_writeSingleByte ( CSL_SdioHandle  hSdio,
Uint32  writeAddr,
Uint8  funNum,
Uint8  writeData 
)

===========================================================================
SDIO_writeSingleByte

Description
This function writes a single byte of data to the SDIO card. 'writeAddr' is address on the SDIO card to where data byte will be written. Command 52 (IO_RW_DIRECT Command) is used to write the data.

Arguments

            hSdio          Handle to the SDIO.
            writeAddr      Location to write data byte.
            funNum         IO function number to read data
            writeData      Data to be written
     

Return Value CSL_Status

  • CSL_SOK - Close successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid Parameter
  • CSL_ESDIO_TIMEOUT - Card Response time out
  • CSL_ESDIO_CRCERR - Response/Data CRC Error

Pre Condition
1:SDIO_open() API should be called successfully.
2:SDIO_initCard() API should be called successfully.

Post Condition
Writes a byte of data to the SDIO card

Modifies
SDIO card registers

Example

            CSL_SdioControllerObj    sdioContObj;
            CSL_SdioHandle           hSdio;
            CSL_SdioInstId           instId;
            CSL_status               status;
            Uint16                   rca;
            Uint32                   ocr;
            Uint8                    writeData;
            Uint32                   writeAddr;
            Uint8                    funNum;

            instId = CSL_SDIO_INST0;

            status = SDIO_init();

            hSdio  = SDIO_open(&sdioContObj, instId, &status);

            status = SDIO_detectCard(hSdio, &sdioCardObj);

            status = SDIO_initCard(hSdio, ocr, TRUE);

            writeAddr  = 0x02;
            writeData  = 0x02;
            funNum     = 0;

            status = SDIO_writeSingleByte(hSdio, writeAddr, funNum, writeData);
     

===========================================================================

References CSL_SDIO_CMD_52, CSL_SDIO_CMD_TOUT_CRC_ERROR, CSL_SDIO_EVENT_EOFCMD, CSL_SDIO_EVENT_ERROR_CMDTIMEOUT, CSL_SDIO_MAKE_CMD52_WRITE_ARG, CSL_SDIO_MASK_WORD, CSL_SDIO_MAX_FUNCTION_COUNT, CSL_SDIO_RSHIFT, CSL_SDIO_SHIFT_WORD, and CSL_SdioControllerObj::sdioRegs.