summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/shared/src/uart-output-char.c
blob: 8619db038f1b7fd090f254b0a3cf45793127778d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;