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

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

commit 0f1701da1d1dcee4a256a420e7c2b4d466a62c80
Author: Ricard Rosson <[email protected]>
AuthorDate: Fri Nov 27 05:02:29 2026 +0000

    arch/xtensa/esp32s3: Fix the masks of esp32s3_qspi_setmode().
    
    esp32s3_qspi_setmode() changed SPI_MISC_REG and SPI_USER_REG with
    "regval &= MASK" where "regval &= ~MASK" was meant.  So it cleared
    every bit of the two registers except the one it was about to set:
    
    * SPI_CS1_DIS and SPI_CS2_DIS of SPI_MISC_REG and SPI_USR_MOSI and
      SPI_CS_HOLD of SPI_USER_REG, set by esp32s3_qspi_init(), were lost.
    
    * SPI_CK_IDLE_EDGE and SPI_CK_OUT_EDGE could be set but not cleared,
      so a change from mode 3 to mode 0 left the clock idle high.
    
    Mode 0 is the mode after the initialization, and setting it again
    does nothing, so only the users of another mode were affected.
    
    Clear only the bit that is changed.
    
    Assisted-by: Claude Code:claude-fable-5-2
    Signed-off-by: Ricard Rosson <[email protected]>
---
 arch/xtensa/src/esp32s3/esp32s3_qspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/src/esp32s3/esp32s3_qspi.c 
b/arch/xtensa/src/esp32s3/esp32s3_qspi.c
index 0a98eb0d7d0..11bacbfc78a 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_qspi.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_qspi.c
@@ -650,12 +650,12 @@ static void esp32s3_qspi_setmode(struct qspi_dev_s *dev,
         }
 
       regval  = getreg32(SPI_MISC_REG(id));
-      regval &= SPI_CK_IDLE_EDGE_M;
+      regval &= ~SPI_CK_IDLE_EDGE_M;
       regval |= ck_idle_edge << SPI_CK_IDLE_EDGE_S;
       putreg32(regval, SPI_MISC_REG(id));
 
       regval  = getreg32(SPI_USER_REG(id));
-      regval &= SPI_CK_OUT_EDGE_M;
+      regval &= ~SPI_CK_OUT_EDGE_M;
       regval |= ck_out_edge << SPI_CK_OUT_EDGE_S;
       putreg32(regval, SPI_USER_REG(id));
 

Reply via email to