git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2909 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
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.
|
* @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] sdcp pointer to the @p SDCDriver object
|
||||||
* @param[in[ cmd card command
|
* @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 *resp) {
|
||||||
uint32_t sta;
|
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;
|
(void)sdcp;
|
||||||
SDIO->ARG = arg;
|
SDIO->ARG = arg;
|
||||||
SDIO->CMD = (uint32_t)cmd | SDIO_CMD_WAITRESP_0 | SDIO_CMD_CPSMEN;
|
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] sdcp pointer to the @p SDCDriver object
|
||||||
* @param[in[ cmd card command
|
* @param[in[ cmd card command
|
||||||
|
@ -249,8 +281,8 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
*
|
*
|
||||||
* @notapi
|
* @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 *resp) {
|
||||||
|
|
||||||
uint32_t sta;
|
uint32_t sta;
|
||||||
|
|
||||||
|
|
|
@ -160,8 +160,10 @@ extern "C" {
|
||||||
void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg);
|
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,
|
bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
uint32_t *resp);
|
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);
|
uint32_t *resp);
|
||||||
|
bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
|
uint32_t *resp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -146,17 +146,17 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
sdc_lld_send_cmd_none(sdcp, SDC_CMD_GO_IDLE_STATE, 0);
|
sdc_lld_send_cmd_none(sdcp, SDC_CMD_GO_IDLE_STATE, 0);
|
||||||
|
|
||||||
/* V2.0 cards detection.*/
|
/* 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))
|
SDC_CMD8_PATTERN, &resp))
|
||||||
sdcp->cardmode |= SDC_MODE_CARDTYPE_SDV20;
|
sdcp->cardmode |= SDC_MODE_CARDTYPE_SDV20;
|
||||||
/* Voltage verification.*/
|
/* Voltage verification.*/
|
||||||
if (((resp >> 8) & 0xF) != 1)
|
if (((resp >> 8) & 0xF) != 1)
|
||||||
goto failed;
|
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;
|
goto failed;
|
||||||
else {
|
else {
|
||||||
/* MMC or SD detection.*/
|
/* 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;
|
sdcp->cardmode |= SDC_MODE_CARDTYPE_MMC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
chThdSleepMilliseconds(10);
|
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;
|
goto failed;
|
||||||
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_OP_COND, ocr, &resp))
|
if (sdc_lld_send_cmd_short(sdcp, SDC_CMD_APP_OP_COND, ocr, &resp))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
Loading…
Reference in New Issue