From af4d6f1e36157fe45f9e219c8d678c9e7c2c01c9 Mon Sep 17 00:00:00 2001 From: 3djc <3djc@gh.com> Date: Mon, 10 Jun 2024 10:29:29 +0200 Subject: [PATCH] feat: using FF_FS_TINY --- .../targets/common/arm/stm32/diskio_sdio.cpp | 24 +++++++------------ radio/src/thirdparty/FatFs/ffconf.h | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/radio/src/targets/common/arm/stm32/diskio_sdio.cpp b/radio/src/targets/common/arm/stm32/diskio_sdio.cpp index 5ad0d40c109..73ed3501cc1 100644 --- a/radio/src/targets/common/arm/stm32/diskio_sdio.cpp +++ b/radio/src/targets/common/arm/stm32/diskio_sdio.cpp @@ -270,15 +270,12 @@ static DRESULT sdio_read(BYTE lun, BYTE * buff, DWORD sector, UINT count) res = _read_dma(buff, sector, count); if (res != RES_OK) return res; - uint32_t timeout = HAL_GetTick(); - while((HAL_GetTick() - timeout) < SD_TIMEOUT) { - if (sdio_check_card_state() == SD_TRANSFER_OK) { - return RES_OK; - } + if (sdio_check_card_state_with_timeout(SD_TIMEOUT) < 0) { + TRACE("SD getstatus timeout, s:%u c:%u", sector, (uint32_t)count); + return RES_ERROR; } - TRACE("SD getstatus timeout, s:%u c:%u", sector, (uint32_t)count); - return RES_ERROR; + return RES_OK; } static DRESULT _write_dma(const BYTE *buff, DWORD sector, UINT count) @@ -329,16 +326,13 @@ static DRESULT sdio_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count) res = _write_dma(buff, sector, count); if (res != RES_OK) return res; - - uint32_t timeout = HAL_GetTick(); - while((HAL_GetTick() - timeout) < SD_TIMEOUT) { - if (sdio_check_card_state() == SD_TRANSFER_OK) { - return RES_OK; - } + + if (sdio_check_card_state_with_timeout(SD_TIMEOUT) < 0) { + TRACE("SD getstatus timeout, s:%u c: %u", sector, (uint32_t)count); + return RES_ERROR; } - TRACE("SD getstatus timeout, s:%u c: %u", sector, (uint32_t)count); - return RES_ERROR; + return RES_OK; } static DRESULT sdio_get_sector_count(DWORD* sectors) diff --git a/radio/src/thirdparty/FatFs/ffconf.h b/radio/src/thirdparty/FatFs/ffconf.h index 1e5b98593f7..7ea64f87106 100644 --- a/radio/src/thirdparty/FatFs/ffconf.h +++ b/radio/src/thirdparty/FatFs/ffconf.h @@ -235,7 +235,7 @@ / System Configurations /---------------------------------------------------------------------------*/ -#define FF_FS_TINY 0 +#define FF_FS_TINY 1 /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes. / Instead of private sector buffer eliminated from the file object, common sector