source: rtems/bsps/m68k/csb360/console/console-io.c @ d7d66d7

5
Last change on this file since d7d66d7 was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 19, 2018 at 4:28:01 AM

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  This file contains the hardware specific portions of the TTY driver
3 *  for the serial ports on the mcf5272
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 <mcf5272/mcf5272.h>
19
20volatile int g_cnt = 0;
21
22/*
23 *  console_initialize_hardware
24 *
25 *  This routine initializes the console hardware.
26 *
27 */
28
29void console_initialize_hardware(void)
30{
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    uart_regs_t *uart;
46    int i;
47    if (port == 0) {
48        uart = g_uart0_regs;
49    } else {
50        uart = g_uart1_regs;
51    }
52
53    /* wait for the fifo to make room */
54/*    while ((uart->usr & MCF5272_USR_TXRDY) == 0) { */
55    while ((uart->ucsr & MCF5272_USR_TXRDY) == 0) {
56        continue;
57    }
58
59    uart->udata = ch;
60    for (i = 0; i < 1000; i++) g_cnt++;
61}
62
63/*
64 *  console_inbyte_nonblocking
65 *
66 *  This routine polls for a character.
67 */
68
69int console_inbyte_nonblocking(
70  int port
71)
72{
73    uart_regs_t *uart;
74    unsigned char c;
75
76    if (port == 0) {
77        uart = g_uart0_regs;
78    } else {
79        uart = g_uart1_regs;
80    }
81
82/*    if (uart->usr & MCF5272_USR_RXRDY) { */
83    if (uart->ucsr & MCF5272_USR_RXRDY) {
84        c = (char)uart->udata;
85        return c;
86    } else {
87        return -1;
88    }
89}
90
91#include <rtems/bspIo.h>
92
93static void mcf5272_output_char(char c) { console_outbyte_polled( 0, c ); }
94
95BSP_output_char_function_type           BSP_output_char = mcf5272_output_char;
96BSP_polling_getchar_function_type       BSP_poll_char = NULL;
97
Note: See TracBrowser for help on using the repository browser.