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 <stdint.h> |
---|
28 | #include <bsp/tms570-sci.h> |
---|
29 | #include <bsp/tms570-sci-driver.h> |
---|
30 | |
---|
31 | |
---|
32 | /** |
---|
33 | * @brief Puts chars into peripheral |
---|
34 | * |
---|
35 | * debug functions always use serial dev 0 peripheral |
---|
36 | * |
---|
37 | * @retval Void |
---|
38 | */ |
---|
39 | static void tms570_putc(char ch) |
---|
40 | { |
---|
41 | rtems_interrupt_level level; |
---|
42 | |
---|
43 | rtems_interrupt_disable(level); |
---|
44 | while ( ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) { |
---|
45 | rtems_interrupt_flash(level); |
---|
46 | } |
---|
47 | driver_context_table[0].regs->TD = ch; |
---|
48 | rtems_interrupt_enable(level); |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * @brief debug console output |
---|
53 | * |
---|
54 | * debug functions always use serial dev 0 peripheral |
---|
55 | * |
---|
56 | * @retval Void |
---|
57 | */ |
---|
58 | static void tms570_uart_output(char c) |
---|
59 | { |
---|
60 | if ( c == '\n' ) { |
---|
61 | char r = '\r'; |
---|
62 | tms570_putc(r); |
---|
63 | } |
---|
64 | tms570_putc(c); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * @brief debug console input |
---|
69 | * |
---|
70 | * debug functions always use serial dev 0 peripheral |
---|
71 | * |
---|
72 | * @retval x Read char |
---|
73 | * @retval -1 No input character available |
---|
74 | */ |
---|
75 | static int tms570_uart_input( void ) |
---|
76 | { |
---|
77 | if ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_RXRDY ) { |
---|
78 | return driver_context_table[0].regs->RD; |
---|
79 | } else { |
---|
80 | return -1; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | BSP_output_char_function_type BSP_output_char = tms570_uart_output; |
---|
85 | BSP_polling_getchar_function_type BSP_poll_char = tms570_uart_input; |
---|