OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [sparc/] [leon/] [console/] [debugputs.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  debugputs.c,v 1.2 2001/04/23 13:19:35 joel Exp
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
  unsigned 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 = (unsigned 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 = (unsigned 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.