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