OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [or32/] [uart.c] - Diff between revs 207 and 399

Show entire file | Details | Blame | View Log

Rev 207 Rev 399
Line 67... Line 67...
 
 
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Initialize the UART                                                        */
/*!Initialize the UART                                                        */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void
void
_uart_init ()
__uart_init ()
{
{
        int divisor;
        int divisor;
 
 
        /* Reset receiver and transmiter */
        /* Reset receiver and transmiter */
        UREG8 (UART_FCR) = UART_FCR_ENABLE_FIFO |
        UREG8 (UART_FCR) = UART_FCR_ENABLE_FIFO |
Line 91... Line 91...
        UREG8 (UART_LCR) |= UART_LCR_DLAB;
        UREG8 (UART_LCR) |= UART_LCR_DLAB;
        UREG8 (UART_DLL)  = divisor & 0x000000ff;
        UREG8 (UART_DLL)  = divisor & 0x000000ff;
        UREG8 (UART_DLM)  = (divisor >> 8) & 0x000000ff;
        UREG8 (UART_DLM)  = (divisor >> 8) & 0x000000ff;
        UREG8 (UART_LCR) &= ~(UART_LCR_DLAB);
        UREG8 (UART_LCR) &= ~(UART_LCR_DLAB);
 
 
}       /* _uart_init () */
}       /* __uart_init () */
 
 
 
 
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Put a character out on the UART
/*!Put a character out on the UART
 
 
   @param[in] c  The character to output                                      */
   @param[in] c  The character to output                                      */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void _uart_putc (char  c)
void __uart_putc (char  c)
{
{
  unsigned char lsr;
  unsigned char lsr;
 
 
  /* Wait until we are free to transmit */
  /* Wait until we are free to transmit */
  WAIT_FOR_THRE;
  WAIT_FOR_THRE;
 
 
  /* Put the character to be transmitted and wait until it has gone. */
  /* Put the character to be transmitted and wait until it has gone. */
  UREG8 (UART_TX) = c;
  UREG8 (UART_TX) = c;
  WAIT_FOR_XMITR;
  WAIT_FOR_XMITR;
 
 
}       /* _uart_putc () */
}       /* __uart_putc () */
 
 
 
 
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/*!Get a character from the UART
/*!Get a character from the UART
 
 
   @reurn  The character read.                                                */
   @reurn  The character read.                                                */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
char
char
_uart_getc ()
__uart_getc ()
{
{
  unsigned char lsr;
  unsigned char lsr;
  char c;
  char c;
 
 
  /* Wait until a char is available, then get it. */
  /* Wait until a char is available, then get it. */
  WAIT_FOR_CHAR;
  WAIT_FOR_CHAR;
 
 
  return  UREG8 (UART_RX);
  return  UREG8 (UART_RX);
 
 
}       /* _uart_getc () */
}       /* __uart_getc () */
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.