Skip to content

Commit a79e2c7

Browse files
authored
feat: adjust availableForWrite
This change will make sure that if no TX Ringbuffer is used, it will return the UART FIFO available space. Otherwise, it will return the Ringbuffer available space, as defined in the Arduino especification.
1 parent c9b1407 commit a79e2c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ uint32_t uartAvailableForWrite(uart_t* uart)
642642
uint32_t available = uart_ll_get_txfifo_len(UART_LL_GET_HW(uart->num));
643643
size_t txRingBufferAvailable = 0;
644644
if (ESP_OK == uart_get_tx_buffer_free_size(uart->num, &txRingBufferAvailable)) {
645-
available += txRingBufferAvailable;
645+
available = txRingBufferAvailable == 0 ? available : txRingBufferAvailable;
646646
}
647647
UART_MUTEX_UNLOCK();
648648
return available;

0 commit comments

Comments
 (0)