source: rtems/c/src/lib/libbsp/nios2/nios2_iss/console/console.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: 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.org/license/LICENSE.
14 */
15
16#define NO_BSP_INIT
17
18#include <bsp.h>
19#include <rtems/libio.h>
20
21/* #define JTAG_UART_REGS ((altera_avalon_jtag_uart_regs*)NIOS2_IO_BASE(JTAG_UART_BASE)) */
22
23/*  is_character_ready
24 *
25 *  If a character is available, this routine reads it and stores
26 *  it in
27 *  reads the character and stores
28 *
29 *  Input parameters: NONE
30 *
31 *  Output parameters:  NONE
32 *
33 *  Return values:
34 */
35
36bool is_character_ready(
37  char *ch
38)
39{
40    altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
41    unsigned int data = ajur->data;
42
43    if (data & ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK)
44    {
45        *ch = (data & ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK)
46              >> ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST;
47        return true;
48    };
49
50    return false;
51}
52
53void console_initialize_hardware(void)
54{
55}
56
57/*
58 *  This routine reads a character from the SOURCE.
59 *
60 *  Input parameters: NONE
61 *
62 *  Output parameters:  NONE
63 *
64 *  Return values:
65 *    character read from SOURCE
66 */
67
68int console_inbyte_nonblocking(
69  int port
70)
71{
72  char ch;
73  /*
74   *  Wait until a character is available.
75   */
76
77  if (is_character_ready(&ch))
78    return ch;
79  return -1;
80}
81
82/*
83 *  This routine transmits a character out the SOURCE.  It may support
84 *  XON/XOFF flow control.
85 *
86 *  Input parameters:
87 *    ch  - character to be transmitted
88 *
89 *  Output parameters:  NONE
90 */
91
92void console_outbyte_polled(
93  int  port,
94  char ch
95)
96{
97  altera_avalon_jtag_uart_regs *ajur = NIOS2_IO_BASE(JTAG_UART_BASE);
98  /*
99   *  Wait for the transmitter to be ready.
100   *  Check for flow control requests and process.
101   *  Then output the character.
102   */
103
104  while ((ajur->control & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) == 0);
105
106  ajur->data = ch;
107}
108
109/*
110 * To support printk
111 */
112
113#include <rtems/bspIo.h>
114
115
116void ISS_output_char(char c) { console_outbyte_polled( 0, c ); }
117
118BSP_output_char_function_type           BSP_output_char = ISS_output_char;
119BSP_polling_getchar_function_type       BSP_poll_char = NULL;
120
Note: See TracBrowser for help on using the repository browser.