Compare commits
2 Commits
45564a7789
...
0395cd19d4
Author | SHA1 | Date | |
---|---|---|---|
0395cd19d4 | |||
04994bff51 |
@ -739,6 +739,7 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count)
|
|||||||
uint32_t buff_offset = 0;
|
uint32_t buff_offset = 0;
|
||||||
int ret;
|
int ret;
|
||||||
UINT count_backup = count;
|
UINT count_backup = count;
|
||||||
|
uint32_t retry_counter = 512;
|
||||||
|
|
||||||
if (sdio_check_write_protection())
|
if (sdio_check_write_protection())
|
||||||
return RES_WRPRT;
|
return RES_WRPRT;
|
||||||
@ -754,10 +755,18 @@ DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count)
|
|||||||
return RES_ERROR;
|
return RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (status.statusstruct.READY_FOR_DATA != 1) {
|
while (1) {
|
||||||
ret = sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
ret = sdio_check_status_register_cmd13(card_info.rca, &status.value);
|
||||||
if (ret)
|
if (ret)
|
||||||
return RES_ERROR;
|
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)
|
if (count > 1)
|
||||||
|
@ -59,19 +59,17 @@ static int create_controller_folder(void)
|
|||||||
char foldername[48];
|
char foldername[48];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FRESULT filesystem_result;
|
FRESULT filesystem_result;
|
||||||
DIR folder;
|
FILINFO fno;
|
||||||
|
|
||||||
get_controller_folder_path(foldername, sizeof(foldername));
|
get_controller_folder_path(foldername, sizeof(foldername));
|
||||||
|
|
||||||
/* Check if folder is present */
|
/* Check if folder is present */
|
||||||
filesystem_result = f_opendir(&folder, foldername);
|
filesystem_result = f_stat(foldername, &fno);
|
||||||
if (filesystem_result == FR_OK) {
|
if (filesystem_result == FR_OK && fno.fattrib & AM_DIR) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
f_closedir(&folder);
|
|
||||||
} else {
|
} else {
|
||||||
filesystem_result = f_mkdir(foldername);
|
filesystem_result = f_mkdir(foldername);
|
||||||
if (filesystem_result == FR_OK) {
|
if (filesystem_result == FR_OK) {
|
||||||
f_closedir(&folder);
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user