diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-05-20 13:06:48 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-05-20 13:06:48 +0000 |
commit | eec7aaab9321dc576d1d8f08a4688bc5d47c7dbb (patch) | |
tree | 989205a3414190d5bb21d0861da574a019aaf206 /c | |
parent | 2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-eec7aaab9321dc576d1d8f08a4688bc5d47c7dbb.tar.bz2 |
2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/uart-output-char.h, src/uart-output-char.c: New files.
Diffstat (limited to 'c')
-rw-r--r-- | c/src/lib/libbsp/shared/ChangeLog | 4 | ||||
-rw-r--r-- | c/src/lib/libbsp/shared/include/uart-output-char.h | 57 | ||||
-rw-r--r-- | c/src/lib/libbsp/shared/src/uart-output-char.c | 44 |
3 files changed, 105 insertions, 0 deletions
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 <sebastian.huber@embedded-brains.de> + + * include/uart-output-char.h, src/uart-output-char.c: New files. + 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de> * 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 + * <rtems@embedded-brains.de> + * + * 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 <stdint.h> + +#include <bsp.h> + +#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 + * <rtems@embedded-brains.de> + * + * 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 <rtems/bspIo.h> + +#include <bsp/uart-output-char.h> + +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; |