diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-05-02 19:49:35 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-05-02 19:49:35 +0000 |
commit | f6ed2f2a8427129c0d24dee81536dbcedaf2d793 (patch) | |
tree | fafc7709771520163186d980bb1b29c406f186ad /os/hal | |
parent | 31456cb4fea72d79b9c1af9a5b0cc7e3fed1ed6e (diff) | |
download | ChibiOS-f6ed2f2a8427129c0d24dee81536dbcedaf2d793.tar.gz ChibiOS-f6ed2f2a8427129c0d24dee81536dbcedaf2d793.tar.bz2 ChibiOS-f6ed2f2a8427129c0d24dee81536dbcedaf2d793.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2916 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/platforms/STM32/sdc_lld.c | 13 | ||||
-rw-r--r-- | os/hal/platforms/STM32/sdc_lld.h | 4 | ||||
-rw-r--r-- | os/hal/src/sdc.c | 8 |
3 files changed, 19 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/sdc_lld.c b/os/hal/platforms/STM32/sdc_lld.c index b289da8ba..43493d8dd 100644 --- a/os/hal/platforms/STM32/sdc_lld.c +++ b/os/hal/platforms/STM32/sdc_lld.c @@ -75,6 +75,7 @@ CH_IRQ_HANDLER(SDIO_IRQHandler) { void sdc_lld_init(void) {
sdcObjectInit(&SDCD1);
+ SDCD1.thread = NULL;
}
/**
@@ -315,8 +316,16 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg, * @notapi
*/
bool_t sdc_lld_read_blocks(SDCDriver *sdcp, uint8_t *buf, uint32_t n) {
-
- return TRUE;
+ msg_t msg;
+
+ 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;
+ chSysUnlock();
+ return msg != RDY_OK;
}
/**
diff --git a/os/hal/platforms/STM32/sdc_lld.h b/os/hal/platforms/STM32/sdc_lld.h index 349c1df95..4b27b92c1 100644 --- a/os/hal/platforms/STM32/sdc_lld.h +++ b/os/hal/platforms/STM32/sdc_lld.h @@ -141,6 +141,10 @@ struct SDCDriver { */
uint32_t csd[4];
/* End of the mandatory fields.*/
+ /**
+ * @brief Tthread waiting for I/O completion IRQ.
+ */
+ Thread *thread;
};
/*===========================================================================*/
diff --git a/os/hal/src/sdc.c b/os/hal/src/sdc.c index 847647de4..3188afb64 100644 --- a/os/hal/src/sdc.c +++ b/os/hal/src/sdc.c @@ -270,7 +270,7 @@ bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk, bool_t sts;
uint32_t resp[1];
- chDbgCheck((sdcp != NULL) && (buffer != NULL) && (n > 0), "sdcRead");
+ chDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0), "sdcRead");
if ((sdcp->cardmode & SDC_MODE_HIGH_CAPACITY) == 0)
startblk *= SDC_BLOCK_SIZE;
@@ -279,7 +279,7 @@ bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk, startblk, resp))
return TRUE;
- sts = sdc_lld_read_blocks(sdcp, buffer, n);
+ sts = sdc_lld_read_blocks(sdcp, buf, n);
sts = sts || sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION,
0, resp);
return sts;
@@ -306,7 +306,7 @@ bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk, bool_t sts;
uint32_t resp[1];
- chDbgCheck((sdcp != NULL) && (buffer != NULL) && (n > 0), "sdcWrite");
+ chDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0), "sdcWrite");
if ((sdcp->cardmode & SDC_MODE_HIGH_CAPACITY) == 0)
startblk *= SDC_BLOCK_SIZE;
@@ -315,7 +315,7 @@ bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk, startblk, resp))
return TRUE;
- sts = sdc_lld_write_blocks(sdcp, buffer, n);
+ sts = sdc_lld_write_blocks(sdcp, buf, n);
sts = sts || sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION,
0, resp);
return sts;
|