Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:08

0001 /**
0002  * @file
0003  * @ingroup RTEMSBSPsSPARCLEON2
0004  * @brief TTY driver for the serial ports on the LEON
0005  */
0006 
0007 /*
0008  *  This file contains the TTY driver for the serial ports on the LEON.
0009  *
0010  *  This driver uses the termios pseudo driver.
0011  *
0012  *  COPYRIGHT (c) 1989-1999.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  *  The license and distribution terms for this file may be
0016  *  found in the file LICENSE in this distribution or at
0017  *  http://www.rtems.org/license/LICENSE.
0018  */
0019 
0020 #include <bsp.h>
0021 #include <rtems/bspIo.h>
0022 
0023 void console_outbyte_polled( int port, unsigned char ch )
0024 {
0025   if ( port == 0 ) {
0026     while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 );
0027     LEON_REG.UART_Channel_1 = (unsigned int) ch;
0028     return;
0029   }
0030 
0031   while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 );
0032   LEON_REG.UART_Channel_2 = (unsigned int) ch;
0033 }
0034 
0035 int console_inbyte_nonblocking( int port )
0036 {
0037   if ( port == 0 ) {
0038     if (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_ERR) {
0039       LEON_REG.UART_Status_1 = ~LEON_REG_UART_STATUS_ERR;
0040     }
0041 
0042     if ((LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_DR) == 0)
0043        return -1;
0044     return (int) LEON_REG.UART_Channel_1;
0045   }
0046 
0047   if (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_ERR) {
0048     LEON_REG.UART_Status_2 = ~LEON_REG_UART_STATUS_ERR;
0049   }
0050 
0051   if ((LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_DR) == 0)
0052      return -1;
0053   return (int) LEON_REG.UART_Channel_2;
0054 }
0055 
0056 static void bsp_out_char( char c )
0057 {
0058   console_outbyte_polled( 0, c );
0059 }
0060 
0061 BSP_output_char_function_type BSP_output_char = bsp_out_char;
0062 
0063 static int bsp_in_char( void )
0064 {
0065   return console_inbyte_nonblocking( 0 );
0066 }
0067 
0068 BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;