From d7e676fd4c5afc3b4ea12a5d8c72d083fb80d134 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 21 Jul 2011 15:28:32 +0000 Subject: 2011-07-21 Sebastian Huber * include/uart-output-char.h, src/uart-output-char.c: Support for getchark(). --- c/src/lib/libbsp/shared/src/uart-output-char.c | 35 +++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'c/src/lib/libbsp/shared/src/uart-output-char.c') diff --git a/c/src/lib/libbsp/shared/src/uart-output-char.c b/c/src/lib/libbsp/shared/src/uart-output-char.c index c39def09f1..b6d07453be 100644 --- a/c/src/lib/libbsp/shared/src/uart-output-char.c +++ b/c/src/lib/libbsp/shared/src/uart-output-char.c @@ -7,12 +7,13 @@ */ /* - * Copyright (c) 2010 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * + * Copyright (c) 2010-2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -23,7 +24,7 @@ #include -static void uart_output(char c) +static void uart_output_raw(char c) { while ((CONSOLE_LSR & CONSOLE_LSR_THRE) == 0) { /* Wait */ @@ -32,14 +33,24 @@ static void uart_output(char c) CONSOLE_THR = c; } -static void output(char c) +static void uart_output(char c) { if (c == '\n') { - uart_output('\r'); + uart_output_raw('\r'); } - uart_output(c); + uart_output_raw(c); +} + +static int uart_input(void) +{ + if ((CONSOLE_LSR & CONSOLE_LSR_RDR) != 0) { + return CONSOLE_RBR; + } else { + return -1; + } } -BSP_output_char_function_type BSP_output_char = output; -BSP_polling_getchar_function_type BSP_poll_char = NULL; +BSP_output_char_function_type BSP_output_char = uart_output; + +BSP_polling_getchar_function_type BSP_poll_char = uart_input; -- cgit v1.2.3