diff options
author | Leonard Kugis <leonard@kug.is> | 2024-05-22 02:32:12 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2024-05-22 02:32:12 +0200 |
commit | b0356477bb99ce627e21091445fe0cd3fb8025d5 (patch) | |
tree | c97513719ac861d623f32821236acb47cd24c1a7 /FT245.c | |
parent | 7789a69bd2a750043ffd3daee23bfca8cbb625a0 (diff) |
FT245_read_buffered now returning actual number of bytes read.
Diffstat (limited to 'FT245.c')
-rw-r--r-- | FT245.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1012,15 +1012,15 @@ bool FT245_write_buffered(ft245_t *ft245, uint8_t *data, size_t size) return true; } -bool FT245_read_buffered(ft245_t *ft245, uint8_t *data, size_t size) +size_t FT245_read_buffered(ft245_t *ft245, uint8_t *data, size_t size) { - if(cb_occupation(ft245->buffer_rx) < size) - return false; - - for(size_t i = 0; i < size; i++) + for(size_t i = 0; i < size; i++) { + if(cb_empty(ft245->buffer_rx)) + return i; cb_pop(ft245->buffer_rx, data[i]); + } - return true; + return size; } bool FT245_write_word_buffered(ft245_t *ft245, uint32_t word) |