From 388ab6c2db17e36ac1161a8e5107c7d0b45f32aa Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 20 Nov 2024 17:08:18 +0900 Subject: [PATCH] esp32s3: don't clear pending interrupts on eg. up_putc Fixes https://github.com/apache/nuttx/issues/14872 --- arch/xtensa/src/esp32s3/esp32s3_lowputc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/src/esp32s3/esp32s3_lowputc.c b/arch/xtensa/src/esp32s3/esp32s3_lowputc.c index b8c7e264c20a6..c210769e1d3a7 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_lowputc.c +++ b/arch/xtensa/src/esp32s3/esp32s3_lowputc.c @@ -825,9 +825,17 @@ void esp32s3_lowputc_disable_all_uart_int(struct esp32s3_uart_s *priv, putreg32(0, UART_INT_ENA_REG(priv->id)); - /* Clear all ints */ + /* Note: this function is used to disable interrupts temporarily, + * paired with esp32s3_lowputc_restore_all_uart_int. (eg. up_putc) + * In that case, it might not be safe to clear interrupt bits. + */ + + if (current_status == NULL) + { + /* Clear all ints */ - putreg32(0xffffffff, UART_INT_CLR_REG(priv->id)); + putreg32(0xffffffff, UART_INT_CLR_REG(priv->id)); + } spin_unlock_irqrestore(&priv->lock, flags); }