source: rtems/c/src/lib/libbsp/arm/lm3s69xx/console/uart.c @ e263c16

4.11
Last change on this file since e263c16 was e263c16, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 24, 2011 at 1:23:42 PM

2011-09-24 Sebastian Huber <sebastian.huber@…>

  • 0001-Fixed-interrupt-handling-for-ARMv7M.patch, 0002-Fixed-system-handler-priority-register-access.patch, 0003-Disable-priority_mask-unused-for-NVIC.patch, 0004-Typo.patch, 0005-Evil-hack-for-BASEPRI-BASEPRI_MAX.patch, 0006-Evil-hack-to-increase-the-RAM-size.patch, bsp_specs, ChangeLog?, clock/clock-config.c, configure.ac, console/console-config.c, console/uart.c, .cvsignore, include/bsp.h, include/.cvsignore, include/irq.h, include/lm3s69xx.h, include/uart.h, irq/irq.c, make/custom/lm3s6965.cfg, make/custom/lm3s69xx.inc, Makefile.am, README, start/start.S, startup/bspreset.c, startup/bspstart.c, startup/bspstarthook.c, startup/linkcmds.lm3s6965, timer/timer.c: New files.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * Copyright (c) 2011 Sebastian Huber.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.com/license/LICENSE.
13 *
14 * $Id$
15 */
16
17#include <bspopts.h>
18#include <bsp/uart.h>
19#include <libchip/sersupp.h>
20
21static volatile lm3s69xx_uart *get_uart_regs(int minor)
22{
23  console_tbl *ct = &Console_Port_Tbl [minor];
24
25  return (lm3s69xx_uart *) ct->ulCtrlPort1;
26}
27
28static void initialize(int minor)
29{
30  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
31
32  uart->ctl = 0;
33  uart->lcrh = UARTLCRH_WLEN(0x3) | UARTLCRH_FEN;
34  uart->ctl = UARTCTL_RXE | UARTCTL_TXE | UARTCTL_UARTEN;
35}
36
37static int first_open(int major, int minor, void *arg)
38{
39  rtems_libio_open_close_args_t *oc = (rtems_libio_open_close_args_t *) arg;
40  struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
41  console_tbl *ct = &Console_Port_Tbl [minor];
42  console_data *cd = &Console_Port_Data [minor];
43
44  cd->termios_data = tty;
45  rtems_termios_set_initial_baud(tty, LM3S69XX_UART_BAUD);
46
47  return 0;
48}
49
50static int last_close(int major, int minor, void *arg)
51{
52  return 0;
53}
54
55static int read_polled(int minor)
56{
57  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
58
59  if ((uart->fr & UARTFR_RXFE) != 0) {
60    return -1;
61  } else {
62    return UARTDR_DATA(uart->dr);
63  }
64}
65
66static void write_polled(int minor, char c)
67{
68  volatile lm3s69xx_uart *uart = get_uart_regs(minor);
69
70  while ((uart->fr & UARTFR_TXFF) != 0) {
71    /* Wait */
72  }
73
74  uart->dr = UARTDR_DATA(c);
75}
76
77static ssize_t write_support_polled(
78  int minor,
79  const char *s,
80  size_t n
81)
82{
83  ssize_t i = 0;
84
85  for (i = 0; i < n; ++i) {
86    write_polled(minor, s [i]);
87  }
88
89  return n;
90}
91
92static int set_attribues(int minor, const struct termios *term)
93{
94  return -1;
95}
96
97console_fns lm3s69xx_uart_fns = {
98  .deviceProbe = libchip_serial_default_probe,
99  .deviceFirstOpen = first_open,
100  .deviceLastClose = last_close,
101  .deviceRead = read_polled,
102  .deviceWrite = write_support_polled,
103  .deviceInitialize = initialize,
104  .deviceWritePolled = write_polled,
105  .deviceSetAttributes = set_attribues,
106  .deviceOutputUsesInterrupts = false
107};
Note: See TracBrowser for help on using the repository browser.