You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2021/05/20 05:23:58 UTC

[incubator-nuttx] 01/21: arch: cxd56xx: Fix uart getting stuck during a clock change

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

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

commit 9b3a80cc372a4942f19e6f328f141c3712eddb1c
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Wed May 19 17:03:36 2021 +0900

    arch: cxd56xx: Fix uart getting stuck during a clock change
    
    UART driver is stopped and re-started during a clock change. When a UART
    interrupt is generated in each process, the unexpected behavior will
    occur and a console will get stuck with UART driver. This commit fixed
    each process is performed atomically.
---
 arch/arm/src/cxd56xx/cxd56_uart.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/src/cxd56xx/cxd56_uart.c b/arch/arm/src/cxd56xx/cxd56_uart.c
index b8b2f3c..3ddfac6 100644
--- a/arch/arm/src/cxd56xx/cxd56_uart.c
+++ b/arch/arm/src/cxd56xx/cxd56_uart.c
@@ -206,11 +206,15 @@ static void cxd56_uart_pincontrol(int ch, bool on)
 
 static void cxd56_uart_start(int ch)
 {
+  irqstate_t flags = enter_critical_section();
+
   cxd56_setbaud(CONSOLE_BASE, CONSOLE_BASEFREQ, CONSOLE_BAUD);
 
   putreg32(g_lcr, g_uartdevs[ch].uartbase + CXD56_UART_LCR_H);
 
   putreg32(g_cr, g_uartdevs[ch].uartbase + CXD56_UART_CR);
+
+  leave_critical_section(flags);
 }
 
 /****************************************************************************
@@ -226,6 +230,8 @@ static void cxd56_uart_stop(int ch)
 {
   uint32_t cr;
 
+  irqstate_t flags = enter_critical_section();
+
   while (UART_FR_BUSY & getreg32(g_uartdevs[ch].uartbase + CXD56_UART_FR));
 
   cr   = getreg32(g_uartdevs[ch].uartbase + CXD56_UART_CR);
@@ -235,6 +241,8 @@ static void cxd56_uart_stop(int ch)
 
   g_lcr = getreg32(g_uartdevs[ch].uartbase + CXD56_UART_LCR_H);
   putreg32(0, g_uartdevs[ch].uartbase + CXD56_UART_LCR_H);
+
+  leave_critical_section(flags);
 }
 
 /****************************************************************************