1 //==========================================================================
3 // io/serial/arm/arm_lpc2xxx_ser.inl
5 // ARM LPC2XXX Serial I/O definitions
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
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.
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
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.
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.
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####
42 // Contributors: gthomas, jlarmour
44 // Purpose: LPC2XXX Serial I/O module (interrupt driven version)
47 //####DESCRIPTIONEND####
49 //==========================================================================
51 #include <cyg/hal/hal_intr.h>
53 //-----------------------------------------------------------------------------
54 // Baud rate specification
56 static unsigned int select_baud[] = {
81 // we need dynamically generated divider values because they depend on the
82 // value of pclk which in turn is changeable
84 #define CYG_IO_SERIAL_GENERIC_16X5X_BAUD_GENERATOR \
85 CYG_HAL_ARM_LPC2XXX_BAUD_GENERATOR
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
93 #if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE > 0
95 lpc2xxx_serial_out_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
97 lpc2xxx_serial_in_buf0[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL0_BUFSIZE];
99 static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel0,
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)
113 static SERIAL_CHANNEL(lpc2xxx_serial_channel0,
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
124 DEVTAB_ENTRY(lpc2xxx_serial_io0,
125 CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL0_NAME,
126 0, // Does not depend on a lower
128 &cyg_io_serial_devio,
130 pc_serial_lookup, // Serial driver may need initializing
131 &lpc2xxx_serial_channel0
133 #endif // CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL0
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
140 #if CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE > 0
142 lpc2xxx_serial_out_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
144 lpc2xxx_serial_in_buf1[CYGNUM_IO_SERIAL_ARM_LPC2XXX_SERIAL1_BUFSIZE];
146 static SERIAL_CHANNEL_USING_INTERRUPTS(lpc2xxx_serial_channel1,
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)
160 static SERIAL_CHANNEL(lpc2xxx_serial_channel1,
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
171 DEVTAB_ENTRY(lpc2xxx_serial_io1,
172 CYGDAT_IO_SERIAL_ARM_LPC2XXX_SERIAL1_NAME,
173 0, // Does not depend on a lower
175 &cyg_io_serial_devio,
177 pc_serial_lookup, // Serial driver may need initializing
178 &lpc2xxx_serial_channel1
180 #endif // CYGPKG_IO_SERIAL_ARM_LPC2XXX_SERIAL1
182 // EOF arm_lpc2xxx_ser.inl