source: rtems/c/src/lib/libbsp/nios2/nios2_iss/console/console.c @ 359e537

4.104.115
Last change on this file since 359e537 was 359e537, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 30, 2009 at 5:09:41 AM

Whitespace removal.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  This file implements simple console IO via JTAG UART.
3 *
4 *  Based on no_cpu/console.c
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  Altera-specific code is
9 *  COPYRIGHT (c) 2005-2006 Kolja Waschk, rtemsdev/ixo.de
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#define NO_BSP_INIT
19
20#include <bsp.h>
21#include <rtems/libio.h>
22
23/* #define JTAG_UART_REGS ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
24
25/*  is_character_ready
26 *
27 *  If a character is available, this routine reads it and stores
28 *  it in
29 *  reads the character and stores
30 *
31 *  Input parameters: NONE
32 *
33 *  Output parameters:  NONE
34 *
35 *  Return values:
36 */
37
38bool is_character_ready(
39  char *ch
40)
41{
42    altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
43    unsigned int data = ajur->data;
44
45    if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK)
46    {
47        *ch = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK)
48              >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
49        return true;
50    };
51
52    return false;
53}
54
55void console_initialize_hardware(void)
56{
57}
58
59/*
60 *  This routine reads a character from the SOURCE.
61 *
62 *  Input parameters: NONE
63 *
64 *  Output parameters:  NONE
65 *
66 *  Return values:
67 *    character read from SOURCE
68 */
69
70int console_inbyte_nonblocking(
71  int port
72)
73{
74  char ch;
75  /*
76   *  Wait until a character is available.
77   */
78
79  if (is_character_ready(&ch))
80    return ch;
81  return -1;
82}
83
84/*
85 *  This routine transmits a character out the SOURCE.  It may support
86 *  XON/XOFF flow control.
87 *
88 *  Input parameters:
89 *    ch  - character to be transmitted
90 *
91 *  Output parameters:  NONE
92 */
93
94void console_outbyte_polled(
95  int  port,
96  char ch
97)
98{
99  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
100  /*
101   *  Wait for the transmitter to be ready.
102   *  Check for flow control requests and process.
103   *  Then output the character.
104   */
105
106  while ((ajur->control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
107
108  ajur->data = ch;
109}
110
111/*
112 *  *  To support printk
113 *   */
114
115#include <rtems/bspIo.h>
116
117
118ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
119
120BSP_output_char_function_type           BSP_output_char = ISS_output_char;
121BSP_polling_getchar_function_type       BSP_poll_char = NULL;
122
Note: See TracBrowser for help on using the repository browser.