Back to home page

LXR

 
 

    


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

0001 /*
0002  *  COPYRIGHT (c) 1989-1999.
0003  *  On-Line Applications Research Corporation (OAR).
0004  *
0005  *  The license and distribution terms for this file may be
0006  *  found in the file LICENSE in this distribution or at
0007  *  http://www.rtems.org/license/LICENSE.
0008  */
0009 
0010 #include <bsp.h>
0011 #include <rtems/libio.h>
0012 #include <stdlib.h>
0013 
0014 /*
0015  *  console_outbyte_polled
0016  *
0017  *  This routine transmits a character using polling.
0018  */
0019 void console_outbyte_polled(
0020   int  port,
0021   unsigned char ch
0022 )
0023 {
0024   if ( port == 0 ) {
0025     while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) == 0 );
0026     ERC32_MEC.UART_Channel_A = (unsigned int) ch;
0027     return;
0028   }
0029 
0030   while ( (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) == 0 );
0031   ERC32_MEC.UART_Channel_B = (unsigned int) ch;
0032 }
0033 
0034 /*
0035  *  console_inbyte_nonblocking
0036  *
0037  *  This routine polls for a character.
0038  */
0039 int console_inbyte_nonblocking( int port )
0040 {
0041   int UStat;
0042 
0043   UStat = ERC32_MEC.UART_Status;
0044 
0045   switch (port) {
0046 
0047     case 0:
0048       if (UStat & ERC32_MEC_UART_STATUS_ERRA) {
0049         ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
0050         ERC32_MEC.Control = ERC32_MEC.Control;
0051       }
0052 
0053       if ((UStat & ERC32_MEC_UART_STATUS_DRA) == 0)
0054          return -1;
0055       return (int) ERC32_MEC.UART_Channel_A;
0056 
0057     case 1:
0058       if (UStat & ERC32_MEC_UART_STATUS_ERRB) {
0059         ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
0060         ERC32_MEC.Control = ERC32_MEC.Control;
0061       }
0062 
0063       if ((UStat & ERC32_MEC_UART_STATUS_DRB) == 0)
0064         return -1;
0065       return (int) ERC32_MEC.UART_Channel_B;
0066 
0067     default:
0068       rtems_fatal_error_occurred( 'D' << 8 | (port & 0xffffff) );
0069   }
0070 
0071   return -1;
0072 }
0073 
0074 /*
0075  *  To support printk
0076  */
0077 
0078 #include <rtems/bspIo.h>
0079 
0080 static void BSP_output_char_f(char c) { console_outbyte_polled( 0, c ); }
0081 
0082 BSP_output_char_function_type           BSP_output_char = BSP_output_char_f;
0083 BSP_polling_getchar_function_type       BSP_poll_char = NULL;