git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2909 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
40c7b22bf4
commit
d5fb75afc4
|
@ -206,6 +206,7 @@ void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {
|
|||
|
||||
/**
|
||||
* @brief Sends an SDIO command with a short response expected.
|
||||
* @note The CRC is not verified.
|
||||
*
|
||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||
* @param[in[ cmd card command
|
||||
|
@ -222,6 +223,37 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
|||
uint32_t *resp) {
|
||||
uint32_t sta;
|
||||
|
||||
(void)sdcp;
|
||||
SDIO->ARG = arg;
|
||||
SDIO->CMD = (uint32_t)cmd | SDIO_CMD_WAITRESP_0 | SDIO_CMD_CPSMEN;
|
||||
while (((sta = SDIO->STA) & (SDIO_STA_CMDREND | SDIO_STA_CTIMEOUT |
|
||||
SDIO_STA_CCRCFAIL)) == 0)
|
||||
;
|
||||
SDIO->ICR = 0xFFFFFFFF;
|
||||
if ((sta & (SDIO_STA_CTIMEOUT)) != 0)
|
||||
return TRUE;
|
||||
*resp = SDIO->RESP1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sends an SDIO command with a short response expected and CRC.
|
||||
*
|
||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||
* @param[in[ cmd card command
|
||||
* @param[in] arg command argument
|
||||
* @param[out] resp pointer to the response buffer (one word)
|
||||
* @return The operation status.
|
||||
* @retval FALSE the operation succeeded.
|
||||
* @retval TRUE the operation failed because timeout, CRC check or
|
||||
* other errors.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
uint32_t *resp) {
|
||||
uint32_t sta;
|
||||
|
||||
(void)sdcp;
|
||||
SDIO->ARG = arg;
|
||||
SDIO->CMD = (uint32_t)cmd | SDIO_CMD_WAITRESP_0 | SDIO_CMD_CPSMEN;
|
||||
|
@ -236,7 +268,7 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Sends an SDIO command with a long response expected.
|
||||
* @brief Sends an SDIO command with a long response expected and CRC.
|
||||
*
|
||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||
* @param[in[ cmd card command
|
||||
|
@ -249,7 +281,7 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
|||
*
|
||||
* @notapi
|
||||
*/
|
||||
bool_t sdc_lld_send_cmd_long(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
uint32_t *resp) {
|
||||
|
||||
uint32_t sta;
|
||||
|
|
|
@ -160,7 +160,9 @@ extern "C" {
|
|||
void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg);
|
||||
bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
uint32_t *resp);
|
||||
bool_t sdc_lld_send_cmd_long(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
uint32_t *resp);
|
||||
bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||
uint32_t *resp);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -146,17 +146,17 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
|||
sdc_lld_send_cmd_none(sdcp, SDC_CMD_GO_IDLE_STATE, 0);
|
||||
|
||||
/* V2.0 cards detection.*/
|
||||
if (!sdc_lld_send_cmd_short(sdcp, SDC_CMD_SEND_IF_COND,
|
||||
if (!sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEND_IF_COND,
|
||||
SDC_CMD8_PATTERN, &resp))
|
||||
sdcp->cardmode |= SDC_MODE_CARDTYPE_SDV20;
|
||||
/* Voltage verification.*/
|
||||
if (((resp >> 8) & 0xF) != 1)
|
||||
goto failed;
|
||||
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
goto failed;
|
||||
else {
|
||||
/* MMC or SD detection.*/
|
||||
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
sdcp->cardmode |= SDC_MODE_CARDTYPE_MMC;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
|||
i = 0;
|
||||
while (TRUE) {
|
||||
chThdSleepMilliseconds(10);
|
||||
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_APP_CMD, 0, &resp))
|
||||
goto failed;
|
||||
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_OP_COND, ocr, &resp))
|
||||
goto failed;
|
||||
|
|
Loading…
Reference in New Issue