Skip to content

Commit 9cfb62c

Browse files
committed
Try to read and send the requested data in chunks
1 parent 2a3c5be commit 9cfb62c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,15 @@ static void command_loop(void)
227227
// Send ACK after handling slen (before reading)
228228
sendbyte_blocking(S_ACK);
229229

230-
// Handle receive operation in chunks
231-
uint32_t chunk_size = (rlen < MAX_BUFFER_SIZE) ? rlen : MAX_BUFFER_SIZE;
232-
230+
// Handle receive operation in chunks for large rlen
233231
cs_select(SPI_CS);
234-
spi_read_blocking(SPI_IF, 0, rx_buffer, chunk_size);
235-
cs_deselect(SPI_CS);
232+
while (rlen > 0) {
233+
uint32_t chunk_size = (rlen < MAX_BUFFER_SIZE) ? rlen : MAX_BUFFER_SIZE;
236234

237-
sendbytes_blocking(rx_buffer, chunk_size);
238-
rlen -= chunk_size;
235+
spi_read_blocking(SPI_IF, 0, rx_buffer, chunk_size);
236+
sendbytes_blocking(rx_buffer, chunk_size);
237+
rlen -= chunk_size;
238+
}
239239
cs_deselect(SPI_CS);
240240
break;
241241
}

0 commit comments

Comments
 (0)