source: rtems/c/src/lib/libbsp/arm/lpc176x/console/console-config.c @ 2a2a1695

4.115
Last change on this file since 2a2a1695 was 19260fb, checked in by Martin Boretto <martin.boretto@…>, on 06/09/14 at 14:27:18

bsp/lpc176x: New BSP

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc176x
5 *
6 * @brief Console configuration.
7 */
8
9/*
10 * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <libchip/serial.h>
24#include <libchip/ns16550.h>
25
26#include <bsp.h>
27#include <bsp/io.h>
28#include <bsp/irq.h>
29
30/**
31 * @brief Gets the uart register according to the current address.
32 *
33 * @param  addr Register address.
34 * @param  i Index register.
35 * @return  Uart register.
36 */
37static inline uint8_t lpc176x_uart_get_register(
38  const uintptr_t addr,
39  const uint8_t   i
40)
41{
42  volatile uint32_t *reg = (volatile uint32_t *) addr;
43
44  return (uint8_t) reg[ i ];
45}
46
47/**
48 * @brief Sets the uart register address according to the value passed.
49 *
50 * @param  addr Register address.
51 * @param  i Index register.
52 * @param val Value to set.
53 */
54static inline void lpc176x_uart_set_register(
55  const uintptr_t addr,
56  const uint8_t   i,
57  const uint8_t   val
58)
59{
60  volatile uint32_t *reg = (volatile uint32_t *) addr;
61
62  reg[ i ] = val;
63}
64
65/**
66 * @brief Represents the uart configuration ports.
67 */
68console_tbl Console_Configuration_Ports[] = {
69#ifdef LPC176X_CONFIG_CONSOLE
70  {
71    .sDeviceName = "/dev/ttyS0",
72    .deviceType = SERIAL_NS16550_WITH_FDR,
73    .pDeviceFns = &ns16550_fns,
74    .deviceProbe = NULL,
75    .pDeviceFlow = NULL,
76    .ulMargin = 16,
77    .ulHysteresis = 8,
78    .pDeviceParams = (void *) LPC176X_UART_BAUD,
79    .ulCtrlPort1 = UART0_BASE_ADDR,
80    .ulCtrlPort2 = 0,
81    .ulDataPort = UART0_BASE_ADDR,
82    .getRegister = lpc176x_uart_get_register,
83    .setRegister = lpc176x_uart_set_register,
84    .getData = NULL,
85    .setData = NULL,
86    .ulClock = LPC176X_PCLK,
87    .ulIntVector = LPC176X_IRQ_UART_0
88  },
89#endif
90#ifdef LPC176X_CONFIG_UART_1
91  {
92    .sDeviceName = "/dev/ttyS1",
93    .deviceType = SERIAL_NS16550_WITH_FDR,
94    .pDeviceFns = &ns16550_fns,
95    .deviceProbe = lpc176x_uart_probe_1,
96    .pDeviceFlow = NULL,
97    .ulMargin = 16,
98    .ulHysteresis = 8,
99    .pDeviceParams = (void *) LPC176X_UART_BAUD,
100    .ulCtrlPort1 = UART1_BASE_ADDR,
101    .ulCtrlPort2 = 0,
102    .ulDataPort = UART1_BASE_ADDR,
103    .getRegister = lpc176x_uart_get_register,
104    .setRegister = lpc176x_uart_set_register,
105    .getData = NULL,
106    .setData = NULL,
107    .ulClock = LPC176X_PCLK,
108    .ulIntVector = LPC176X_IRQ_UART_1
109  },
110#endif
111#ifdef LPC176X_CONFIG_UART_2
112  {
113    .sDeviceName = "/dev/ttyS2",
114    .deviceType = SERIAL_NS16550_WITH_FDR,
115    .pDeviceFns = &ns16550_fns,
116    .deviceProbe = lpc176x_uart_probe_2,
117    .pDeviceFlow = NULL,
118    .ulMargin = 16,
119    .ulHysteresis = 8,
120    .pDeviceParams = (void *) LPC176X_UART_BAUD,
121    .ulCtrlPort1 = UART2_BASE_ADDR,
122    .ulCtrlPort2 = 0,
123    .ulDataPort = UART2_BASE_ADDR,
124    .getRegister = lpc176x_uart_get_register,
125    .setRegister = lpc176x_uart_set_register,
126    .getData = NULL,
127    .setData = NULL,
128    .ulClock = LPC176X_PCLK,
129    .ulIntVector = LPC176X_IRQ_UART_2
130  },
131#endif
132#ifdef LPC176X_CONFIG_UART_3
133  {
134    .sDeviceName = "/dev/ttyS3",
135    .deviceType = SERIAL_NS16550_WITH_FDR,
136    .pDeviceFns = &ns16550_fns,
137    .deviceProbe = lpc176x_uart_probe_3,
138    .pDeviceFlow = NULL,
139    .ulMargin = 16,
140    .ulHysteresis = 8,
141    .pDeviceParams = (void *) LPC176X_UART_BAUD,
142    .ulCtrlPort1 = UART3_BASE_ADDR,
143    .ulCtrlPort2 = 0,
144    .ulDataPort = UART3_BASE_ADDR,
145    .getRegister = lpc176x_uart_get_register,
146    .setRegister = lpc176x_uart_set_register,
147    .getData = NULL,
148    .setData = NULL,
149    .ulClock = LPC176X_PCLK,
150    .ulIntVector = LPC176X_IRQ_UART_3
151  },
152#endif
153};
154
155#define LPC176X_UART_COUNT ( sizeof( Console_Configuration_Ports ) \
156                             / sizeof( Console_Configuration_Ports[ 0 ] ) )
157
158unsigned long Console_Configuration_Count = LPC176X_UART_COUNT;
Note: See TracBrowser for help on using the repository browser.