From d7c13c87728bd4766c7ffe79467267020e37cf98 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 16 Oct 2018 14:34:38 +0200 Subject: 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 0731446f08..8b8d9fbc81 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 }; -- cgit v1.2.3