]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/serial/arm/lpc2xxx/v2_0/include/arm_lpc2xxx_ser.inl
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / devs / serial / arm / lpc2xxx / v2_0 / include / arm_lpc2xxx_ser.inl
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 #define CYG_IO_SERIAL_GENERIC_16X5X_BAUD_GENERATOR \
85             CYG_HAL_ARM_LPC2XXX_BAUD_GENERATOR 
86
87 #ifdef CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0
88 static pc_serial_info lpc2xxx_serial_info0 = 
89   { CYGARC_HAL_LPC2XXX_REG_UART0_BASE,
90     CYGNUM_HAL_INTERRUPT_UART0
91   };
92
93 #if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE > 0
94 static unsigned char 
95 lpc2xxx_serial_out_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
96 static unsigned char 
97 lpc2xxx_serial_in_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
98
99 static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel0,
100                                        pc_serial_funs, 
101                                        lpc2xxx_serial_info0,
102                                        CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BAUD),
103                                        CYG_SERIAL_STOP_DEFAULT,
104                                        CYG_SERIAL_PARITY_DEFAULT,
105                                        CYG_SERIAL_WORD_LENGTH_DEFAULT,
106                                        CYG_SERIAL_FLAGS_DEFAULT,
107                                        &lpc2xxx_serial_out_buf0[0], 
108                                        sizeof(lpc2xxx_serial_out_buf0),
109                                        &lpc2xxx_serial_in_buf0[0], 
110                                        sizeof(lpc2xxx_serial_in_buf0)
111     );
112 #else
113 static SERIAL_CHANNEL(lpc2xxx_serial_channel0,
114                       pc_serial_funs, 
115                       lpc2xxx_serial_info0,
116                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BAUD),
117                       CYG_SERIAL_STOP_DEFAULT,
118                       CYG_SERIAL_PARITY_DEFAULT,
119                       CYG_SERIAL_WORD_LENGTH_DEFAULT,
120                       CYG_SERIAL_FLAGS_DEFAULT
121     );
122 #endif
123
124 DEVTAB_ENTRY(lpc2xxx_serial_io0, 
125              CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL0_NAME,
126              0,                     // Does not depend on a lower
127                                     // level interface
128              &cyg_io_serial_devio, 
129              pc_serial_init, 
130              pc_serial_lookup,     // Serial driver may need initializing
131              &lpc2xxx_serial_channel0
132     );
133 #endif //  CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0
134
135 #ifdef CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL1
136 static pc_serial_info lpc2xxx_serial_info1 = 
137   { CYGARC_HAL_LPC2XXX_REG_UART1_BASE,
138     CYGNUM_HAL_INTERRUPT_UART1
139   };
140 #if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE > 0
141 static unsigned char 
142 lpc2xxx_serial_out_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
143 static unsigned char 
144 lpc2xxx_serial_in_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
145
146 static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel1,
147                                        pc_serial_funs, 
148                                        lpc2xxx_serial_info1,
149                                        CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BAUD),
150                                        CYG_SERIAL_STOP_DEFAULT,
151                                        CYG_SERIAL_PARITY_DEFAULT,
152                                        CYG_SERIAL_WORD_LENGTH_DEFAULT,
153                                        CYG_SERIAL_FLAGS_DEFAULT,
154                                        &lpc2xxx_serial_out_buf1[0], 
155                                        sizeof(lpc2xxx_serial_out_buf1),
156                                        &lpc2xxx_serial_in_buf1[0], 
157                                        sizeof(lpc2xxx_serial_in_buf1)
158     );
159 #else
160 static SERIAL_CHANNEL(lpc2xxx_serial_channel1,
161                       pc_serial_funs, 
162                       lpc2xxx_serial_info1,
163                       CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BAUD),
164                       CYG_SERIAL_STOP_DEFAULT,
165                       CYG_SERIAL_PARITY_DEFAULT,
166                       CYG_SERIAL_WORD_LENGTH_DEFAULT,
167                       CYG_SERIAL_FLAGS_DEFAULT
168     );
169 #endif
170
171 DEVTAB_ENTRY(lpc2xxx_serial_io1, 
172              CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL1_NAME,
173              0,                     // Does not depend on a lower
174                                     // level interface
175              &cyg_io_serial_devio, 
176              pc_serial_init, 
177              pc_serial_lookup,     // Serial driver may need initializing
178              &lpc2xxx_serial_channel1
179     );
180 #endif //  CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL1
181
182 // EOF arm_lpc2xxx_ser.inl