void FSDev_SD_Card_BSP_CmdWaitEnd (FS_QTY unit_nbr,
FS_DEV_SD_CARD_CMD *p_cmd,
CPU_INT32U *p_resp,
FS_DEV_SD_CARD_ERR *p_err);
File |
Called from |
Code enabled by |
|
SD/MMC cardmode driver |
N/A |
Wait for command to end and get command response.
Arguments
unit_nbr
Unit number of SD/MMC card.
p_cmd
Pointer to command that is ending.
p_resp
Pointer to buffer that will receive command response, if any.
p_err
Pointer to variable that will receive the return error code from this function:
FS_DEV_SD_CARD_ERR_NONE
No error.
FS_DEV_SD_CARD_ERR_NO_CARD
No card present.
FS_DEV_SD_CARD_ERR_UNKNOWN
Unknown or other error.
FS_DEV_SD_CARD_ERR_WAIT_TIMEOUT
Timeout in waiting for command response.
FS_DEV_SD_CARD_ERR_RESP_TIMEOUT
Timeout in receiving command response.
FS_DEV_SD_CARD_ERR_RESP_CHKSUM
Error in response checksum.
FS_DEV_SD_CARD_ERR_RESP_CMD_IX
Response command index error.
FS_DEV_SD_CARD_ERR_RESP_END_BIT
Response end bit error.
FS_DEV_SD_CARD_ERR_RESP
Other response error.
FS_DEV_SD_CARD_ERR_DATA
Other data error.
Returned Value
None.
Notes/Warnings
FSDev_SD_Card_BSP_CmdStart()
returned an error.p_resp
.p_resp
:The first 4-byte word should hold bits 127..96 of the response.
The second 4-byte word should hold bits 95..64 of the response.
The third 4-byte word should hold bits 63..32 of the response.
The four 4-byte word should hold bits 31.. 0 of the response.
Example
The implementation of FSDev_SD_Card_BSP_CmdWaitEnd()
in is targeted for the same host controller as the other listings in this chapter; for more information, see FSDev_SD_Card_BSP_CmdStart()
.
Listing C-8 FSDev_SD_Card_BSP_CmdWaitEnd()
LC-8(1) Wait until command execution completes or an error occurs. The wait loop (or wait on semaphore) should always have a timeout to avoid blocking the task in the case of an unforeseen hardware malfunction or a software flaw.
LC-8(2) Check if an error occurred. The error status register is decoded to produce the actual error condition. That is not necessary, strictly, but error counters that accumulate within the generic driver based upon returned error values may be useful while debugging a port.
LC-8(3) Read the response, if any. Note that the order in which a long response is stored in the buffer may oppose its storage in the controller’s register or FIFO.