git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2925 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2011-05-07 19:33:47 +00:00
parent 6dc70a8453
commit d12cc995d5
1 changed files with 29 additions and 7 deletions

View File

@ -59,6 +59,16 @@ CH_IRQ_HANDLER(SDIO_IRQHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
chSysLockFromIsr();
if (SDCD1.thread != NULL) {
if ((SDIO->STA & SDIO_STA_DATAEND) != 0)
SDCD1.thread->p_u.rdymsg = RDY_OK;
else
SDCD1.thread->p_u.rdymsg = RDY_RESET;
chSchReadyI(SDCD1.thread);
SDCD1.thread = NULL;
}
chSysUnlockFromIsr();
CH_IRQ_EPILOGUE(); CH_IRQ_EPILOGUE();
} }
@ -320,8 +330,7 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
*/ */
bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk, bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
uint8_t *buf, uint32_t n) { uint8_t *buf, uint32_t n) {
msg_t msg; uint32_t sta, resp[1];
uint32_t sts, resp[1];
/* Prepares the DMA channel for reading.*/ /* Prepares the DMA channel for reading.*/
dmaChannelSetup(&STM32_DMA2->channels[STM32_DMA_CHANNEL_4], dmaChannelSetup(&STM32_DMA2->channels[STM32_DMA_CHANNEL_4],
@ -349,11 +358,24 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
goto error; goto error;
chSysLock(); chSysLock();
chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #1", "not NULL"); sta = SDIO->STA;
sdcp->thread = chThdSelf(); if ((sta & SDIO_STA_DCRCFAIL | SDIO_STA_DTIMEOUT |
chSchGoSleepS(THD_STATE_SUSPENDED); SDIO_STA_DATAEND | SDIO_STA_STBITERR) == 0) {
chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #2", "not NULL"); chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #1", "not NULL");
msg = chThdSelf()->p_u.rdymsg; sdcp->thread = chThdSelf();
chSchGoSleepS(THD_STATE_SUSPENDED);
chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #2", "not NULL");
if (chThdSelf()->p_u.rdymsg != RDY_OK) {
chSysUnlock();
goto error;
}
}
else {
if ((sta & SDIO_STA_DATAEND) == 0) {
chSysUnlock();
goto error;
}
}
chSysUnlock(); chSysUnlock();
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION, 0, resp)) if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION, 0, resp))