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 3e73e3c25 hw/mcu/stm: Fix UART tx_done event
3e73e3c25 is described below

commit 3e73e3c255eefa578c4e659776106ebda67cc66b
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Tue Feb 10 00:22:32 2026 +0100

    hw/mcu/stm: Fix UART tx_done event
    
    TXE bit shall be ignored if TXEIE bit is disabled, i.e. we shall not
    handle TX data register empty if corresponding interrupt is disabled.
    
    This is because after tx_func returned last character we disable TXEIE
    but the TXE bit is be still set when we receive interrupts for e.g. TX
    complete or RX not empty. As a result we call tx_func again, we receive
    no data again, and then we call tx_done again even if subsequent TX was
    not yet started.
---
 hw/mcu/stm/stm32_common/src/hal_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/mcu/stm/stm32_common/src/hal_uart.c 
b/hw/mcu/stm/stm32_common/src/hal_uart.c
index 14e3f8f2a..cd356763c 100644
--- a/hw/mcu/stm/stm32_common/src/hal_uart.c
+++ b/hw/mcu/stm/stm32_common/src/hal_uart.c
@@ -210,7 +210,7 @@ uart_irq_handler(int num)
     }
     if (isr & (TXE | TC)) {
         cr1 = regs->CR1;
-        if (isr & TXE) {
+        if (isr & TXE && cr1 & USART_CR1_TXEIE) {
             data = u->u_tx_func(u->u_func_arg);
             if (data < 0) {
                 cr1 &= ~USART_CR1_TXEIE;

Reply via email to