Skip to content

Commit d9d4a72

Browse files
committed
esp8266/uart: Add uart_flush() function.
1 parent d3a4d39 commit d9d4a72

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

esp8266/uart.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ void uart_tx_one_char(uint8 uart, uint8 TxChar) {
105105
WRITE_PERI_REG(UART_FIFO(uart), TxChar);
106106
}
107107

108+
void uart_flush(uint8 uart) {
109+
while (true) {
110+
uint32 fifo_cnt = READ_PERI_REG(UART_STATUS(uart)) & (UART_TXFIFO_CNT<<UART_TXFIFO_CNT_S);
111+
if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) == 0) {
112+
break;
113+
}
114+
}
115+
}
116+
108117
/******************************************************************************
109118
* FunctionName : uart1_write_char
110119
* Description : Internal used function

esp8266/uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,6 @@ typedef struct {
9292
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br);
9393
int uart0_rx(void);
9494
void uart_tx_one_char(uint8 uart, uint8 TxChar);
95+
void uart_flush(uint8 uart);
9596

9697
#endif // _INCLUDED_UART_H_

0 commit comments

Comments
 (0)