source:
rtems/c/src/lib/libbsp/sparc/leon3/console/debugputs.c
@
1348869f
Last change on this file since 1348869f was 1348869f, checked in by Joel Sherrill <joel.sherrill@…>, on 10/05/05 at 19:26:00 | |
---|---|
|
|
File size: 2.3 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 | * Modified for LEON3 BSP. |
10 | * COPYRIGHT (c) 2004. |
11 | * Gaisler Research. |
12 | * |
13 | * The license and distribution terms for this file may be |
14 | * found in the file LICENSE in this distribution or at |
15 | * http://www.rtems.com/license/LICENSE. |
16 | * |
17 | * $Id$ |
18 | */ |
19 | |
20 | #include <bsp.h> |
21 | #include <rtems/libio.h> |
22 | #include <stdlib.h> |
23 | #include <assert.h> |
24 | |
25 | /* |
26 | * console_outbyte_polled |
27 | * |
28 | * This routine transmits a character using polling. |
29 | */ |
30 | |
31 | void console_outbyte_polled( |
32 | int port, |
33 | unsigned char ch |
34 | ) |
35 | { |
36 | if ((port >= 0) && (port <= CONFIGURE_NUMBER_OF_TERMIOS_PORTS)) |
37 | { |
38 | while ( (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_THE) == 0 ); |
39 | LEON3_Console_Uart[port]->data = (unsigned int) ch; |
40 | } |
41 | } |
42 | |
43 | /* |
44 | * console_inbyte_nonblocking |
45 | * |
46 | * This routine polls for a character. |
47 | */ |
48 | |
49 | int console_inbyte_nonblocking( int port ) |
50 | { |
51 | |
52 | if ((port >=0) && (port < CONFIGURE_NUMBER_OF_TERMIOS_PORTS)) |
53 | { |
54 | |
55 | if (LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_ERR) { |
56 | LEON3_Console_Uart[port]->status = ~LEON_REG_UART_STATUS_ERR; |
57 | } |
58 | |
59 | if ((LEON3_Console_Uart[port]->status & LEON_REG_UART_STATUS_DR) == 0) |
60 | return -1; |
61 | return (int) LEON3_Console_Uart[port]->data; |
62 | } |
63 | |
64 | else |
65 | { |
66 | assert( 0 ); |
67 | } |
68 | |
69 | return -1; |
70 | } |
71 | |
72 | /* |
73 | * DEBUG_puts |
74 | * |
75 | * This should be safe in the event of an error. It attempts to insure |
76 | * that no TX empty interrupts occur while it is doing polled IO. Then |
77 | * it restores the state of that external interrupt. |
78 | * |
79 | * Input parameters: |
80 | * string - pointer to debug output string |
81 | * |
82 | * Output parameters: NONE |
83 | * |
84 | * Return values: NONE |
85 | */ |
86 | |
87 | void DEBUG_puts( |
88 | char *string |
89 | ) |
90 | { |
91 | char *s; |
92 | /* unsigned32 old_level; */ |
93 | |
94 | /* LEON_Disable_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); */ |
95 | sparc_disable_interrupts(); |
96 | LEON3_Console_Uart[0]->ctrl = LEON_REG_UART_CTRL_TE; |
97 | for ( s = string ; *s ; s++ ) |
98 | console_outbyte_polled( 0, *s ); |
99 | |
100 | console_outbyte_polled( 0, '\r' ); |
101 | console_outbyte_polled( 0, '\n' ); |
102 | sparc_enable_interrupts(); |
103 | /* LEON_Restore_interrupt( LEON_INTERRUPT_UART_1_RX_TX, old_level ); */ |
104 | } |
Note: See TracBrowser
for help on using the repository browser.