STM32 gotchas
165.UART/USART conundrum

As we've already discussed here, UART and USART (and even LPUART) in STM32 is the same module, except UART is a "stripped-down" version with some of the features simply omitted at chip design time. Even USARTs are not all created equal, individual incarnations have an individual mix of features, again as it was configured by the chip designers.

Fact that UART and USART are just two names for the same module is underpinned by the fact, that UARTs don't have individual structs defined in the CMSIS-mandated device headers, nor symbols for its registers' bits and bitfields - they all use the USART-related structs/symbols (and again, same applies for LPUART).

However, ST stubbornly features UARTs as a different module, eg. in using different naming of modules (UARTx vs. USARTx) and different symbol names (such as RCC_APBxENR.UARTxEN vs. RCC_APBxENR.USARTxEN) - which makes automatic code generation unnecessarily harder. Also in libraries such as Cube, ST provides entirely unnecessarily separate code for UARTs and USARTs, with separate source files, separate function names etc.

This all is entirely unnecessary and superfluous, resulting in confusion and unnecessary extra work. While clearly it's a legacy burden, ST could've easily dealt with this by providing a simple but complete and concise descripition of differences between UART and USART, augmented by a "legacy translation layer" in the CMSIS-mandated device header and in any libraries.

Even ST then makes the shortcut in some documentation, and talks only about "UART" or only about "USART" ( 'L476 RM, while there is officially USART1..3 and UART4 and UART5, at several places description like "USARTx, x = 1,2,3,4,5" can be found).

Here, in gotchas, systematically, "UART" is used exclusively, to denote both UART and USART.