Fixed bug 3605794.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5306 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2013-02-24 08:11:13 +00:00
parent 54e9e02607
commit 5a6b1e42b0
5 changed files with 70 additions and 35 deletions

View File

@ -39,28 +39,28 @@
stop [label="BLK_STOP\nLow Power"];
uninit [label="BLK_UNINIT", style="bold"];
ready [label="BLK_READY\nClock Enabled"];
active [label="BLK_ACTIVE\nClock Enabled"];
connecting [label="BLK_CONN.ING\nConnecting"];
disconnecting [label="BLK_DISC.ING\nDisconnecting"];
active [label="BLK_ACTIVE\nCard Ready"];
ready [label="BLK_READY\nCard Ready"];
reading [label="BLK_READING\nReading"];
writing [label="BLK_WRITING\nWriting"];
uninit -> stop [label=" blkInit()", constraint=false];
stop -> stop [label="\nblkStop()"];
stop -> ready [label="\nblkStart()"];
ready -> stop [label="\nblkStop()"];
ready -> ready [label="\nblkStart()\nblkDisconnect()"];
ready -> connecting [label="\nblkConnect()"];
connecting -> active [label="\nconnection\nsuccessful"];
connecting -> active [label="\nblkConnect()", dir="back"];
connecting -> ready [label="\nconnection\nfailed"];
disconnecting -> active [label="\nblkDisconnect()", dir="back"];
ready -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
active -> reading [label="\nblkRead()"];
reading -> active [label="\nread finished\nread error"];
active -> writing [label="\nblkWrite()"];
writing -> active [label="\nwrite finished\nwrite error"];
stop -> active [label="\nblkStart()"];
active -> stop [label="\nblkStop()"];
active -> active [label="\nblkStart()\nblkDisconnect()"];
active -> connecting [label="\nblkConnect()"];
connecting -> ready [label="\nconnection\nsuccessful"];
connecting -> ready [label="\nblkConnect()", dir="back"];
connecting -> active [label="\nconnection\nfailed"];
disconnecting -> ready [label="\nblkDisconnect()", dir="back"];
active -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
ready -> reading [label="\nblkRead()"];
reading -> ready [label="\nread finished\nread error"];
ready -> writing [label="\nblkWrite()"];
writing -> ready [label="\nwrite finished\nwrite error"];
}
* @enddot
* @else
@ -73,28 +73,31 @@
stop [label="BLK_STOP\nLow Power"];
uninit [label="BLK_UNINIT", style="bold"];
ready [label="BLK_READY\nClock Enabled"];
active [label="BLK_ACTIVE\nClock Enabled"];
connecting [label="BLK_CONN.ING\nConnecting"];
disconnecting [label="BLK_DISC.ING\nDisconnecting"];
active [label="BLK_ACTIVE\nCard Ready"];
ready [label="BLK_READY\nCard Ready"];
reading [label="BLK_READING\nReading"];
writing [label="BLK_WRITING\nWriting"];
syncing [label="BLK_SYNCING\nSynchronizing"];
uninit -> stop [label=" blkInit()", constraint=false];
stop -> stop [label="\nblkStop()"];
stop -> ready [label="\nblkStart()"];
ready -> stop [label="\nblkStop()"];
ready -> ready [label="\nblkStart()\nblkDisconnect()"];
ready -> connecting [label="\nblkConnect()"];
connecting -> active [label="\nconnection\nsuccessful"];
connecting -> active [label="\nblkConnect()", dir="back"];
connecting -> ready [label="\nconnection\nfailed"];
disconnecting -> active [label="\nblkDisconnect()", dir="back"];
ready -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
active -> reading [label="\nblkRead()"];
reading -> active [label="\nread finished\nread error"];
active -> writing [label="\nblkWrite()"];
writing -> active [label="\nwrite finished\nwrite error"];
stop -> active [label="\nblkStart()"];
active -> stop [label="\nblkStop()"];
active -> active [label="\nblkStart()\nblkDisconnect()"];
active -> connecting [label="\nblkConnect()"];
connecting -> ready [label="\nconnection\nsuccessful"];
connecting -> ready [label="\nblkConnect()", dir="back"];
connecting -> active [label="\nconnection\nfailed"];
disconnecting -> ready [label="\nblkDisconnect()", dir="back"];
active -> disconnecting [label="\ndisconnection\nfinished", dir="back"];
ready -> reading [label="\nblkRead()"];
reading -> ready [label="\nread finished\nread error"];
ready -> writing [label="\nblkWrite()"];
writing -> ready [label="\nwrite finished\nwrite error"];
ready -> syncing [label="\nblkSync()"];
syncing -> ready [label="\nsynchronization finished"];
}
* @enddot
* @endif

View File

