1 | /* |
---|
2 | * This file contains the hardware specific portions of the TTY driver |
---|
3 | * for the serial ports on the csb350. |
---|
4 | * |
---|
5 | * Logic based on the jmr3904-io.c file in newlib 1.8.2 |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-2000. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <rtems/libio.h> |
---|
19 | #include <libcpu/au1x00.h> |
---|
20 | |
---|
21 | /* |
---|
22 | * console_initialize_hardware |
---|
23 | * |
---|
24 | * This routine initializes the console hardware. |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | void console_initialize_hardware(void) |
---|
29 | { |
---|
30 | uart0->fifoctrl = 0xf1; /* enable fifo, max sizes */ |
---|
31 | au_sync(); |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | /* |
---|
36 | * console_outbyte_polled |
---|
37 | * |
---|
38 | * This routine transmits a character using polling. |
---|
39 | */ |
---|
40 | |
---|
41 | void console_outbyte_polled( |
---|
42 | int port, |
---|
43 | char ch |
---|
44 | ) |
---|
45 | { |
---|
46 | /* wait for the fifo to make room */ |
---|
47 | while ((uart0->linestat & 0x20) == 0) { |
---|
48 | continue; |
---|
49 | } |
---|
50 | |
---|
51 | uart0->txdata = ch; |
---|
52 | au_sync(); |
---|
53 | } |
---|
54 | |
---|
55 | /* |
---|
56 | * console_inbyte_nonblocking |
---|
57 | * |
---|
58 | * This routine polls for a character. |
---|
59 | */ |
---|
60 | |
---|
61 | int console_inbyte_nonblocking( |
---|
62 | int port |
---|
63 | ) |
---|
64 | { |
---|
65 | unsigned char c; |
---|
66 | |
---|
67 | if (uart0->linestat & 1) { |
---|
68 | c = (char)uart0->rxdata; |
---|
69 | return c; |
---|
70 | } else { |
---|
71 | return -1; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | #include <rtems/bspIo.h> |
---|
76 | |
---|
77 | void csb250_output_char(char c) |
---|
78 | { |
---|
79 | console_outbyte_polled( 0, c ); |
---|
80 | if (c == '\n') { |
---|
81 | console_outbyte_polled( 0, '\r' ); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | BSP_output_char_function_type BSP_output_char = csb250_output_char; |
---|
86 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|
87 | |
---|