SDC card initialization works.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2911 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
b33b5201ad
commit
82b9e1cf4c
|
@ -41,13 +41,15 @@
|
||||||
#define SDC_CMD_SEL_DESEL_CARD 7
|
#define SDC_CMD_SEL_DESEL_CARD 7
|
||||||
#define SDC_CMD_SEND_IF_COND 8
|
#define SDC_CMD_SEND_IF_COND 8
|
||||||
#define SDC_CMD_SEND_CSD 9
|
#define SDC_CMD_SEND_CSD 9
|
||||||
|
#define SDC_CMD_SET_BLOCKLEN 16
|
||||||
#define SDC_CMD_APP_OP_COND 41
|
#define SDC_CMD_APP_OP_COND 41
|
||||||
#define SDC_CMD_APP_CMD 55
|
#define SDC_CMD_APP_CMD 55
|
||||||
|
|
||||||
#define SDC_MODE_CARDTYPE_MASK 0xF
|
#define SDC_MODE_CARDTYPE_MASK 0xF
|
||||||
#define SDC_MODE_CARDTYPE_SDV11 0 /**< Card is V1.1 compliant. */
|
#define SDC_MODE_CARDTYPE_SDV11 0 /**< Card is V1.1 compliant. */
|
||||||
#define SDC_MODE_CARDTYPE_SDV20 1 /**< Card is V2.0 compliant. */
|
#define SDC_MODE_CARDTYPE_SDV20 1 /**< Card is V2.0 compliant. */
|
||||||
#define SDC_MODE_CARDTYPE_MMC 2 /**< Card is MMC compliant. */
|
#define SDC_MODE_CARDTYPE_MMC 2 /**< Card is MMC compliant. */
|
||||||
|
#define SDC_MODE_HIGH_CAPACITY 0x10 /**< High capacity card. */
|
||||||
|
|
||||||
#define SDC_CMD8_PATTERN 0x000001AA
|
#define SDC_CMD8_PATTERN 0x000001AA
|
||||||
|
|
||||||
|
|
|
@ -176,8 +176,11 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
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;
|
||||||
if ((resp[0] & 0x80000000) != 0)
|
if ((resp[0] & 0x80000000) != 0) {
|
||||||
|
if (resp[0] & 0x40000000)
|
||||||
|
sdcp->cardmode |= SDC_MODE_HIGH_CAPACITY;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (++i >= SDC_ACMD41_RETRY)
|
if (++i >= SDC_ACMD41_RETRY)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
@ -202,6 +205,17 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEL_DESEL_CARD, resp[0], resp))
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEL_DESEL_CARD, resp[0], resp))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
/* Block lenght fixed at 512 bytes.*/
|
||||||
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SET_BLOCKLEN, 512, resp))
|
||||||
|
goto failed;
|
||||||
|
|
||||||
|
/* Switches to wide bus mode.*/
|
||||||
|
switch (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) {
|
||||||
|
case SDC_MODE_CARDTYPE_SDV11:
|
||||||
|
case SDC_MODE_CARDTYPE_SDV20:
|
||||||
|
SDIO->CLKCR |= SDIO_CLKCR_WIDBUS_0;
|
||||||
|
}
|
||||||
|
|
||||||
sdcp->state = SDC_ACTIVE;
|
sdcp->state = SDC_ACTIVE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
failed:
|
failed:
|
||||||
|
@ -228,6 +242,7 @@ bool_t sdcDisconnect(SDCDriver *sdcp) {
|
||||||
chSysLock();
|
chSysLock();
|
||||||
chDbgAssert(sdcp->state == SDC_ACTIVE,
|
chDbgAssert(sdcp->state == SDC_ACTIVE,
|
||||||
"sdcDisconnect(), #1", "invalid state");
|
"sdcDisconnect(), #1", "invalid state");
|
||||||
|
sdc_lld_stop_clk(sdcp);
|
||||||
sdcp->state = SDC_READY;
|
sdcp->state = SDC_READY;
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue