/* Checks for error conditions for R2 (CID or CSD) response.  */
static SD_Error CmdResp2Error(void)
/* Checks for error conditions for R2 (CID or CSD) response.  */
static SD_Error CmdResp2Error(void)
{
	SD_Error errorstatus = SD_OK;
	uint32_t status;
	status = SDIO ->STA;
	while (!(status & (SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CTIMEOUT | SDIO_FLAG_CMDREND))) {
		status = SDIO ->STA;
	}
	if (status & SDIO_FLAG_CTIMEOUT) {
		errorstatus = SD_CMD_RSP_TIMEOUT;
		SDIO->ICR =  (SDIO_FLAG_CTIMEOUT);
		return (errorstatus);
	} else if (status & SDIO_FLAG_CCRCFAIL) {
		errorstatus = SD_CMD_CRC_FAIL;
		SDIO->ICR =  (SDIO_FLAG_CCRCFAIL);
		return (errorstatus);
	}
	SDIO->ICR =  (SDIO_STATIC_FLAGS );
	return (errorstatus);
}