[rtems commit] bsp/imx7: Add getchark() support

Sebastian Huber sebh at rtems.org
Wed Oct 17 08:03:01 UTC 2018


Module:    rtems
Branch:    master
Commit:    d7c13c87728bd4766c7ffe79467267020e37cf98
Changeset: http://git.rtems.org/rtems/commit/?id=d7c13c87728bd4766c7ffe79467267020e37cf98

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Oct 16 14:34:38 2018 +0200

bsp/imx7: Add getchark() support

---

 bsps/arm/imx/console/console-config.c | 36 +++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/bsps/arm/imx/console/console-config.c b/bsps/arm/imx/console/console-config.c
index 0731446..8b8d9fb 100644
--- a/bsps/arm/imx/console/console-config.c
+++ b/bsps/arm/imx/console/console-config.c
@@ -64,6 +64,19 @@ static void imx_uart_write_polled(rtems_termios_device_context *base, char c)
   regs->utxd = IMX_UART_UTXD_TX_DATA(c);
 }
 
+static int imx_uart_read_polled(rtems_termios_device_context *base)
+{
+  volatile imx_uart *regs;
+
+  regs = imx_uart_get_regs(base);
+
+  if ((regs->usr2 & IMX_UART_USR2_RDR) != 0) {
+    return IMX_UART_URXD_RX_DATA_GET(regs->urxd);
+  } else {
+    return -1;
+  }
+}
+
 void imx_uart_console_drain(void)
 {
   volatile imx_uart *regs;
@@ -82,6 +95,11 @@ static void imx_output_char(char c)
   imx_uart_write_polled(&imx_uart_console->base, c);
 }
 
+static int imx_poll_char(void)
+{
+  return imx_uart_read_polled(&imx_uart_console->base);
+}
+
 static void imx_uart_init_context(
   imx_uart_context *ctx,
   const char *fdt,
@@ -147,6 +165,7 @@ static void imx_uart_probe(void)
   }
 
   BSP_output_char = imx_output_char;
+  BSP_poll_char = imx_poll_char;
 }
 
 static void imx_output_char_init(char c)
@@ -315,21 +334,6 @@ static void imx_uart_write(
 #endif
 }
 
-#ifndef CONSOLE_USE_INTERRUPTS
-static int imx_uart_read(rtems_termios_device_context *base)
-{
-  volatile imx_uart *regs;
-
-  regs = imx_uart_get_regs(base);
-
-  if ((regs->usr2 & IMX_UART_USR2_RDR) != 0) {
-    return IMX_UART_URXD_RX_DATA_GET(regs->urxd);
-  } else {
-    return -1;
-  }
-}
-#endif
-
 static const rtems_termios_device_handler imx_uart_handler = {
   .first_open = imx_uart_first_open,
   .last_close = imx_uart_last_close,
@@ -338,7 +342,7 @@ static const rtems_termios_device_handler imx_uart_handler = {
 #ifdef CONSOLE_USE_INTERRUPTS
   .mode = TERMIOS_IRQ_DRIVEN
 #else
-  .poll_read = imx_uart_read,
+  .poll_read = imx_uart_read_polled,
   .mode = TERMIOS_POLLED
 #endif
 };




More information about the vc mailing list