Swatantra-66 opened a new pull request, #21334:
URL: https://github.com/apache/nuttx/pull/21334

   ## Summary
   In `arch/arm/src/stm32wb/stm32wb_serial.c`, `stm32_serial_setformat()` 
writes the baud rate register (`BRR`) and the parity/word length bits (`PCE`, 
`PS`, `M0`, `M1`) in `CR1` while the USART is enabled (`UE = 1`).
   
   Per the ST Reference Manual (RM0434), Section 37.8 (USART Control Register 
1), bits `M1`, `M0`, `PCE`, and `PS` can only be written when the USART is 
disabled (`UE = 0`). Consequently, runtime `tcsetattr()` calls attempting to 
change the baud rate or parity/data bits return success while leaving the 
hardware USART registers completely unchanged.
   
   This patch clears `USART_CR1_UE` before the update and restores it upon 
completion inside a critical section, bringing the STM32WB serial driver into 
alignment with the approved implementations in STM32L4 (commit 47180bf5ea), 
STM32H7, and STM32F7.
   
   ## Impact
   - Hardware: STM32WB microcontrollers (e.g. NUCLEO-WB55RG, Flipper Zero).
   - Functionality: Ensures runtime serial configuration changes via 
`tcsetattr()` take effect in hardware.
   
   ## Testing
   - Verified against ST Reference Manual RM0434 (USART_CR1 bit write 
restrictions).
   - Logic aligns with merged commit 47180bf5ea (`arch/arm/src/stm32l4: disable 
the USART while changing the line format`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to