From eec7aaab9321dc576d1d8f08a4688bc5d47c7dbb Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 20 May 2010 13:06:48 +0000 Subject: 2010-05-20 Sebastian Huber * include/uart-output-char.h, src/uart-output-char.c: New files. --- c/src/lib/libbsp/shared/ChangeLog | 4 ++ c/src/lib/libbsp/shared/include/uart-output-char.h | 57 ++++++++++++++++++++++ c/src/lib/libbsp/shared/src/uart-output-char.c | 44 +++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 c/src/lib/libbsp/shared/include/uart-output-char.h create mode 100644 c/src/lib/libbsp/shared/src/uart-output-char.c (limited to 'c') diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog index 011cf2e866..3292fcb941 100644 --- a/c/src/lib/libbsp/shared/ChangeLog +++ b/c/src/lib/libbsp/shared/ChangeLog @@ -1,3 +1,7 @@ +2010-05-20 Sebastian Huber + + * include/uart-output-char.h, src/uart-output-char.c: New files. + 2010-04-30 Sebastian Huber * include/irq-config.h: Removed file. diff --git a/c/src/lib/libbsp/shared/include/uart-output-char.h b/c/src/lib/libbsp/shared/include/uart-output-char.h new file mode 100644 index 0000000000..2fbfb89e93 --- /dev/null +++ b/c/src/lib/libbsp/shared/include/uart-output-char.h @@ -0,0 +1,57 @@ +/** + * @file + * + * @ingroup bsp_kit + * + * @brief Output character definitions for standard UARTs. + */ + +/* + * Copyright (c) 2010 + * embedded brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifndef LIBBSP_SHARED_UART_OUTPUT_CHAR_H +#define LIBBSP_SHARED_UART_OUTPUT_CHAR_H + +#include + +#include + +#define CONSOLE_RBR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x00)) +#define CONSOLE_THR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x00)) +#define CONSOLE_DLL (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x00)) +#define CONSOLE_DLM (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x04)) +#define CONSOLE_IER (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x04)) +#define CONSOLE_IIR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x08)) +#define CONSOLE_FCR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x08)) +#define CONSOLE_LCR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x0C)) +#define CONSOLE_LSR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x14)) +#define CONSOLE_SCR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x1C)) +#define CONSOLE_ACR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x20)) +#define CONSOLE_ICR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x24)) +#define CONSOLE_FDR (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x28)) +#define CONSOLE_TER (*(volatile uint32_t *) (BSP_CONSOLE_UART_BASE + 0x30)) + +#define CONSOLE_LSR_THRE 0x20 + +#define BSP_CONSOLE_UART_INIT(dll) \ + do { \ + CONSOLE_LCR = 0x00; \ + CONSOLE_IER = 0x00; \ + CONSOLE_LCR = 0x80; \ + CONSOLE_DLL = (dll); \ + CONSOLE_DLM = 0x00; \ + CONSOLE_LCR = 0x03; \ + CONSOLE_FCR = 0x07; \ + } while (0) + +#endif /* LIBBSP_SHARED_UART_OUTPUT_CHAR_H */ diff --git a/c/src/lib/libbsp/shared/src/uart-output-char.c b/c/src/lib/libbsp/shared/src/uart-output-char.c new file mode 100644 index 0000000000..8619db038f --- /dev/null +++ b/c/src/lib/libbsp/shared/src/uart-output-char.c @@ -0,0 +1,44 @@ +/** + * @file + * + * @ingroup bsp_kit + * + * @brief Output character implementation for standard UARTs. + */ + +/* + * Copyright (c) 2010 + * embedded brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include + +#include + +static void uart_output(char c) +{ + while ((CONSOLE_LSR & CONSOLE_LSR_THRE) == 0) { + /* Wait */ + } + + CONSOLE_THR = c; +} + +static void output(char c) +{ + if (c == '\n') { + uart_output('\r'); + } + + uart_output(c); +} + +BSP_output_char_function_type BSP_output_char = output; -- cgit v1.2.3