SDC. Reverted from SDC_SUCCESS/SDC_FAILED to boolean values.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/sdc_dev2@4103 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
579fffb63c
commit
671cb8ab9d
|
@ -88,12 +88,6 @@
|
||||||
#define SDC_CMD_LOCK_UNLOCK 42
|
#define SDC_CMD_LOCK_UNLOCK 42
|
||||||
#define SDC_CMD_APP_CMD 55
|
#define SDC_CMD_APP_CMD 55
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returning status.
|
|
||||||
*/
|
|
||||||
#define SDC_SUCCESS FALSE
|
|
||||||
#define SDC_FAILED TRUE
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name SDC bus error conditions
|
* @name SDC bus error conditions
|
||||||
* @{
|
* @{
|
||||||
|
|
|
@ -79,8 +79,8 @@ static union {
|
||||||
* @param[in] resp pointer to the response buffer
|
* @param[in] resp pointer to the response buffer
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -96,16 +96,16 @@ static bool_t sdc_lld_prepare_read(SDCDriver *sdcp, uint32_t startblk,
|
||||||
/* Send read multiple blocks command to card.*/
|
/* Send read multiple blocks command to card.*/
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_READ_MULTIPLE_BLOCK,
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_READ_MULTIPLE_BLOCK,
|
||||||
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* Send read single block command.*/
|
/* Send read single block command.*/
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_READ_SINGLE_BLOCK,
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_READ_SINGLE_BLOCK,
|
||||||
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,8 +117,8 @@ static bool_t sdc_lld_prepare_read(SDCDriver *sdcp, uint32_t startblk,
|
||||||
* @param[in] resp pointer to the response buffer
|
* @param[in] resp pointer to the response buffer
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -134,16 +134,16 @@ static bool_t sdc_lld_prepare_write(SDCDriver *sdcp, uint32_t startblk,
|
||||||
/* Write multiple blocks command.*/
|
/* Write multiple blocks command.*/
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_WRITE_MULTIPLE_BLOCK,
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_WRITE_MULTIPLE_BLOCK,
|
||||||
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* Write single block command.*/
|
/* Write single block command.*/
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_WRITE_BLOCK,
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_WRITE_BLOCK,
|
||||||
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
startblk, resp) || SDC_R1_ERROR(resp[0]))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,8 +154,8 @@ static bool_t sdc_lld_prepare_write(SDCDriver *sdcp, uint32_t startblk,
|
||||||
* @param[in] resp pointer to the response buffer
|
* @param[in] resp pointer to the response buffer
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*/
|
*/
|
||||||
static bool_t sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
|
static bool_t sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
|
||||||
uint32_t *resp){
|
uint32_t *resp){
|
||||||
|
@ -173,7 +173,7 @@ static bool_t sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
|
||||||
}
|
}
|
||||||
if ((SDIO->STA & SDIO_STA_DATAEND) == 0) {
|
if ((SDIO->STA & SDIO_STA_DATAEND) == 0) {
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until DMA channel enabled to be sure that all data transferred.*/
|
/* Wait until DMA channel enabled to be sure that all data transferred.*/
|
||||||
|
@ -195,7 +195,7 @@ static bool_t sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
|
||||||
if (n > 1)
|
if (n > 1)
|
||||||
return sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION, 0, resp);
|
return sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_STOP_TRANSMISSION, 0, resp);
|
||||||
else
|
else
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -470,8 +470,8 @@ void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {
|
||||||
* @param[out] resp pointer to the response buffer (one word)
|
* @param[out] resp pointer to the response buffer (one word)
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -488,10 +488,10 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
||||||
if ((sta & (SDIO_STA_CTIMEOUT)) != 0){
|
if ((sta & (SDIO_STA_CTIMEOUT)) != 0){
|
||||||
sdc_lld_collect_errors(sdcp);
|
sdc_lld_collect_errors(sdcp);
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
*resp = SDIO->RESP1;
|
*resp = SDIO->RESP1;
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -503,8 +503,8 @@ bool_t sdc_lld_send_cmd_short(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
* @param[out] resp pointer to the response buffer (one word)
|
* @param[out] resp pointer to the response buffer (one word)
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -521,10 +521,10 @@ bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
||||||
if ((sta & (SDIO_STA_CTIMEOUT | SDIO_STA_CCRCFAIL)) != 0){
|
if ((sta & (SDIO_STA_CTIMEOUT | SDIO_STA_CCRCFAIL)) != 0){
|
||||||
sdc_lld_collect_errors(sdcp);
|
sdc_lld_collect_errors(sdcp);
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
*resp = SDIO->RESP1;
|
*resp = SDIO->RESP1;
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -536,8 +536,8 @@ bool_t sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
* @param[out] resp pointer to the response buffer (four words)
|
* @param[out] resp pointer to the response buffer (four words)
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -556,14 +556,14 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
SDIO->ICR = SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CCRCFAILC;
|
||||||
if ((sta & (STM32_SDIO_STA_ERROR_MASK)) != 0){
|
if ((sta & (STM32_SDIO_STA_ERROR_MASK)) != 0){
|
||||||
sdc_lld_collect_errors(sdcp);
|
sdc_lld_collect_errors(sdcp);
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
/* save bytes in reverse order because MSB in response comes first */
|
/* save bytes in reverse order because MSB in response comes first */
|
||||||
*resp++ = SDIO->RESP4;
|
*resp++ = SDIO->RESP4;
|
||||||
*resp++ = SDIO->RESP3;
|
*resp++ = SDIO->RESP3;
|
||||||
*resp++ = SDIO->RESP2;
|
*resp++ = SDIO->RESP2;
|
||||||
*resp = SDIO->RESP1;
|
*resp = SDIO->RESP1;
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -575,8 +575,8 @@ bool_t sdc_lld_send_cmd_long_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
|
||||||
* @param[in] n number of blocks to read
|
* @param[in] n number of blocks to read
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -590,7 +590,7 @@ bool_t sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
|
|
||||||
/* Checks for errors and waits for the card to be ready for reading.*/
|
/* Checks for errors and waits for the card to be ready for reading.*/
|
||||||
if (_sdc_wait_for_transfer_state(sdcp))
|
if (_sdc_wait_for_transfer_state(sdcp))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
|
|
||||||
/* Prepares the DMA channel for writing.*/
|
/* Prepares the DMA channel for writing.*/
|
||||||
dmaStreamSetMemory0(sdcp->dma, buf);
|
dmaStreamSetMemory0(sdcp->dma, buf);
|
||||||
|
@ -609,7 +609,7 @@ bool_t sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
SDIO->DLEN = n * SDC_BLOCK_SIZE;
|
SDIO->DLEN = n * SDC_BLOCK_SIZE;
|
||||||
|
|
||||||
/* Talk to card what we want from it.*/
|
/* Talk to card what we want from it.*/
|
||||||
if (sdc_lld_prepare_read(sdcp, startblk, n, resp) == SDC_FAILED)
|
if (sdc_lld_prepare_read(sdcp, startblk, n, resp) == TRUE)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Transaction starts just after DTEN bit setting.*/
|
/* Transaction starts just after DTEN bit setting.*/
|
||||||
|
@ -618,14 +618,14 @@ bool_t sdc_lld_read_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
SDIO_DCTRL_DBLOCKSIZE_0 |
|
SDIO_DCTRL_DBLOCKSIZE_0 |
|
||||||
SDIO_DCTRL_DMAEN |
|
SDIO_DCTRL_DMAEN |
|
||||||
SDIO_DCTRL_DTEN;
|
SDIO_DCTRL_DTEN;
|
||||||
if (sdc_lld_wait_transaction_end(sdcp, n, resp) == SDC_FAILED)
|
if (sdc_lld_wait_transaction_end(sdcp, n, resp) == TRUE)
|
||||||
goto error;
|
goto error;
|
||||||
else
|
else
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
sdc_lld_error_cleanup(sdcp, n, resp);
|
sdc_lld_error_cleanup(sdcp, n, resp);
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -637,8 +637,8 @@ error:
|
||||||
* @param[in] n number of blocks to write
|
* @param[in] n number of blocks to write
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -652,7 +652,7 @@ bool_t sdc_lld_write_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
|
|
||||||
/* Checks for errors and waits for the card to be ready for writing.*/
|
/* Checks for errors and waits for the card to be ready for writing.*/
|
||||||
if (_sdc_wait_for_transfer_state(sdcp))
|
if (_sdc_wait_for_transfer_state(sdcp))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
|
|
||||||
/* Prepares the DMA channel for writing.*/
|
/* Prepares the DMA channel for writing.*/
|
||||||
dmaStreamSetMemory0(sdcp->dma, buf);
|
dmaStreamSetMemory0(sdcp->dma, buf);
|
||||||
|
@ -671,7 +671,7 @@ bool_t sdc_lld_write_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
SDIO->DLEN = n * SDC_BLOCK_SIZE;
|
SDIO->DLEN = n * SDC_BLOCK_SIZE;
|
||||||
|
|
||||||
/* Talk to card what we want from it.*/
|
/* Talk to card what we want from it.*/
|
||||||
if (sdc_lld_prepare_write(sdcp, startblk, n, resp) == SDC_FAILED)
|
if (sdc_lld_prepare_write(sdcp, startblk, n, resp) == TRUE)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Transaction starts just after DTEN bit setting.*/
|
/* Transaction starts just after DTEN bit setting.*/
|
||||||
|
@ -679,14 +679,14 @@ bool_t sdc_lld_write_aligned(SDCDriver *sdcp, uint32_t startblk,
|
||||||
SDIO_DCTRL_DBLOCKSIZE_0 |
|
SDIO_DCTRL_DBLOCKSIZE_0 |
|
||||||
SDIO_DCTRL_DMAEN |
|
SDIO_DCTRL_DMAEN |
|
||||||
SDIO_DCTRL_DTEN;
|
SDIO_DCTRL_DTEN;
|
||||||
if (sdc_lld_wait_transaction_end(sdcp, n, resp) == SDC_FAILED)
|
if (sdc_lld_wait_transaction_end(sdcp, n, resp) == TRUE)
|
||||||
goto error;
|
goto error;
|
||||||
else
|
else
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
sdc_lld_error_cleanup(sdcp, n, resp);
|
sdc_lld_error_cleanup(sdcp, n, resp);
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -698,8 +698,8 @@ error:
|
||||||
* @param[in] n number of blocks to read
|
* @param[in] n number of blocks to read
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -711,12 +711,12 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (sdc_lld_read_aligned(sdcp, startblk, u.buf, 1))
|
if (sdc_lld_read_aligned(sdcp, startblk, u.buf, 1))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
memcpy(buf, u.buf, SDC_BLOCK_SIZE);
|
memcpy(buf, u.buf, SDC_BLOCK_SIZE);
|
||||||
buf += SDC_BLOCK_SIZE;
|
buf += SDC_BLOCK_SIZE;
|
||||||
startblk++;
|
startblk++;
|
||||||
}
|
}
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
||||||
return sdc_lld_read_aligned(sdcp, startblk, buf, n);
|
return sdc_lld_read_aligned(sdcp, startblk, buf, n);
|
||||||
|
@ -731,8 +731,8 @@ bool_t sdc_lld_read(SDCDriver *sdcp, uint32_t startblk,
|
||||||
* @param[in] n number of blocks to write
|
* @param[in] n number of blocks to write
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -746,10 +746,10 @@ bool_t sdc_lld_write(SDCDriver *sdcp, uint32_t startblk,
|
||||||
memcpy(u.buf, buf, SDC_BLOCK_SIZE);
|
memcpy(u.buf, buf, SDC_BLOCK_SIZE);
|
||||||
buf += SDC_BLOCK_SIZE;
|
buf += SDC_BLOCK_SIZE;
|
||||||
if (sdc_lld_write_aligned(sdcp, startblk, u.buf, 1))
|
if (sdc_lld_write_aligned(sdcp, startblk, u.buf, 1))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
startblk++;
|
startblk++;
|
||||||
}
|
}
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
#endif /* STM32_SDC_SDIO_UNALIGNED_SUPPORT */
|
||||||
return sdc_lld_write_aligned(sdcp, startblk, buf, n);
|
return sdc_lld_write_aligned(sdcp, startblk, buf, n);
|
||||||
|
|
|
@ -89,8 +89,8 @@ static uint32_t _sdc_get_slice(uint32_t *data, int32_t end, int32_t start) {
|
||||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
|
@ -101,10 +101,10 @@ bool_t _sdc_wait_for_transfer_state(SDCDriver *sdcp) {
|
||||||
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEND_STATUS,
|
if (sdc_lld_send_cmd_short_crc(sdcp, SDC_CMD_SEND_STATUS,
|
||||||
sdcp->rca, resp) ||
|
sdcp->rca, resp) ||
|
||||||
SDC_R1_ERROR(resp[0]))
|
SDC_R1_ERROR(resp[0]))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
switch (SDC_R1_STS(resp[0])) {
|
switch (SDC_R1_STS(resp[0])) {
|
||||||
case SDC_STS_TRAN:
|
case SDC_STS_TRAN:
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
case SDC_STS_DATA:
|
case SDC_STS_DATA:
|
||||||
case SDC_STS_RCV:
|
case SDC_STS_RCV:
|
||||||
case SDC_STS_PRG:
|
case SDC_STS_PRG:
|
||||||
|
@ -115,11 +115,11 @@ bool_t _sdc_wait_for_transfer_state(SDCDriver *sdcp) {
|
||||||
default:
|
default:
|
||||||
/* The card should have been initialized so any other state is not
|
/* The card should have been initialized so any other state is not
|
||||||
valid and is reported as an error.*/
|
valid and is reported as an error.*/
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If something going too wrong.*/
|
/* If something going too wrong.*/
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -204,8 +204,8 @@ void sdcStop(SDCDriver *sdcp) {
|
||||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -346,13 +346,13 @@ bool_t sdcConnect(SDCDriver *sdcp) {
|
||||||
|
|
||||||
/* Initialization complete.*/
|
/* Initialization complete.*/
|
||||||
sdcp->state = SDC_ACTIVE;
|
sdcp->state = SDC_ACTIVE;
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
|
|
||||||
/* Initialization failed.*/
|
/* Initialization failed.*/
|
||||||
failed:
|
failed:
|
||||||
sdc_lld_stop_clk(sdcp);
|
sdc_lld_stop_clk(sdcp);
|
||||||
sdcp->state = SDC_READY;
|
sdcp->state = SDC_READY;
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,8 +361,8 @@ failed:
|
||||||
* @param[in] sdcp pointer to the @p SDCDriver object
|
* @param[in] sdcp pointer to the @p SDCDriver object
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -375,20 +375,20 @@ bool_t sdcDisconnect(SDCDriver *sdcp) {
|
||||||
"sdcDisconnect(), #1", "invalid state");
|
"sdcDisconnect(), #1", "invalid state");
|
||||||
if (sdcp->state == SDC_READY) {
|
if (sdcp->state == SDC_READY) {
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
sdcp->state = SDC_DISCONNECTING;
|
sdcp->state = SDC_DISCONNECTING;
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
|
|
||||||
/* Waits for eventual pending operations completion.*/
|
/* Waits for eventual pending operations completion.*/
|
||||||
if (_sdc_wait_for_transfer_state(sdcp))
|
if (_sdc_wait_for_transfer_state(sdcp))
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
|
|
||||||
/* Card clock stopped.*/
|
/* Card clock stopped.*/
|
||||||
sdc_lld_stop_clk(sdcp);
|
sdc_lld_stop_clk(sdcp);
|
||||||
|
|
||||||
sdcp->state = SDC_READY;
|
sdcp->state = SDC_READY;
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,8 +402,8 @@ bool_t sdcDisconnect(SDCDriver *sdcp) {
|
||||||
* @param[in] n number of blocks to read
|
* @param[in] n number of blocks to read
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -415,7 +415,7 @@ bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk,
|
||||||
|
|
||||||
if ((startblk + n - 1) > sdcp->capacity){
|
if ((startblk + n - 1) > sdcp->capacity){
|
||||||
sdcp->errors |= SDC_OVERFLOW_ERROR;
|
sdcp->errors |= SDC_OVERFLOW_ERROR;
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
|
@ -439,8 +439,8 @@ bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk,
|
||||||
* @param[in] n number of blocks to write
|
* @param[in] n number of blocks to write
|
||||||
*
|
*
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval SDC_SUCCESS operation succeeded.
|
* @retval FALSE operation succeeded.
|
||||||
* @retval SDC_FAILED operation failed.
|
* @retval TRUE operation failed.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -452,7 +452,7 @@ bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk,
|
||||||
|
|
||||||
if ((startblk + n - 1) > sdcp->capacity){
|
if ((startblk + n - 1) > sdcp->capacity){
|
||||||
sdcp->errors |= SDC_OVERFLOW_ERROR;
|
sdcp->errors |= SDC_OVERFLOW_ERROR;
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
|
|
|
@ -79,10 +79,10 @@ bool_t badblocks(uint32_t start, uint32_t end, uint32_t blockatonce, uint8_t pat
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
position += blockatonce;
|
position += blockatonce;
|
||||||
}
|
}
|
||||||
return SDC_SUCCESS;
|
return FALSE;
|
||||||
|
|
||||||
ERROR:
|
ERROR:
|
||||||
return SDC_FAILED;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue