aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM32/sdc_lld.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-03-09 12:31:50 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-03-09 12:31:50 +0000
commit300f9721f8206fe16ad28b508568d9347880adb9 (patch)
tree18aaeb8abdbbef818cc336d99bc0626d32669a9a /os/hal/platforms/STM32/sdc_lld.c
parentfcadc8a00add3b61c790ad801d507069a8093094 (diff)
downloadChibiOS-300f9721f8206fe16ad28b508568d9347880adb9.tar.gz
ChibiOS-300f9721f8206fe16ad28b508568d9347880adb9.tar.bz2
ChibiOS-300f9721f8206fe16ad28b508568d9347880adb9.zip
Fixed bug 3606743.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5395 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/STM32/sdc_lld.c')
-rw-r--r--os/hal/platforms/STM32/sdc_lld.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/os/hal/platforms/STM32/sdc_lld.c b/os/hal/platforms/STM32/sdc_lld.c
index 68b1d01e0..119a2e23d 100644
--- a/os/hal/platforms/STM32/sdc_lld.c
+++ b/os/hal/platforms/STM32/sdc_lld.c
@@ -212,40 +212,27 @@ static bool_t sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
* @brief Gets SDC errors.
*
* @param[in] sdcp pointer to the @p SDCDriver object
+ * @param[in] sta value of the STA register
*
* @notapi
*/
-static void sdc_lld_collect_errors(SDCDriver *sdcp) {
+static void sdc_lld_collect_errors(SDCDriver *sdcp, uint32_t sta) {
uint32_t errors = SDC_NO_ERROR;
- if (SDIO->STA & SDIO_STA_CCRCFAIL) {
- SDIO->ICR |= SDIO_ICR_CCRCFAILC;
+ if (sta & SDIO_STA_CCRCFAIL)
errors |= SDC_CMD_CRC_ERROR;
- }
- if (SDIO->STA & SDIO_STA_DCRCFAIL) {
- SDIO->ICR |= SDIO_ICR_DCRCFAILC;
+ if (sta & SDIO_STA_DCRCFAIL)
errors |= SDC_DATA_CRC_ERROR;
- }
- if (SDIO->STA & SDIO_STA_CTIMEOUT) {
- SDIO->ICR |= SDIO_ICR_CTIMEOUTC;
+ if (sta & SDIO_STA_CTIMEOUT)
errors |= SDC_COMMAND_TIMEOUT;
- }
- if (SDIO->STA & SDIO_STA_DTIMEOUT) {
- SDIO->ICR |= SDIO_ICR_CTIMEOUTC;
+ if (sta & SDIO_STA_DTIMEOUT)
errors |= SDC_DATA_TIMEOUT;
- }
- if (SDIO->STA & SDIO_STA_TXUNDERR) {
- SDIO->ICR |= SDIO_ICR_TXUNDERRC;
+ if (sta & SDIO_STA_TXUNDERR)
errors |= SDC_TX_UNDERRUN;
- }
- if (SDIO->STA & SDIO_STA_RXOVERR) {
- SDIO->ICR |= SDIO_ICR_RXOVERRC;
+ if (sta & SDIO_STA_RXOVERR)
errors |= SDC_RX_OVERRUN;
- }
- if (SDIO->STA & SDIO_STA_STBITERR) {
- SDIO->ICR |= SDIO_ICR_STBITERRC;
+ if (sta & SDIO_STA_STBITERR)
errors |= SDC_STARTBIT_ERROR;
- }
sdcp->errors |= errors;
}
@@ -262,13 +249,14 @@ static void sdc_lld_collect_errors(SDCDriver *sdcp) {
static void sdc_lld_error_cleanup(SDCDriver *sdcp,
uint32_t n,
uint32_t *resp) {
+ uint32_t sta = SDIO->STA;
dmaStreamClearInterrupt(sdcp->dma);
dmaStreamDisable(sdcp->dma);
SDIO->ICR = STM32_SDIO_ICR_ALL_FLAGS;
SDIO->MASK = 0;
SDIO->DCTRL = 0;
- sdc_lld_collect_errors(sdcp);
+ sdc_lld_collect_errors(sdcp, sta);
if (n > 1)
sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_STOP_TRANSMISSION, 0, resp);
}
@@ -510,9 +498,9 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
while (((sta = SDIO->STA) & (SDIO_STA_CMDREND | SDIO_STA_CTIMEOUT |
SDIO_STA_CCRCFAIL)) == 0)
;
- SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
+ SDIO->ICR = sta;
if ((sta & (SDIO_STA_CTIMEOUT)) != 0) {
- sdc_lld_collect_errors(sdcp);
+ sdc_lld_collect_errors(sdcp, sta);
return CH_FAILED;
}
*resp = SDIO->RESP1;
@@ -544,9 +532,9 @@ bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
while (((sta = SDIO->STA) & (SDIO_STA_CMDREND | SDIO_STA_CTIMEOUT |
SDIO_STA_CCRCFAIL)) == 0)
;
- SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
+ SDIO->ICR = sta;
if ((sta & (SDIO_STA_CTIMEOUT | SDIO_STA_CCRCFAIL)) != 0) {
- sdc_lld_collect_errors(sdcp);
+ sdc_lld_collect_errors(sdcp, sta);
return CH_FAILED;
}
*resp = SDIO->RESP1;
@@ -579,9 +567,9 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
while (((sta = SDIO->STA) & (SDIO_STA_CMDREND | SDIO_STA_CTIMEOUT |
SDIO_STA_CCRCFAIL)) == 0)
;
- SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
+ SDIO->ICR = sta;
if ((sta & (STM32_SDIO_STA_ERROR_MASK)) != 0) {
- sdc_lld_collect_errors(sdcp);
+ sdc_lld_collect_errors(sdcp, sta);
return CH_FAILED;
}
/* Save bytes in reverse order because MSB in response comes first.*/