This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 282c4104b9 tlsr82/serial: clear uart tx index when uart_reset called. 282c4104b9 is described below commit 282c4104b9b508036777156a5b097f2297210b8c Author: wangbowen6 <wangbow...@xiaomi.com> AuthorDate: Mon Sep 19 14:17:27 2022 +0800 tlsr82/serial: clear uart tx index when uart_reset called. Otherwise, after the rx error occur, the tx output will be out of sequence, for example: normal log: [ 30.163000] 12345678abcdefgh [ 30.666000] 12345678abcdefgh [ 31.169000] 12345678abcdefgh [ 31.672000] 12345678abcdefgh [ 32.175000] 12345678abcdefgh [ 32.678000] 12345678abcdefgh [ 33.181000] 12345678abcdefgh error log: he 7 .20]0003 127456c8abgdefch gde [6.707002] 16345b78afcde fcde fghe10010] 5234a678ebcd 77 713 00]41238567dabchefgd che 7 .21]0003 127456c8abgdefch gde [8.709002] 16345b78afcde fcde Signed-off-by: wangbowen6 <wangbow...@xiaomi.com> --- arch/arm/src/tlsr82/tlsr82_serial.c | 49 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/arch/arm/src/tlsr82/tlsr82_serial.c b/arch/arm/src/tlsr82/tlsr82_serial.c index 9e9fa7e983..1d76729f5b 100644 --- a/arch/arm/src/tlsr82/tlsr82_serial.c +++ b/arch/arm/src/tlsr82/tlsr82_serial.c @@ -331,32 +331,51 @@ static uart_dev_t g_uart0_dev = ****************************************************************************/ /**************************************************************************** - * Name: uart_reset + * Name: uart_clr_rx_index * * Description: - * Reset the uart hardware, the software pointer must be set to zero - * (function uart_clr_rx_index() must be called). + * Clear the uart receive software pointer, this function must be called + * after wakeup from power-saving mode or reset uart. * * Parameters: + * uart_num - the uart hardware index + * + * Returned Values: * void * + ****************************************************************************/ + +static inline void uart_clr_rx_index(int uart_num) +{ + uart_rxindex = 0; +} + +/**************************************************************************** + * Name: uart_clr_tx_index + * + * Description: + * Clear the uart transimit software pointer, this function must be called + * after wakeup from power-saving mode or reset uart. + * + * Parameters: + * uart_num - the uart hardware index + * * Returned Values: * void * ****************************************************************************/ -static inline void uart_reset(void) +static inline void uart_clr_tx_index(int uart_num) { - RESET_RST0_REG |= RESET_RST0_UART; - RESET_RST0_REG &= ~RESET_RST0_UART; + uart_txindex = 0; } /**************************************************************************** * Name: uart_reset * * Description: - * Clear the uart receive software pointer, this function must be called - * after wakeup from power-saving mode or reset uart. + * Reset the uart hardware, the software pointer must be set to zero + * (function uart_clr_rx_index() must be called). * * Parameters: * uart_num - the uart hardware index @@ -366,9 +385,12 @@ static inline void uart_reset(void) * ****************************************************************************/ -static inline void uart_clr_rx_index(int uart_num) +static inline void uart_reset(int uart_num) { - uart_rxindex = 0; + RESET_RST0_REG |= RESET_RST0_UART; + RESET_RST0_REG &= ~RESET_RST0_UART; + uart_clr_rx_index(uart_num); + uart_clr_tx_index(uart_num); } /**************************************************************************** @@ -999,7 +1021,7 @@ static int tlsr82_uart_setup(struct uart_dev_s *dev) /* Reset the uart */ - uart_reset(); + uart_reset(priv->port); /* Uart communication parameters config * TODO: unity below functions to uart_format_config() @@ -1071,10 +1093,9 @@ static int UART_RAMCODE tlsr82_interrupt(int irq, void *context, void *arg) uart_irq_clr(priv->port, UART_IRQ_CLR_RX); - /* uart_reset() clear hardware pointer, and clear software pointer */ + /* uart_reset() clear hardware and software fifo index */ - uart_reset(); - uart_clr_rx_index(priv->port); + uart_reset(priv->port); } #ifdef CONFIG_SERIAL_TXDMA