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

4.115
Last change on this file since 6279149 was 6279149, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 8, 2014 at 9:04:56 PM

Add console-polled.h and update all BSPs that should use it.

The file console-polled.h provides the prototypes for the three
required methods when implementing a single port polled console
driver. This paradigm is common on simulators and simple hardware.

+ Updated the BSPs Makefile.am to make console-polled.h available.
+ Regenerated the BSPs preinstall.sm.
+ Updated console support files to include <bsp/console-polled.h>.
+ Updated console support files to make printk() support method static.

  • 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
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 <bsp/console-polled.h>
17#include <rtems/libio.h>
18#include <libcpu/au1x00.h>
19
20/*
21 *  console_initialize_hardware
22 *
23 *  This routine initializes the console hardware.
24 *
25 */
26
27void console_initialize_hardware(void)
28{
29    uart0->fifoctrl = 0xf1;   /* enable fifo, max sizes */
30    au_sync();
31}
32
33
34/*
35 *  console_outbyte_polled
36 *
37 *  This routine transmits a character using polling.
38 */
39
40void console_outbyte_polled(
41  int  port,
42  char ch
43)
44{
45    /* wait for the fifo to make room */
46    while ((uart0->linestat & 0x20) == 0) {
47        continue;
48    }
49
50    uart0->txdata = ch;
51    au_sync();
52}
53
54/*
55 *  console_inbyte_nonblocking
56 *
57 *  This routine polls for a character.
58 */
59
60int console_inbyte_nonblocking(
61  int port
62)
63{
64  unsigned char c;
65
66  if (uart0->linestat & 1) {
67      c = (char)uart0->rxdata;
68      return c;
69  } else {
70      return -1;
71  }
72}
73
74#include <rtems/bspIo.h>
75
76void csb250_output_char(char c)
77{
78    console_outbyte_polled( 0, c );
79    if (c == '\n') {
80        console_outbyte_polled( 0, '\r' );
81    }
82}
83
84static int csb250_get_char(void)
85{
86  return console_inbyte_nonblocking(0);
87}
88
89BSP_output_char_function_type           BSP_output_char = csb250_output_char;
90BSP_polling_getchar_function_type       BSP_poll_char = csb250_get_char;
91
Note: See TracBrowser for help on using the repository browser.