This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f3ddb3ffac drivers/serial: Make the 16550 rx trigger level configurable
f3ddb3ffac is described below

commit f3ddb3ffac9b00ae20f819fd9be84d983d828222
Author: Lwazi Dube <[email protected]>
AuthorDate: Fri Aug 2 16:36:09 2024 -0400

    drivers/serial: Make the 16550 rx trigger level configurable
    
    To avoid breaking other configs, the default value 2 is equal to the 
original
    hard coded value.
---
 drivers/serial/Kconfig-16550 | 20 ++++++++++++++++++++
 drivers/serial/uart_16550.c  | 13 +++++++------
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/Kconfig-16550 b/drivers/serial/Kconfig-16550
index 6d57487b7f..a5510beb2c 100644
--- a/drivers/serial/Kconfig-16550
+++ b/drivers/serial/Kconfig-16550
@@ -57,6 +57,11 @@ config 16550_UART0_2STOP
        ---help---
                0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit
 
+config 16550_UART0_RX_TRIGGER
+  int "16550 UART0 RX interrupt trigger level"
+       default 2
+       range 0 3
+
 config 16550_UART0_RXBUFSIZE
        int "16550 UART0 Rx buffer size"
        default 256
@@ -165,6 +170,11 @@ config 16550_UART1_2STOP
        ---help---
                0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit
 
+config 16550_UART1_RX_TRIGGER
+  int "16550 UART1 RX interrupt trigger level"
+       default 2
+       range 0 3
+
 config 16550_UART1_RXBUFSIZE
        int "16550 UART1 Rx buffer size"
        default 256
@@ -273,6 +283,11 @@ config 16550_UART2_2STOP
        ---help---
                0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit
 
+config 16550_UART2_RX_TRIGGER
+  int "16550 UART2 RX interrupt trigger level"
+       default 2
+       range 0 3
+
 config 16550_UART2_RXBUFSIZE
        int "16550 UART2 Rx buffer size"
        default 256
@@ -381,6 +396,11 @@ config 16550_UART3_2STOP
        ---help---
                0=1 stop bit, 1=Two stop bits.  Default: 1 stop bit
 
+config 16550_UART3_RX_TRIGGER
+  int "16550 UART3 RX interrupt trigger level"
+       default 2
+       range 0 3
+
 config 16550_UART3_RXBUFSIZE
        int "16550 UART3 Rx buffer size"
        default 256
diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c
index e03fee887d..53609720d1 100644
--- a/drivers/serial/uart_16550.c
+++ b/drivers/serial/uart_16550.c
@@ -97,6 +97,7 @@ struct u16550_s
   bool                   flow;      /* flow control (RTS/CTS) enabled */
 #endif
 #endif
+  uart_datawidth_t       rxtrigger; /* RX trigger level */
 };
 
 /****************************************************************************
@@ -226,6 +227,7 @@ static struct u16550_s g_uart0priv =
   .flow           = true,
 #endif
 #endif
+  .rxtrigger      = CONFIG_16550_UART0_RX_TRIGGER,
 };
 
 static uart_dev_t g_uart0port =
@@ -279,6 +281,7 @@ static struct u16550_s g_uart1priv =
   .flow           = true,
 #endif
 #endif
+  .rxtrigger      = CONFIG_16550_UART1_RX_TRIGGER,
 };
 
 static uart_dev_t g_uart1port =
@@ -332,6 +335,7 @@ static struct u16550_s g_uart2priv =
   .flow           = true,
 #endif
 #endif
+  .rxtrigger      = CONFIG_16550_UART2_RX_TRIGGER,
 };
 
 static uart_dev_t g_uart2port =
@@ -385,6 +389,7 @@ static struct u16550_s g_uart3priv =
   .flow           = true,
 #endif
 #endif
+  .rxtrigger      = CONFIG_16550_UART3_RX_TRIGGER,
 };
 
 static uart_dev_t g_uart3port =
@@ -759,11 +764,6 @@ static int u16550_setup(FAR struct uart_dev_s *dev)
   u16550_serialout(priv, UART_FCR_OFFSET,
                    (UART_FCR_RXRST | UART_FCR_TXRST));
 
-  /* Set trigger */
-
-  u16550_serialout(priv, UART_FCR_OFFSET,
-                   (UART_FCR_FIFOEN | UART_FCR_RXTRIGGER_8));
-
   /* Set up the IER */
 
   priv->ier = u16550_serialin(priv, UART_IER_OFFSET);
@@ -842,7 +842,8 @@ static int u16550_setup(FAR struct uart_dev_s *dev)
   /* Configure the FIFOs */
 
   u16550_serialout(priv, UART_FCR_OFFSET,
-                   (UART_FCR_RXTRIGGER_8 | UART_FCR_TXRST | UART_FCR_RXRST |
+                   (priv->rxtrigger << UART_FCR_RXTRIGGER_SHIFT |
+                    UART_FCR_TXRST | UART_FCR_RXRST |
                     UART_FCR_FIFOEN));
 
   /* Set up the auto flow control */

Reply via email to