1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <bsp.h> |
---|
11 | #include <rtems/libio.h> |
---|
12 | #include <stdlib.h> |
---|
13 | |
---|
14 | /* |
---|
15 | * console_outbyte_polled |
---|
16 | * |
---|
17 | * This routine transmits a character using polling. |
---|
18 | */ |
---|
19 | void console_outbyte_polled( |
---|
20 | int port, |
---|
21 | unsigned char ch |
---|
22 | ) |
---|
23 | { |
---|
24 | if ( port == 0 ) { |
---|
25 | while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) == 0 ); |
---|
26 | ERC32_MEC.UART_Channel_A = (unsigned int) ch; |
---|
27 | return; |
---|
28 | } |
---|
29 | |
---|
30 | while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 ); |
---|
31 | ERC32_MEC.UART_Channel_B = (unsigned int) ch; |
---|
32 | } |
---|
33 | |
---|
34 | /* |
---|
35 | * console_inbyte_nonblocking |
---|
36 | * |
---|
37 | * This routine polls for a character. |
---|
38 | */ |
---|
39 | int console_inbyte_nonblocking( int port ) |
---|
40 | { |
---|
41 | int UStat; |
---|
42 | |
---|
43 | UStat = ERC32_MEC.UART_Status; |
---|
44 | |
---|
45 | switch (port) { |
---|
46 | |
---|
47 | case 0: |
---|
48 | if (UStat & ERC32_MEC_UART_STATUS_ERRA) { |
---|
49 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA; |
---|
50 | ERC32_MEC.Control = ERC32_MEC.Control; |
---|
51 | } |
---|
52 | |
---|
53 | if ((UStat & ERC32_MEC_UART_STATUS_DRA) == 0) |
---|
54 | return -1; |
---|
55 | return (int) ERC32_MEC.UART_Channel_A; |
---|
56 | |
---|
57 | case 1: |
---|
58 | if (UStat & ERC32_MEC_UART_STATUS_ERRB) { |
---|
59 | ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB; |
---|
60 | ERC32_MEC.Control = ERC32_MEC.Control; |
---|
61 | } |
---|
62 | |
---|
63 | if ((UStat & ERC32_MEC_UART_STATUS_DRB) == 0) |
---|
64 | return -1; |
---|
65 | return (int) ERC32_MEC.UART_Channel_B; |
---|
66 | |
---|
67 | default: |
---|
68 | rtems_fatal_error_occurred( 'D' << 8 | (port & 0xffffff) ); |
---|
69 | } |
---|
70 | |
---|
71 | return -1; |
---|
72 | } |
---|
73 | |
---|
74 | /* |
---|
75 | * To support printk |
---|
76 | */ |
---|
77 | |
---|
78 | #include <rtems/bspIo.h> |
---|
79 | |
---|
80 | static void BSP_output_char_f(char c) { console_outbyte_polled( 0, c ); } |
---|
81 | |
---|
82 | BSP_output_char_function_type BSP_output_char = BSP_output_char_f; |
---|
83 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|