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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [sparc/] [erc32/] [console/] [debugputs.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  This file contains the TTY driver for the serial ports on the erc32.
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: debugputs.c,v 1.2 2001-09-27 12:01:13 chris 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
  char ch
30
)
31
{
32
  if ( port == 0 ) {
33
    while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) == 0 );
34
    ERC32_MEC.UART_Channel_A = (int) ch;
35
    return;
36
  }
37
 
38
  while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 );
39
  ERC32_MEC.UART_Channel_B = (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
  int UStat;
51
 
52
  UStat = ERC32_MEC.UART_Status;
53
 
54
  switch (port) {
55
 
56
    case 0:
57
      if (UStat & ERC32_MEC_UART_STATUS_ERRA) {
58
        ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
59
        ERC32_MEC.Control = ERC32_MEC.Control;
60
      }
61
 
62
      if ((UStat & ERC32_MEC_UART_STATUS_DRA) == 0)
63
         return -1;
64
      return (int) ERC32_MEC.UART_Channel_A;
65
      return 1;
66
 
67
    case 1:
68
      if (UStat & ERC32_MEC_UART_STATUS_ERRB) {
69
        ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
70
        ERC32_MEC.Control = ERC32_MEC.Control;
71
      }
72
 
73
      if ((UStat & ERC32_MEC_UART_STATUS_DRB) == 0)
74
        return -1;
75
      return (int) ERC32_MEC.UART_Channel_B;
76
 
77
    default:
78
      assert( 0 );
79
  }
80
 
81
  return -1;
82
}
83
 
84
/*
85
 *  DEBUG_puts
86
 *
87
 *  This should be safe in the event of an error.  It attempts to insure
88
 *  that no TX empty interrupts occur while it is doing polled IO.  Then
89
 *  it restores the state of that external interrupt.
90
 *
91
 *  Input parameters:
92
 *    string  - pointer to debug output string
93
 *
94
 *  Output parameters:  NONE
95
 *
96
 *  Return values:      NONE
97
 */
98
 
99
void DEBUG_puts(
100
  char *string
101
)
102
{
103
  char *s;
104
  unsigned32 old_level;
105
 
106
  ERC32_Disable_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level );
107
    for ( s = string ; *s ; s++ )
108
      console_outbyte_polled( 0, *s );
109
 
110
    console_outbyte_polled( 0, '\r' );
111
    console_outbyte_polled( 0, '\n' );
112
  ERC32_Restore_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level );
113
}

powered by: WebSVN 2.1.0

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