@ -49,7 +49,8 @@ typedef enum {
BLK_DISCONNECTING = 4, /**< Disconnection in progress. */
BLK_READY = 5, /**< Device ready. */
BLK_READING = 6, /**< Read operation in progress. */
BLK_WRITING = 7 /**< Write operation in progress. */
BLK_WRITING = 7, /**< Write operation in progress. */
BLK_SYNCING = 8 /**< Sync. operation in progress. */
} blkstate_t;
/**

View File

@ -600,6 +600,7 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
if (recvr1(mmcp) != 0x00) {
spiStop(mmcp->config->spip);
mmcp->state = BLK_READY;
return CH_FAILED;
}
return CH_SUCCESS;
@ -637,6 +638,7 @@ bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
/* Timeout.*/
spiUnselect(mmcp->config->spip);
spiStop(mmcp->config->spip);
mmcp->state = BLK_READY;
return CH_FAILED;
}
@ -702,6 +704,7 @@ bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
if (recvr1(mmcp) != 0x00) {
spiStop(mmcp->config->spip);
mmcp->state = BLK_READY;
return CH_FAILED;
}
return CH_SUCCESS;
@ -740,6 +743,7 @@ bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
/* Error.*/
spiUnselect(mmcp->config->spip);
spiStop(mmcp->config->spip);
mmcp->state = BLK_READY;
return CH_FAILED;
}
@ -788,8 +792,14 @@ bool_t mmcSync(MMCDriver *mmcp) {
if (mmcp->state != BLK_READY)
return CH_FAILED;
/* Synchronization operation in progress.*/
mmcp->state = BLK_SYNCING;
spiStart(mmcp->config->spip, mmcp->config->hscfg);
sync(mmcp);
/* Synchronization operation finished.*/
mmcp->state = BLK_READY;
return CH_SUCCESS;
}
@ -835,6 +845,9 @@ bool_t mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk) {
chDbgCheck((mmcp != NULL), "mmcErase");
/* Erase operation in progress.*/
mmcp->state = BLK_WRITING;
/* Handling command differences between HC and normal cards.*/
if (!mmcp->block_addresses) {
startblk *= MMCSD_BLOCK_SIZE;
@ -850,11 +863,13 @@ bool_t mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk) {
if (send_command_R1(mmcp, MMCSD_CMD_ERASE, 0))
goto failed;
mmcp->state = BLK_READY;
return CH_SUCCESS;
/* Command failed, state reset to BLK_ACTIVE.*/
failed:
spiStop(mmcp->config->spip);
mmcp->state = BLK_READY;
return CH_FAILED;
}

View File

@ -468,13 +468,21 @@ sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp) {
* @api
*/
bool_t sdcSync(SDCDriver *sdcp) {
bool_t result;
chDbgCheck(sdcp != NULL, "sdcSync");
if (sdcp->state != BLK_READY)
return CH_FAILED;
return sdc_lld_sync(sdcp);
/* Synchronization operation in progress.*/
sdcp->state = BLK_SYNCING;
result = sdc_lld_sync(sdcp);
/* Synchronization operation finished.*/
sdcp->state = BLK_READY;
return result;
}
/**
@ -522,6 +530,9 @@ bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
chDbgCheck((sdcp != NULL), "sdcErase");
chDbgAssert(sdcp->state == BLK_READY, "sdcErase(), #1", "invalid state");
/* Erase operation in progress.*/
sdcp->state = BLK_WRITING;
/* Handling command differences between HC and normal cards.*/
if (!(sdcp->cardmode & SDC_MODE_HIGH_CAPACITY)) {
startblk *= MMCSD_BLOCK_SIZE;
@ -533,17 +544,17 @@ bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE_RW_BLK_START,
startblk, resp) != CH_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
return CH_FAILED;
goto failed;
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE_RW_BLK_END,
endblk, resp) != CH_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
return CH_FAILED;
goto failed;
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE,
0, resp) != CH_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
return CH_FAILED;
goto failed;
/* Quick sleep to allow it to transition to programming or receiving state */
/* TODO: ??????????????????????????? */
@ -552,6 +563,10 @@ bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
_sdc_wait_for_transfer_state(sdcp);
return CH_SUCCESS;
failed:
sdcp->state = BLK_READY;
return CH_FAILED;
}
#endif /* HAL_USE_SDC */

View File

@ -85,6 +85,7 @@
*****************************************************************************
*** 2.5.2 ***
- FIX: Fixed errors in MMC_SPI driver state machine (bug 3605794).
- FIX: Fixed deadlock in Serial_USB driver (bug 3605793).
- FIX: Fixed compile Error OLIMEX_SAM7_EX256/board.c (bug 3605058).
- FIX: Fixed bug prevents calling adcStartConversionI() within ISR (bug