mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
SDIO timeout fixes
This commit is contained in:
parent
e229c8f8e7
commit
0076dd99e0
3 changed files with 15 additions and 17 deletions
|
@ -159,7 +159,7 @@ DRESULT __disk_read(
|
|||
if (Status == SD_OK) {
|
||||
SDTransferState State;
|
||||
|
||||
Status = SD_WaitReadOperation(); // Check if the Transfer is finished
|
||||
Status = SD_WaitReadOperation(100*count); // Check if the Transfer is finished
|
||||
|
||||
while ((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
|
||||
|
||||
|
@ -230,7 +230,7 @@ DRESULT __disk_write(
|
|||
if (Status == SD_OK) {
|
||||
SDTransferState State;
|
||||
|
||||
Status = SD_WaitWriteOperation(); // Check if the Transfer is finished
|
||||
Status = SD_WaitWriteOperation(500*count); // Check if the Transfer is finished
|
||||
|
||||
while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#define SD_SINGLE_BUS_SUPPORT ((uint32_t)0x00010000)
|
||||
#define SD_CARD_LOCKED ((uint32_t)0x02000000)
|
||||
|
||||
#define SD_DATATIMEOUT ((uint32_t)0xFFFFFFFF)
|
||||
#define SD_DATATIMEOUT ((uint32_t)100000)
|
||||
#define SD_0TO7BITS ((uint32_t)0x000000FF)
|
||||
#define SD_8TO15BITS ((uint32_t)0x0000FF00)
|
||||
#define SD_16TO23BITS ((uint32_t)0x00FF0000)
|
||||
|
@ -1338,7 +1338,7 @@ OPTIMIZE("O0") SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr,
|
|||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; // TODO consider setting shorter timeout
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT * NumberOfBlocks;
|
||||
SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize;
|
||||
SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_512b;
|
||||
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO;
|
||||
|
@ -1372,25 +1372,24 @@ OPTIMIZE("O0") SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr,
|
|||
* @param None.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
OPTIMIZE("O0") SD_Error SD_WaitReadOperation(void)
|
||||
OPTIMIZE("O0") SD_Error SD_WaitReadOperation(uint32_t timeout)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t timeout;
|
||||
|
||||
timeout = SD_DATATIMEOUT;
|
||||
|
||||
while (!DMAEndOfTransfer && !TransferEnd && (TransferError == SD_OK) && (timeout > 0))
|
||||
{
|
||||
delay_ms(1);
|
||||
timeout--;
|
||||
}
|
||||
TRACE_SD_CARD_EVENT((timeout == 0), sd_wait_read, (TransferError << 8) + (DMAEndOfTransfer << 1) + TransferEnd);
|
||||
|
||||
DMAEndOfTransfer = 0;
|
||||
|
||||
timeout = SD_DATATIMEOUT;
|
||||
timeout = 10;
|
||||
|
||||
while(((SDIO->STA & SDIO_FLAG_RXACT)) && (timeout > 0))
|
||||
{
|
||||
delay_ms(1);
|
||||
timeout--;
|
||||
}
|
||||
TRACE_SD_CARD_EVENT((timeout == 0), sd_wait_read, -1);
|
||||
|
@ -1590,7 +1589,7 @@ OPTIMIZE("O0") SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAd
|
|||
return(errorstatus);
|
||||
}
|
||||
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;
|
||||
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT * NumberOfBlocks;
|
||||
SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize;
|
||||
SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_512b;
|
||||
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard;
|
||||
|
@ -1610,25 +1609,24 @@ OPTIMIZE("O0") SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAd
|
|||
* @param None.
|
||||
* @retval SD_Error: SD Card Error code.
|
||||
*/
|
||||
OPTIMIZE("O0") SD_Error SD_WaitWriteOperation(void)
|
||||
OPTIMIZE("O0") SD_Error SD_WaitWriteOperation(uint32_t timeout)
|
||||
{
|
||||
SD_Error errorstatus = SD_OK;
|
||||
uint32_t timeout;
|
||||
|
||||
timeout = SD_DATATIMEOUT;
|
||||
|
||||
while (!DMAEndOfTransfer && !TransferEnd && (TransferError == SD_OK) && (timeout > 0))
|
||||
{
|
||||
delay_ms(1);
|
||||
timeout--;
|
||||
}
|
||||
TRACE_SD_CARD_EVENT((timeout == 0), sd_wait_write, (TransferError << 8) + (DMAEndOfTransfer << 1) + TransferEnd);
|
||||
|
||||
DMAEndOfTransfer = 0;
|
||||
|
||||
timeout = SD_DATATIMEOUT;
|
||||
timeout = 10;
|
||||
|
||||
while(((SDIO->STA & SDIO_FLAG_TXACT)) && (timeout > 0))
|
||||
{
|
||||
delay_ms(1);
|
||||
timeout--;
|
||||
}
|
||||
TRACE_SD_CARD_EVENT((timeout == 0), sd_wait_write, -1);
|
||||
|
|
|
@ -207,8 +207,8 @@ SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t Bl
|
|||
SDTransferState SD_GetTransferState(void);
|
||||
// SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr);
|
||||
// SD_Error SD_SendSDStatus(uint32_t *psdstatus);
|
||||
SD_Error SD_WaitReadOperation(void);
|
||||
SD_Error SD_WaitWriteOperation(void);
|
||||
SD_Error SD_WaitReadOperation(uint32_t timeout);
|
||||
SD_Error SD_WaitWriteOperation(uint32_t timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue