You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2020/09/05 00:39:30 UTC
[incubator-nuttx] branch master updated: stm32: lowputc: Ensure
USART is disabled before configuring
This is an automated email from the ASF dual-hosted git repository.
davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new e67f72b stm32: lowputc: Ensure USART is disabled before configuring
e67f72b is described below
commit e67f72b02ddf3915a59997e8942ae8ba4b815d89
Author: Nathan Hartman <59...@users.noreply.github.com>
AuthorDate: Fri Sep 4 17:33:06 2020 -0400
stm32: lowputc: Ensure USART is disabled before configuring
arch/arm/src/stm32/stm32_lowputc.c:
* stm32_lowsetup(): Ensure the USART is disabled before attempting
to configure it because some register bits cannot be modified
otherwise. This solves an issue that was encountered when a
serial bootloader did not perform a full teardown/cleanup before
launching NuttX.
---
arch/arm/src/stm32/stm32_lowputc.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm/src/stm32/stm32_lowputc.c b/arch/arm/src/stm32/stm32_lowputc.c
index e070c3f..9f67bcc 100644
--- a/arch/arm/src/stm32/stm32_lowputc.c
+++ b/arch/arm/src/stm32/stm32_lowputc.c
@@ -614,6 +614,18 @@ void stm32_lowsetup(void)
/* Enable and configure the selected console device */
#if defined(HAVE_CONSOLE) && !defined(CONFIG_SUPPRESS_UART_CONFIG)
+ /* Ensure the USART is disabled because some bits of the following
+ * registers cannot be modified otherwise.
+ *
+ * Although the USART is expected to be disabled at power on reset, this
+ * might not be the case if we boot from a serial bootloader that does not
+ * clean up properly.
+ */
+
+ cr = getreg32(STM32_CONSOLE_BASE + STM32_USART_CR1_OFFSET);
+ cr &= ~USART_CR1_UE;
+ putreg32(cr, STM32_CONSOLE_BASE + STM32_USART_CR1_OFFSET);
+
/* Configure CR2 */
cr = getreg32(STM32_CONSOLE_BASE + STM32_USART_CR2_OFFSET);