Issue #9: Fix timeout bug in write block command
This commit is contained in:
parent
45564a7789
commit
04994bff51
@ -739,6 +739,7 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count)
|
||||
uint32_t buff_offset = 0;
|
||||
int ret;
|
||||
UINT count_backup = count;
|
||||
uint32_t retry_counter = 512;
|
||||
|
||||
if (sdio_check_write_protection())
|
||||
return RES_WRPRT;
|
||||
@ -754,10 +755,18 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count)
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
while (status.statusstruct.READY_FOR_DATA != 1) {
|
||||
while (1) {
|
||||
ret = sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
||||
if (ret)
|
||||
return RES_ERROR;
|
||||
|
||||
if (status.statusstruct.CURRENT_STATE == CURRENT_STATE_TRAN)
|
||||
break;
|
||||
|
||||
if (--retry_counter == 0)
|
||||
return RES_ERROR;
|
||||
|
||||
sdio_wait_ms(1);
|
||||
}
|
||||
|
||||
if (count > 1)
|
||||
|
Loading…
Reference in New Issue
Block a user