sdmmc v2: Move address alignment check in driver

This commit is contained in:
CTCaer
2020-04-29 21:46:25 +03:00
parent eac6426125
commit 10e7e06048
4 changed files with 52 additions and 40 deletions

View File

@@ -46,16 +46,7 @@ DRESULT disk_read (
UINT count /* Number of sectors to read */
)
{
// Ensure that buffer resides in DRAM and it's DMA aligned.
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
if (sdmmc_storage_read(&sd_storage, sector, count, buf))
{
memcpy(buff, buf, 512 * count);
return RES_OK;
}
return RES_ERROR;
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
}
/*-----------------------------------------------------------------------*/
@@ -68,14 +59,7 @@ DRESULT disk_write (
UINT count /* Number of sectors to write */
)
{
// Ensure that buffer resides in DRAM and it's DMA aligned.
if (((u32)buff >= DRAM_START) && !((u32)buff % 8))
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
u8 *buf = (u8 *)SDMMC_UPPER_BUFFER;
memcpy(buf, buff, 512 * count);
if (sdmmc_storage_write(&sd_storage, sector, count, buf))
return RES_OK;
return RES_ERROR;
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
}
/*-----------------------------------------------------------------------*/