Skip to content

Commit 676f5cf

Browse files
authored
fix UART FIFO test for being full (#5390)
Fixes #5362
1 parent f4f1c89 commit 676f5cf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void uartWrite(uart_t* uart, uint8_t c)
422422
return;
423423
}
424424
UART_MUTEX_LOCK();
425-
while(uart->dev->status.txfifo_cnt == 0x7F);
425+
while(uart->dev->status.txfifo_cnt >= 0x7E);
426426
#if CONFIG_IDF_TARGET_ESP32
427427
uart->dev->fifo.rw_byte = c;
428428
#else
@@ -441,7 +441,7 @@ void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
441441
uint32_t fifo_reg = UART_FIFO_AHB_REG(uart->num);
442442
#endif
443443
while(len) {
444-
while(uart->dev->status.txfifo_cnt == 0x7F);
444+
while(uart->dev->status.txfifo_cnt >= 0x7E);
445445
#if CONFIG_IDF_TARGET_ESP32
446446
uart->dev->fifo.rw_byte = *data++;
447447
#else
@@ -563,7 +563,7 @@ uint32_t uartGetBaudRate(uart_t* uart)
563563
static void ARDUINO_ISR_ATTR uart0_write_char(char c)
564564
{
565565
#if CONFIG_IDF_TARGET_ESP32
566-
while(((ESP_REG(0x01C+DR_REG_UART_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) == 0x7F);
566+
while(((ESP_REG(0x01C+DR_REG_UART_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) >= 0x7E);
567567
ESP_REG(DR_REG_UART_BASE) = c;
568568
#else
569569
while(UART0.status.txfifo_cnt == 0x7F);
@@ -574,7 +574,7 @@ static void ARDUINO_ISR_ATTR uart0_write_char(char c)
574574
static void ARDUINO_ISR_ATTR uart1_write_char(char c)
575575
{
576576
#if CONFIG_IDF_TARGET_ESP32
577-
while(((ESP_REG(0x01C+DR_REG_UART1_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) == 0x7F);
577+
while(((ESP_REG(0x01C+DR_REG_UART1_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) >= 0x7E);
578578
ESP_REG(DR_REG_UART1_BASE) = c;
579579
#else
580580
while(UART1.status.txfifo_cnt == 0x7F);
@@ -585,7 +585,7 @@ static void ARDUINO_ISR_ATTR uart1_write_char(char c)
585585
#if CONFIG_IDF_TARGET_ESP32
586586
static void ARDUINO_ISR_ATTR uart2_write_char(char c)
587587
{
588-
while(((ESP_REG(0x01C+DR_REG_UART2_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) == 0x7F);
588+
while(((ESP_REG(0x01C+DR_REG_UART2_BASE) >> UART_TXFIFO_CNT_S) & 0x7F) >= 0x7E);
589589
ESP_REG(DR_REG_UART2_BASE) = c;
590590
}
591591
#endif

0 commit comments

Comments
 (0)