aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-05-07 19:33:47 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-05-07 19:33:47 +0000
commitd12cc995d567ff3c43af6e33a9eee5259c95e287 (patch)
tree7643604482769414b275d08c3cd2f7ce343af655
parent6dc70a8453a1a2b5953330dcd688f2121ad62732 (diff)
downloadChibiOS-d12cc995d567ff3c43af6e33a9eee5259c95e287.tar.gz
ChibiOS-d12cc995d567ff3c43af6e33a9eee5259c95e287.tar.bz2
ChibiOS-d12cc995d567ff3c43af6e33a9eee5259c95e287.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2925 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/platforms/STM32/sdc_lld.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/os/hal/platforms/STM32/sdc_lld.c b/os/hal/platforms/STM32/sdc_lld.c
index cb6eb2099..1697c2964 100644
--- a/os/hal/platforms/STM32/sdc_lld.c
+++ b/os/hal/platforms/STM32/sdc_lld.c
@@ -59,6 +59,16 @@ CH_IRQ_HANDLER(SDIO_IRQHandler) {
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();
}
@@ -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,
uint8_t *buf, uint32_t n) {
- msg_t msg;
- uint32_t sts, resp[1];
+ uint32_t sta, resp[1];
/* Prepares the DMA channel for reading.*/
dmaChannelSetup(&STM32_DMA2->channels[STM32_DMA_CHANNEL_4],
@@ -349,11 +358,24 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
goto error;
chSysLock();
- chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #1", "not NULL");
- sdcp->thread = chThdSelf();
- chSchGoSleepS(THD_STATE_SUSPENDED);
- chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #2", "not NULL");
- msg = chThdSelf()->p_u.rdymsg;
+ sta = SDIO->STA;
+ if ((sta & SDIO_STA_DCRCFAIL | SDIO_STA_DTIMEOUT |
+ SDIO_STA_DATAEND | SDIO_STA_STBITERR) == 0) {
+ chDbgAssert(sdcp->thread == NULL, "sdc_lld_read_blocks(), #1", "not NULL");
+ 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();
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION, 0, resp))