source: rtems/c/src/lib/libbsp/sparc/leon2/console/debugputs.c @ 064820c

4.115
Last change on this file since 064820c was 8d830fae, checked in by Radu <radustoma@…>, on 12/02/13 at 20:07:35

leon2_doxygen_1

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon2
4 * @brief TTY driver for the serial ports on the LEON
5 */
6
7/*
8 *  This file contains the TTY driver for the serial ports on the LEON.
9 *
10 *  This driver uses the termios pseudo driver.
11 *
12 *  COPYRIGHT (c) 1989-1999.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.com/license/LICENSE.
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
31void console_outbyte_polled(
32  int  port,
33  unsigned char ch
34)
35{
36  if ( port == 0 ) {
37    while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 );
38      LEON_REG.UART_Channel_1 = (unsigned int) ch;
39      return;
40    }
41
42    while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 );
43    LEON_REG.UART_Channel_2 = (unsigned int) ch;
44}
45
46/*
47 *  console_inbyte_nonblocking
48 *
49 *  This routine polls for a character.
50 */
51
52int console_inbyte_nonblocking( int port )
53{
54
55  switch (port) {
56
57    case 0:
58      if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
59        LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
60      }
61
62      if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
63         return -1;
64      return (int) LEON_REG.UART_Channel_1;
65      return 1;
66
67    case 1:
68      if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
69        LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
70      }
71
72      if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
73         return -1;
74      return (int) LEON_REG.UART_Channel_2;
75
76    default:
77      assert( 0 );
78  }
79
80  return -1;
81}
Note: See TracBrowser for help on using the repository browser.