Skip to content

Commit d2a76cd

Browse files
committed
Try to read and send the requested data in chunks
1 parent 472b303 commit d2a76cd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

main.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,14 @@ static void command_loop(void)
228228
sendbyte_blocking(S_ACK);
229229

230230
// Handle receive operation in chunks
231-
while (rlen > 0) {
232-
uint32_t chunk_size = (rlen < MAX_BUFFER_SIZE) ? rlen : MAX_BUFFER_SIZE;
231+
uint32_t chunk_size = (rlen < MAX_BUFFER_SIZE) ? rlen : MAX_BUFFER_SIZE;
233232

234-
cs_select(SPI_CS);
235-
spi_read_blocking(SPI_IF, 0, rx_buffer, chunk_size);
236-
cs_deselect(SPI_CS);
233+
cs_select(SPI_CS);
234+
spi_read_blocking(SPI_IF, 0, rx_buffer, chunk_size);
235+
cs_deselect(SPI_CS);
237236

238-
sendbytes_blocking(rx_buffer, chunk_size);
239-
rlen -= chunk_size;
240-
}
237+
sendbytes_blocking(rx_buffer, chunk_size);
238+
rlen -= chunk_size;
241239
cs_deselect(SPI_CS);
242240
break;
243241
}

0 commit comments

Comments
 (0)