Skip to content

Commit

Permalink
sd_fat read back to simple version
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 2, 2020
1 parent 0c93f1e commit 7e8b385
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/eez/libs/sd_fat/stm32/sd_fat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7e8b385

Please sign in to comment.