source: rtems/c/src/lib/libbsp/mips/csb350/console/console-io.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  This file contains the hardware specific portions of the TTY driver
3 *  for the serial ports on the csb350.
4 *
5 *  Logic based on the jmr3904-io.c file in newlib 1.8.2
6 *
7 *  COPYRIGHT (c) 1989-2000.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp.h>
16#include <rtems/libio.h>
17#include <libcpu/au1x00.h>
18
19/*
20 *  console_initialize_hardware
21 *
22 *  This routine initializes the console hardware.
23 *
24 */
25
26void console_initialize_hardware(void)
27{
28    uart0->fifoctrl = 0xf1;   /* enable fifo, max sizes */
29    au_sync();
30}
31
32
33/*
34 *  console_outbyte_polled
35 *
36 *  This routine transmits a character using polling.
37 */
38
39void console_outbyte_polled(
40  int  port,
41  char ch
42)
43{
44    /* wait for the fifo to make room */
45    while ((uart0->linestat & 0x20) == 0) {
46        continue;
47    }
48
49    uart0->txdata = ch;
50    au_sync();
51}
52
53/*
54 *  console_inbyte_nonblocking
55 *
56 *  This routine polls for a character.
57 */
58
59int console_inbyte_nonblocking(
60  int port
61)
62{
63  unsigned char c;
64
65  if (uart0->linestat & 1) {
66      c = (char)uart0->rxdata;
67      return c;
68  } else {
69      return -1;
70  }
71}
72
73#include <rtems/bspIo.h>
74
75void csb250_output_char(char c)
76{
77    console_outbyte_polled( 0, c );
78    if (c == '\n') {
79        console_outbyte_polled( 0, '\r' );
80    }
81}
82
83int csb250_get_char(void)
84{
85  return console_inbyte_nonblocking(0);
86}
87
88BSP_output_char_function_type           BSP_output_char = csb250_output_char;
89BSP_polling_getchar_function_type       BSP_poll_char = csb250_get_char;
90
Note: See TracBrowser for help on using the repository browser.