Enabled 4 bits mode enabling in the SDC driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2944 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
4e00ffa69c
commit
539fc8bfc3
|
@ -40,6 +40,7 @@
|
||||||
#define SDC_CMD_GO_IDLE_STATE 0
|
#define SDC_CMD_GO_IDLE_STATE 0
|
||||||
#define SDC_CMD_ALL_SEND_CID 2
|
#define SDC_CMD_ALL_SEND_CID 2
|
||||||
#define SDC_CMD_SEND_RELATIVE_ADDR 3
|
#define SDC_CMD_SEND_RELATIVE_ADDR 3
|
||||||
|
#define SDC_CMD_SET_BUS_WIDTH 6
|
||||||
#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
|
||||||
|
|
|
@ -148,6 +148,10 @@ struct SDCDriver {
|
||||||
* @brief Card CSD.
|
* @brief Card CSD.
|
||||||
*/
|
*/
|
||||||
uint32_t csd[4];
|
uint32_t csd[4];
|
||||||
|
/**
|
||||||
|
* @brief Card RCA.
|
||||||
|
*/
|
||||||
|
uint32_t rca;
|
||||||
/* End of the mandatory fields.*/
|
/* End of the mandatory fields.*/
|
||||||
/**
|
/**
|
||||||
* @brief Tthread waiting for I/O completion IRQ.
|
* @brief Tthread waiting for I/O completion IRQ.
|
||||||
|
|
|
@ -173,7 +173,7 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
chThdSleepMilliseconds(10);
|
chThdSleepMilliseconds(10);
|
||||||
if (sdc_lld_send_cmd_short_crc(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;
|
||||||
if ((resp[0] & 0x80000000) != 0) {
|
if ((resp[0] & 0x80000000) != 0) {
|
||||||
|
@ -191,18 +191,18 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* Asks for the RCA.*/
|
/* Asks for the RCA.*/
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEND_RELATIVE_ADDR, 0, resp))
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEND_RELATIVE_ADDR, 0, &sdcp->rca))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* Reads CSD.*/
|
/* Reads CSD.*/
|
||||||
if (sdc_lld_send_cmd_long_crc(sdcp, SDC_CMD_SEND_CSD, resp[0], sdcp->csd))
|
if (sdc_lld_send_cmd_long_crc(sdcp, SDC_CMD_SEND_CSD, sdcp->rca, sdcp->csd))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* Switches to high speed.*/
|
/* Switches to high speed.*/
|
||||||
sdc_lld_set_data_clk(sdcp);
|
sdc_lld_set_data_clk(sdcp);
|
||||||
|
|
||||||
/* Selects the card for operations.*/
|
/* Selects the card for operations.*/
|
||||||
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, sdcp->rca, resp))
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* Block length fixed at 512 bytes.*/
|
/* Block length fixed at 512 bytes.*/
|
||||||
|
@ -211,11 +211,17 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
/* Switches to wide bus mode.*/
|
/* Switches to wide bus mode.*/
|
||||||
/* switch (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) {
|
switch (sdcp->cardmode & SDC_MODE_CARDTYPE_MASK) {
|
||||||
case SDC_MODE_CARDTYPE_SDV11:
|
case SDC_MODE_CARDTYPE_SDV11:
|
||||||
case SDC_MODE_CARDTYPE_SDV20:
|
case SDC_MODE_CARDTYPE_SDV20:
|
||||||
SDIO->CLKCR |= SDIO_CLKCR_WIDBUS_0;
|
sdc_lld_set_bus_mode(sdcp, SDC_MODE_4BIT);
|
||||||
}*/
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_APP_CMD, sdcp->rca, resp) ||
|
||||||
|
(resp[0] & SDC_R1_ERROR_MASK))
|
||||||
|
goto failed;
|
||||||
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SET_BUS_WIDTH, 2, resp) ||
|
||||||
|
(resp[0] & SDC_R1_ERROR_MASK))
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
sdcp->state = SDC_ACTIVE;
|
sdcp->state = SDC_ACTIVE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue