1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// io/serial/arm/arm_lpc2xxx_ser.inl
|
4 |
|
|
//
|
5 |
|
|
// ARM LPC2XXX Serial I/O definitions
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): jani
|
43 |
|
|
// Contributors: gthomas, jlarmour
|
44 |
|
|
// Date: 1999-02-04
|
45 |
|
|
// Purpose: LPC2XXX Serial I/O module (interrupt driven version)
|
46 |
|
|
// Description:
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//==========================================================================
|
51 |
|
|
|
52 |
|
|
#include
|
53 |
|
|
|
54 |
|
|
//-----------------------------------------------------------------------------
|
55 |
|
|
// Baud rate specification
|
56 |
|
|
|
57 |
|
|
static unsigned int select_baud[] = {
|
58 |
|
|
9999, // Unused
|
59 |
|
|
50,
|
60 |
|
|
75,
|
61 |
|
|
110,
|
62 |
|
|
134.5,
|
63 |
|
|
150,
|
64 |
|
|
200,
|
65 |
|
|
300,
|
66 |
|
|
600,
|
67 |
|
|
1200,
|
68 |
|
|
1800,
|
69 |
|
|
2400,
|
70 |
|
|
3600,
|
71 |
|
|
4800,
|
72 |
|
|
7200,
|
73 |
|
|
9600,
|
74 |
|
|
14400,
|
75 |
|
|
19200,
|
76 |
|
|
38400,
|
77 |
|
|
57600,
|
78 |
|
|
115200,
|
79 |
|
|
230400
|
80 |
|
|
};
|
81 |
|
|
|
82 |
|
|
// we need dynamically generated divider values because they depend on the
|
83 |
|
|
// value of pclk which in turn is changeable
|
84 |
|
|
|
85 |
|
|
#define CYG_IO_SERIAL_GENERIC_16X5X_BAUD_GENERATOR \
|
86 |
|
|
CYG_HAL_ARM_LPC2XXX_BAUD_GENERATOR
|
87 |
|
|
|
88 |
|
|
#ifdef CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0
|
89 |
|
|
static pc_serial_info lpc2xxx_serial_info0 =
|
90 |
|
|
{ CYGARC_HAL_LPC2XXX_REG_UART0_BASE,
|
91 |
|
|
CYGNUM_HAL_INTERRUPT_UART0,
|
92 |
|
|
CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_INTPRIO
|
93 |
|
|
};
|
94 |
|
|
|
95 |
|
|
#if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE > 0
|
96 |
|
|
static unsigned char
|
97 |
|
|
lpc2xxx_serial_out_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
|
98 |
|
|
static unsigned char
|
99 |
|
|
lpc2xxx_serial_in_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
|
100 |
|
|
|
101 |
|
|
static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel0,
|
102 |
|
|
pc_serial_funs,
|
103 |
|
|
lpc2xxx_serial_info0,
|
104 |
|
|
CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BAUD),
|
105 |
|
|
CYG_SERIAL_STOP_DEFAULT,
|
106 |
|
|
CYG_SERIAL_PARITY_DEFAULT,
|
107 |
|
|
CYG_SERIAL_WORD_LENGTH_DEFAULT,
|
108 |
|
|
CYG_SERIAL_FLAGS_DEFAULT,
|
109 |
|
|
&lpc2xxx_serial_out_buf0[0],
|
110 |
|
|
sizeof(lpc2xxx_serial_out_buf0),
|
111 |
|
|
&lpc2xxx_serial_in_buf0[0],
|
112 |
|
|
sizeof(lpc2xxx_serial_in_buf0)
|
113 |
|
|
);
|
114 |
|
|
#else
|
115 |
|
|
static SERIAL_CHANNEL(lpc2xxx_serial_channel0,
|
116 |
|
|
pc_serial_funs,
|
117 |
|
|
lpc2xxx_serial_info0,
|
118 |
|
|
CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BAUD),
|
119 |
|
|
CYG_SERIAL_STOP_DEFAULT,
|
120 |
|
|
CYG_SERIAL_PARITY_DEFAULT,
|
121 |
|
|
CYG_SERIAL_WORD_LENGTH_DEFAULT,
|
122 |
|
|
CYG_SERIAL_FLAGS_DEFAULT
|
123 |
|
|
);
|
124 |
|
|
#endif
|
125 |
|
|
|
126 |
|
|
DEVTAB_ENTRY(lpc2xxx_serial_io0,
|
127 |
|
|
CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL0_NAME,
|
128 |
|
|
0, // Does not depend on a lower
|
129 |
|
|
// level interface
|
130 |
|
|
&cyg_io_serial_devio,
|
131 |
|
|
pc_serial_init,
|
132 |
|
|
pc_serial_lookup, // Serial driver may need initializing
|
133 |
|
|
&lpc2xxx_serial_channel0
|
134 |
|
|
);
|
135 |
|
|
#endif // CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0
|
136 |
|
|
|
137 |
|
|
#ifdef CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL1
|
138 |
|
|
static pc_serial_info lpc2xxx_serial_info1 =
|
139 |
|
|
{ CYGARC_HAL_LPC2XXX_REG_UART1_BASE,
|
140 |
|
|
CYGNUM_HAL_INTERRUPT_UART1,
|
141 |
|
|
CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_INTPRIO
|
142 |
|
|
};
|
143 |
|
|
#if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE > 0
|
144 |
|
|
static unsigned char
|
145 |
|
|
lpc2xxx_serial_out_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
|
146 |
|
|
static unsigned char
|
147 |
|
|
lpc2xxx_serial_in_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
|
148 |
|
|
|
149 |
|
|
static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel1,
|
150 |
|
|
pc_serial_funs,
|
151 |
|
|
lpc2xxx_serial_info1,
|
152 |
|
|
CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BAUD),
|
153 |
|
|
CYG_SERIAL_STOP_DEFAULT,
|
154 |
|
|
CYG_SERIAL_PARITY_DEFAULT,
|
155 |
|
|
CYG_SERIAL_WORD_LENGTH_DEFAULT,
|
156 |
|
|
CYG_SERIAL_FLAGS_DEFAULT,
|
157 |
|
|
&lpc2xxx_serial_out_buf1[0],
|
158 |
|
|
sizeof(lpc2xxx_serial_out_buf1),
|
159 |
|
|
&lpc2xxx_serial_in_buf1[0],
|
160 |
|
|
sizeof(lpc2xxx_serial_in_buf1)
|
161 |
|
|
);
|
162 |
|
|
#else
|
163 |
|
|
static SERIAL_CHANNEL(lpc2xxx_serial_channel1,
|
164 |
|
|
pc_serial_funs,
|
165 |
|
|
lpc2xxx_serial_info1,
|
166 |
|
|
CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BAUD),
|
167 |
|
|
CYG_SERIAL_STOP_DEFAULT,
|
168 |
|
|
CYG_SERIAL_PARITY_DEFAULT,
|
169 |
|
|
CYG_SERIAL_WORD_LENGTH_DEFAULT,
|
170 |
|
|
CYG_SERIAL_FLAGS_DEFAULT
|
171 |
|
|
);
|
172 |
|
|
#endif
|
173 |
|
|
|
174 |
|
|
DEVTAB_ENTRY(lpc2xxx_serial_io1,
|
175 |
|
|
CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL1_NAME,
|
176 |
|
|
0, // Does not depend on a lower
|
177 |
|
|
// level interface
|
178 |
|
|
&cyg_io_serial_devio,
|
179 |
|
|
pc_serial_init,
|
180 |
|
|
pc_serial_lookup, // Serial driver may need initializing
|
181 |
|
|
&lpc2xxx_serial_channel1
|
182 |
|
|
);
|
183 |
|
|
#endif // CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL1
|
184 |
|
|
|
185 |
|
|
// EOF arm_lpc2xxx_ser.inl
|