source:
rtems/c/src/lib/libbsp/sparc/leon/console/debugputs.c
@
b21b0ab
Last change on this file since b21b0ab was b21b0ab, checked in by Joel Sherrill <joel.sherrill@…>, on 11/13/00 at 22:40:29 | |
---|---|
|
|
File size: 2.4 KB |
Line | |
---|---|
1 | /* |
2 | * This file contains the TTY driver for the serial ports on the LEON. |
3 | * |
4 | * This driver uses the termios pseudo driver. |
5 | * |
6 | * COPYRIGHT (c) 1989-1999. |
7 | * On-Line Applications Research Corporation (OAR). |
8 | * |
9 | * The license and distribution terms for this file may be |
10 | * found in the file LICENSE in this distribution or at |
11 | * http://www.OARcorp.com/rtems/license.html. |
12 | * |
13 | * $Id$ |
14 | */ |
15 | |
16 | #include <bsp.h> |
17 | #include <rtems/libio.h> |
18 | #include <stdlib.h> |
19 | #include <assert.h> |
20 | |
21 | /* |
22 | * console_outbyte_polled |
23 | * |
24 | * This routine transmits a character using polling. |
25 | */ |
26 | |
27 | void console_outbyte_polled( |
28 | int port, |
29 | char ch |
30 | ) |
31 | { |
32 | if ( port == 0 ) { |
33 | while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 ); |
34 | LEON_REG.UART_Channel_1 = (int) ch; |
35 | return; |
36 | } |
37 | |
38 | while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 ); |
39 | LEON_REG.UART_Channel_2 = (int) ch; |
40 | } |
41 | |
42 | /* |
43 | * console_inbyte_nonblocking |
44 | * |
45 | * This routine polls for a character. |
46 | */ |
47 | |
48 | int console_inbyte_nonblocking( int port ) |
49 | { |
50 | |
51 | switch (port) { |
52 | |
53 | case 0: |
54 | if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) { |
55 | LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR; |
56 | } |
57 | |
58 | if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0) |
59 | return -1; |
60 | return (int) LEON_REG.UART_Channel_1; |
61 | return 1; |
62 | |
63 | case 1: |
64 | if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) { |
65 | LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR; |
66 | } |
67 | |
68 | if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0) |
69 | return -1; |
70 | return (int) LEON_REG.UART_Channel_2; |
71 | |
72 | default: |
73 | assert( 0 ); |
74 | } |
75 | |
76 | return -1; |
77 | } |
78 | |
79 | /* |
80 | * DEBUG_puts |
81 | * |
82 | * This should be safe in the event of an error. It attempts to insure |
83 | * that no TX empty interrupts occur while it is doing polled IO. Then |
84 | * it restores the state of that external interrupt. |
85 | * |
86 | * Input parameters: |
87 | * string - pointer to debug output string |
88 | * |
89 | * Output parameters: NONE |
90 | * |
91 | * Return values: NONE |
92 | */ |
93 | |
94 | void DEBUG_puts( |
95 | char *string |
96 | ) |
97 | { |
98 | char *s; |
99 | unsigned32 old_level; |
100 | |
101 | LEON_Disable_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); |
102 | LEON_REG.UART_Control_1 = LEON_REG_UART_CTRL_TE; |
103 | for ( s = string ; *s ; s++ ) |
104 | console_outbyte_polled( 0, *s ); |
105 | |
106 | console_outbyte_polled( 0, '\r' ); |
107 | console_outbyte_polled( 0, '\n' ); |
108 | LEON_Restore_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); |
109 | } |
Note: See TracBrowser
for help on using the repository browser.