You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/01 13:34:55 UTC

[mynewt-core] branch master updated: hw/mcu/da1469x: Improve UART TX isr handling

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

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d79774  hw/mcu/da1469x: Improve UART TX isr handling
3d79774 is described below

commit 3d79774c56d1ce22bf8a9e9b83ef6f124a702306
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Jan 31 14:15:09 2022 +0100

    hw/mcu/da1469x: Improve UART TX isr handling
    
    1. Set TX threshold for FIFO at 1/4 full so we can start pushing bytes
       before it's completely empty.
    2. Delay tx_done callback until last byte left THR.
---
 hw/mcu/dialog/da1469x/src/hal_uart.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_uart.c b/hw/mcu/dialog/da1469x/src/hal_uart.c
index 2e802cd..0f09f97 100644
--- a/hw/mcu/dialog/da1469x/src/hal_uart.c
+++ b/hw/mcu/dialog/da1469x/src/hal_uart.c
@@ -143,6 +143,12 @@ da1469x_uart_tx_intr_disable(struct da1469x_uart *uart)
 }
 
 static inline void
+da1469x_uart_tx_pthre_intr_disable(struct da1469x_uart *uart)
+{
+    uart->regs->UART2_IER_DLH_REG &= ~UART2_UART2_IER_DLH_REG_PTIME_DLH7_Msk;
+}
+
+static inline void
 da1469x_uart_rx_intr_enable(struct da1469x_uart *uart)
 {
     uart->regs->UART2_IER_DLH_REG |= UART2_UART2_IER_DLH_REG_ERBFI_DLH0_Msk;
@@ -183,15 +189,19 @@ da1469x_uart_isr_thr_empty(struct da1469x_uart *uart)
 
     regs = uart->regs;
 
+    if (!uart->tx_started) {
+        da1469x_uart_tx_intr_disable(uart);
+        if (uart->tx_done) {
+            uart->tx_done(uart->func_arg);
+        }
+        return;
+    }
+
     while (regs->UART2_USR_REG & UART2_UART2_USR_REG_UART_TFNF_Msk) {
         ch = uart->tx_func(uart->func_arg);
         if (ch < 0) {
-            da1469x_uart_tx_intr_disable(uart);
+            da1469x_uart_tx_pthre_intr_disable(uart);
             uart->tx_started = 0;
-            if (uart->tx_done) {
-                uart->tx_done(uart->func_arg);
-            }
-
             break;
         }
 
@@ -571,7 +581,7 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
     /* Enable hardware FIFO */
     regs->UART2_SFE_REG = UART2_UART2_SFE_REG_UART_SHADOW_FIFO_ENABLE_Msk;
     regs->UART2_SRT_REG = 0;
-    regs->UART2_STET_REG = 0;
+    regs->UART2_STET_REG = 3;
 
     /* Enable flow-control if requested and supported */
     if (flow_ctl == HAL_UART_FLOW_CTL_RTS_CTS) {