source: rtems/c/src/lib/libbsp/lm32/shared/console/uart.c @ f68401e

4.115
Last change on this file since f68401e was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  Uart driver for Lattice Mico32 (lm32) UART
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  Jukka Pietarinen <jukka.pietarinen@mrf.fi>, 2008,
12 *  Micro-Research Finland Oy
13 */
14
15#include "../include/system_conf.h"
16#include "uart.h"
17#include <rtems/libio.h>
18
19static inline int uartread(unsigned int reg)
20{
21  return *((int*)(UART_BASE_ADDRESS + reg));
22}
23
24static inline void uartwrite(unsigned int reg, int value)
25{
26  *((int*)(UART_BASE_ADDRESS + reg)) = value;
27}
28
29void BSP_uart_init(int baud)
30{
31  /* Disable UART interrupts */
32  uartwrite(LM32_UART_IER, 0);
33
34  /* Line control 8 bit, 1 stop, no parity */
35  uartwrite(LM32_UART_LCR, LM32_UART_LCR_8BIT);
36
37  /* Modem control, DTR = 1, RTS = 1 */
38  uartwrite(LM32_UART_MCR, LM32_UART_MCR_DTR | LM32_UART_MCR_RTS);
39
40  /* Set baud rate */
41  uartwrite(LM32_UART_DIV, CPU_FREQUENCY/baud);
42}
43
44void BSP_uart_polled_write(char ch)
45{
46  /* Insert CR before LF */
47  if (ch == '\n')
48    BSP_uart_polled_write('\r');
49  /* Wait until THR is empty. */
50  while (!(uartread(LM32_UART_LSR) & LM32_UART_LSR_THRE));
51  uartwrite(LM32_UART_RBR, ch);
52}
53
54char BSP_uart_polled_read( void )
55{
56  /* Wait until there is a byte in RBR */
57  while (!(uartread(LM32_UART_LSR) & LM32_UART_LSR_DR));
58  return (char) uartread(LM32_UART_RBR);
59}
60
61char BSP_uart_is_character_ready(char *ch)
62{
63  if (uartread(LM32_UART_LSR) & LM32_UART_LSR_DR)
64    {
65      *ch = (char) uartread(LM32_UART_RBR);
66      return true;
67    }
68  *ch = '0';
69  return false;
70}
Note: See TracBrowser for help on using the repository browser.