1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

[Horus] Massstorage again OK

This commit is contained in:
Bertrand Songis 2016-07-27 22:36:05 +02:00
parent ac86ebc229
commit c307e1987c

View file

@ -175,23 +175,10 @@ int8_t STORAGE_Read (uint8_t lun,
uint32_t blk_addr, uint32_t blk_addr,
uint16_t blk_len) uint16_t blk_len)
{ {
if (disk_read(0, buf, blk_addr, blk_len) == RES_OK)
for (int retry=0; retry<3; retry++) { return 0;
if (SD_ReadMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) { else
continue; return -1;
}
SDTransferState State;
SD_Error Status = SD_WaitReadOperation(); // Check if the Transfer is finished
while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
if ((State == SD_TRANSFER_OK) && (Status == SD_OK)) {
return 0;
}
}
return -1;
} }
/** /**
* @brief Write data to the medium * @brief Write data to the medium
@ -207,19 +194,10 @@ int8_t STORAGE_Write (uint8_t lun,
uint32_t blk_addr, uint32_t blk_addr,
uint16_t blk_len) uint16_t blk_len)
{ {
if (SD_WriteMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) if (disk_write(0, buf, blk_addr, blk_len) == RES_OK)
return 0;
else
return -1; return -1;
SDTransferState State;
SD_Error Status = SD_WaitWriteOperation(); // Check if the Transfer is finished
while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL)
if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK))
return -1;
return 0;
} }
/** /**