source: rtems/bsps/arm/tms570/console/printk-support.c @ d7d66d7

5
Last change on this file since d7d66d7 was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/18 at 04:28:01

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file printk-support.c
3 *
4 * @ingroup tms570
5 *
6 * @brief definitions of serial line for debugging.
7 */
8
9/*
10 * Copyright (c) 2014 Premysl Houdek <kom541000@gmail.com>
11 *
12 * Google Summer of Code 2014 at
13 * Czech Technical University in Prague
14 * Zikova 1903/4
15 * 166 36 Praha 6
16 * Czech Republic
17 *
18 * Based on LPC24xx and LPC1768 BSP
19 * by embedded brains GmbH and others
20 *
21 * The license and distribution terms for this file may be
22 * found in the file LICENSE in this distribution or at
23 * http://www.rtems.org/license/LICENSE.
24 */
25
26#include <rtems/bspIo.h>
27#include <rtems/sysinit.h>
28#include <stdint.h>
29#include <string.h>
30#include <bsp/tms570-sci.h>
31#include <bsp/tms570-sci-driver.h>
32
33#define TMS570_CONSOLE (&driver_context_table[0])
34
35/**
36 * @brief Puts chars into peripheral
37 *
38 * debug functions always use serial dev 0 peripheral
39 *
40 * @retval Void
41 */
42static void tms570_debug_console_putc(char ch)
43{
44  tms570_sci_context *ctx = TMS570_CONSOLE;
45  volatile tms570_sci_t *regs = ctx->regs;
46  rtems_interrupt_level level;
47
48  rtems_interrupt_disable(level);
49  while ( ( regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {
50    rtems_interrupt_flash(level);
51  }
52  regs->TD = ch;
53  while ( ( regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0) {
54    rtems_interrupt_flash(level);
55  }
56  rtems_interrupt_enable(level);
57}
58
59/**
60 * @brief debug console output
61 *
62 * debug functions always use serial dev 0 peripheral
63 *
64 * @retval Void
65 */
66static void tms570_debug_console_out(char c)
67{
68  tms570_debug_console_putc(c);
69}
70
71static void tms570_debug_console_init(void)
72{
73  tms570_sci_context *ctx = TMS570_CONSOLE;
74  struct termios term;
75
76  tms570_sci_initialize(ctx);
77  memset(&term, 0, sizeof(term));
78  term.c_cflag = B115200;
79  tms570_sci_set_attributes(&ctx->base, &term);
80  BSP_output_char = tms570_debug_console_out;
81}
82
83static void tms570_debug_console_early_init(char c)
84{
85  tms570_debug_console_init();
86  tms570_debug_console_out(c);
87}
88
89/**
90 * @brief debug console input
91 *
92 * debug functions always use serial dev 0 peripheral
93 *
94 * @retval x Read char
95 * @retval -1 No input character available
96 */
97static int tms570_debug_console_in( void )
98{
99  tms570_sci_context *ctx = TMS570_CONSOLE;
100  volatile tms570_sci_t *regs = ctx->regs;
101  rtems_interrupt_level level;
102  int c;
103
104  rtems_interrupt_disable(level);
105
106  if ( regs->FLR & TMS570_SCI_FLR_RXRDY ) {
107      c = (unsigned char) regs->RD;
108  } else {
109      c = -1;
110  }
111
112  rtems_interrupt_enable(level);
113
114  return c;
115}
116
117BSP_output_char_function_type BSP_output_char =
118  tms570_debug_console_early_init;
119
120BSP_polling_getchar_function_type BSP_poll_char = tms570_debug_console_in;
121
122RTEMS_SYSINIT_ITEM(
123  tms570_debug_console_init,
124  RTEMS_SYSINIT_BSP_START,
125  RTEMS_SYSINIT_ORDER_LAST
126);
Note: See TracBrowser for help on using the repository browser.