[rtems commit] bsp/imx: Drain console before reset
Sebastian Huber
sebh at rtems.org
Thu Nov 2 10:26:16 UTC 2017
Module: rtems
Branch: master
Commit: 4b055e23e9cfc33a0d67ca3358e1e07040a599ca
Changeset: http://git.rtems.org/rtems/commit/?id=4b055e23e9cfc33a0d67ca3358e1e07040a599ca
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Nov 2 11:21:51 2017 +0100
bsp/imx: Drain console before reset
Update #3090.
---
c/src/lib/libbsp/arm/imx/console/console-config.c | 13 +++++++++++++
c/src/lib/libbsp/arm/imx/include/bsp.h | 2 ++
c/src/lib/libbsp/arm/imx/startup/bspreset.c | 4 +++-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/c/src/lib/libbsp/arm/imx/console/console-config.c b/c/src/lib/libbsp/arm/imx/console/console-config.c
index a4c79a1..f7d7820 100644
--- a/c/src/lib/libbsp/arm/imx/console/console-config.c
+++ b/c/src/lib/libbsp/arm/imx/console/console-config.c
@@ -59,6 +59,19 @@ static void imx_uart_write_polled(rtems_termios_device_context *base, char c)
regs->utxd = IMX_UART_UTXD_TX_DATA(c);
}
+void imx_uart_console_drain(void)
+{
+ volatile imx_uart *regs;
+
+ regs = imx_uart_get_regs(&imx_uart_console->base);
+
+ if (regs != NULL) {
+ while ((regs->usr2 & IMX_UART_USR2_TXFE) == 0) {
+ /* Wait */
+ }
+ }
+}
+
static void imx_output_char(char c)
{
imx_uart_write_polled(&imx_uart_console->base, c);
diff --git a/c/src/lib/libbsp/arm/imx/include/bsp.h b/c/src/lib/libbsp/arm/imx/include/bsp.h
index cfea807..b5fb712 100644
--- a/c/src/lib/libbsp/arm/imx/include/bsp.h
+++ b/c/src/lib/libbsp/arm/imx/include/bsp.h
@@ -51,6 +51,8 @@ rtems_vector_number imx_get_irq_of_node(
size_t index
);
+void imx_uart_console_drain(void);
+
/**
* @brief Registers an IMX I2C bus driver.
*
diff --git a/c/src/lib/libbsp/arm/imx/startup/bspreset.c b/c/src/lib/libbsp/arm/imx/startup/bspreset.c
index 11eb039..5e2cf39 100644
--- a/c/src/lib/libbsp/arm/imx/startup/bspreset.c
+++ b/c/src/lib/libbsp/arm/imx/startup/bspreset.c
@@ -13,13 +13,15 @@
*/
#include <bsp/bootcard.h>
-
+#include <bsp.h>
#include <arm/freescale/imx/imx_wdogreg.h>
void bsp_reset(void)
{
volatile uint16_t *pcr;
+ imx_uart_console_drain();
+
pcr = (volatile uint16_t *) 0x30280000;
*pcr &= ~WDOG_CR_SRS;
*pcr &= ~WDOG_CR_SRS;
More information about the vc
mailing list