File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
cores/arduino/ard_sup/uart Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ size_t Uart::write(const uint8_t data)
117
117
size_t Uart::write (const uint8_t *buffer, size_t size)
118
118
{
119
119
uint32_t ui32BytesWritten = 0 ;
120
+ uint32_t remaining = size;
120
121
121
122
// FIFO on Apollo3 is 32 bytes
122
123
@@ -125,11 +126,11 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
125
126
am_hal_uart_flags_get (_handle, &uartFlags);
126
127
if (uartFlags & AM_HAL_UART_FR_TX_EMPTY)
127
128
{
128
- uint32_t amtToSend = size ;
129
+ uint32_t amtToSend = remaining ;
129
130
if (amtToSend > AM_HAL_UART_FIFO_MAX)
130
131
amtToSend = AM_HAL_UART_FIFO_MAX;
131
132
132
- size -= amtToSend;
133
+ remaining -= amtToSend;
133
134
134
135
// Transfer to local buffer
135
136
uint8_t tempTX[AM_HAL_UART_FIFO_MAX];
@@ -148,7 +149,7 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
148
149
}
149
150
150
151
// Transfer any remaining bytes into ring buffer
151
- for (int x = 0 ; x < size; x++)
152
+ for (int x = size - remaining ; x < size; x++)
152
153
{
153
154
// If TX ring buffer is full, begin blocking
154
155
while (_tx_buffer.availableForStore () == 0 )
You can’t perform that action at this time.
0 commit comments