Skip to content

Commit fb4f133

Browse files
committed
Fix UART writeBuf and flush
1 parent 03f5d62 commit fb4f133

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ void uartWrite(uart_t* uart, uint8_t c)
170170

171171
void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
172172
{
173-
while(len && uart->dev->status.rxfifo_cnt < 0x7F) {
174-
uart->dev->fifo.rw_byte = *data++;
175-
len--;
173+
while(len) {
174+
while(len && uart->dev->status.txfifo_cnt < 0x7F) {
175+
uart->dev->fifo.rw_byte = *data++;
176+
len--;
177+
}
176178
}
177179
}
178180

@@ -189,8 +191,8 @@ void uartFlush(uart_t* uart)
189191
}
190192

191193
if(uart->txEnabled) {
192-
tmp |= UART_TXFIFO_RST;
193194
while(uart->dev->status.txfifo_cnt);
195+
tmp |= UART_TXFIFO_RST;
194196
}
195197

196198
uart->dev->conf0.val |= (tmp);

0 commit comments

Comments
 (0)