From 7e8b385baa582880a580cbd1867cdfaf752e3a1d Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Mon, 2 Mar 2020 13:26:42 +0100 Subject: [PATCH] sd_fat read back to simple version --- src/eez/libs/sd_fat/stm32/sd_fat.cpp | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/eez/libs/sd_fat/stm32/sd_fat.cpp b/src/eez/libs/sd_fat/stm32/sd_fat.cpp index 7c426c288..f9adb92ae 100644 --- a/src/eez/libs/sd_fat/stm32/sd_fat.cpp +++ b/src/eez/libs/sd_fat/stm32/sd_fat.cpp @@ -179,27 +179,9 @@ int File::read() { } int File::read(void *buf, uint32_t nbyte) { - static const uint32_t CHUNK_SIZE = 512; - - UINT brTotal = 0; - - for (uint32_t i = 0; i < nbyte; i += CHUNK_SIZE) { - uint32_t n = MIN(CHUNK_SIZE, nbyte - i); - - UINT br; - - if (f_read(&m_file, (uint8_t *)buf + i, n, &br) != FR_OK) { - return 0; - } - - brTotal += br; - - if (br < n) { - break; - } - } - - return brTotal; + UINT br; + auto result = f_read(&m_file, buf, nbyte, &br); + return result == FR_OK ? br : 0; } size_t File::write(const uint8_t *buf, size_t size) {