...
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.