1 |
27 |
unneback |
#ifndef CYGONCE_ARM_AEB_SERIAL_H
|
2 |
|
|
#define CYGONCE_ARM_AEB_SERIAL_H
|
3 |
|
|
|
4 |
|
|
// ====================================================================
|
5 |
|
|
//
|
6 |
|
|
// aeb_serial.h
|
7 |
|
|
//
|
8 |
|
|
// Device I/O - Description of ARM AEB-1 serial hardware
|
9 |
|
|
//
|
10 |
|
|
// ====================================================================
|
11 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
21 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License along
|
26 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
30 |
|
|
// or inline functions from this file, or you compile this file and link it
|
31 |
|
|
// with other works to produce a work based on this file, this file does not
|
32 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
33 |
|
|
// License. However the source code for this file must still be made available
|
34 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
37 |
|
|
// this file might be covered by the GNU General Public License.
|
38 |
|
|
//
|
39 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
40 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
43 |
|
|
// ====================================================================
|
44 |
|
|
//#####DESCRIPTIONBEGIN####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): gthomas
|
47 |
|
|
// Contributors: gthomas
|
48 |
|
|
// Date: 1999-02-04
|
49 |
|
|
// Purpose: Internal interfaces for serial I/O drivers
|
50 |
|
|
// Description:
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
// ====================================================================
|
55 |
|
|
|
56 |
|
|
// Description of serial ports on ARM AEB-1
|
57 |
|
|
|
58 |
|
|
struct serial_port {
|
59 |
|
|
unsigned char _byte[32];
|
60 |
|
|
};
|
61 |
|
|
|
62 |
|
|
#define REG(n) _byte[n*4]
|
63 |
|
|
|
64 |
|
|
// Receive control registers
|
65 |
|
|
#define REG_RHR REG(0) // Receive holding register
|
66 |
|
|
#define REG_ISR REG(2) // Interrupt status register
|
67 |
|
|
#define REG_LSR REG(5) // Line status register
|
68 |
|
|
#define REG_MSR REG(6) // Modem status register
|
69 |
|
|
#define REG_SCR REG(7) // Scratch register
|
70 |
|
|
|
71 |
|
|
// Transmit control registers
|
72 |
|
|
#define REG_THR REG(0) // Transmit holding register
|
73 |
|
|
#define REG_IER REG(1) // Interrupt enable register
|
74 |
|
|
#define REG_FCR REG(2) // FIFO control register
|
75 |
|
|
#define REG_LCR REG(3) // Line control register
|
76 |
|
|
#define REG_MCR REG(4) // Modem control register
|
77 |
|
|
#define REG_LDL REG(0) // LSB of baud rate
|
78 |
|
|
#define REG_MDL REG(1) // MSB of baud rate
|
79 |
|
|
|
80 |
|
|
// Interrupt Enable Register
|
81 |
|
|
#define IER_RCV 0x01
|
82 |
|
|
#define IER_XMT 0x02
|
83 |
|
|
#define IER_LS 0x04
|
84 |
|
|
#define IER_MS 0x08
|
85 |
|
|
|
86 |
|
|
// Line Control Register
|
87 |
|
|
#define LCR_WL5 0x00 // Word length
|
88 |
|
|
#define LCR_WL6 0x01
|
89 |
|
|
#define LCR_WL7 0x02
|
90 |
|
|
#define LCR_WL8 0x03
|
91 |
|
|
#define LCR_SB1 0x00 // Number of stop bits
|
92 |
|
|
#define LCR_SB1_5 0x04 // 1.5 -> only valid with 5 bit words
|
93 |
|
|
#define LCR_SB2 0x04
|
94 |
|
|
#define LCR_PN 0x00 // Parity mode - none
|
95 |
|
|
#define LCR_PE 0x0C // Parity mode - even
|
96 |
|
|
#define LCR_PO 0x08 // Parity mode - odd
|
97 |
|
|
#define LCR_PM 0x28 // Forced "mark" parity
|
98 |
|
|
#define LCR_PS 0x38 // Forced "space" parity
|
99 |
|
|
#define LCR_DL 0x80 // Enable baud rate latch
|
100 |
|
|
|
101 |
|
|
// Line Status Register
|
102 |
|
|
#define LSR_RSR 0x01
|
103 |
|
|
#define LSR_THE 0x20
|
104 |
|
|
|
105 |
|
|
// Modem Control Register
|
106 |
|
|
#define MCR_DTR 0x01
|
107 |
|
|
#define MCR_RTS 0x02
|
108 |
|
|
#define MCR_INT 0x08 // Enable interrupts
|
109 |
|
|
|
110 |
|
|
// Interrupt status register
|
111 |
|
|
#define ISR_Tx 0x02
|
112 |
|
|
#define ISR_Rx 0x04
|
113 |
|
|
|
114 |
|
|
static unsigned char select_word_length[] = {
|
115 |
|
|
LCR_WL5, // 5 bits / word (char)
|
116 |
|
|
LCR_WL6,
|
117 |
|
|
LCR_WL7,
|
118 |
|
|
LCR_WL8
|
119 |
|
|
};
|
120 |
|
|
|
121 |
|
|
static unsigned char select_stop_bits[] = {
|
122 |
|
|
0,
|
123 |
|
|
LCR_SB1, // 1 stop bit
|
124 |
|
|
LCR_SB1_5, // 1.5 stop bit
|
125 |
|
|
LCR_SB2 // 2 stop bits
|
126 |
|
|
};
|
127 |
|
|
|
128 |
|
|
static unsigned char select_parity[] = {
|
129 |
|
|
LCR_PN, // No parity
|
130 |
|
|
LCR_PE, // Even parity
|
131 |
|
|
LCR_PO, // Odd parity
|
132 |
|
|
LCR_PM, // Mark parity
|
133 |
|
|
LCR_PS, // Space parity
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
// Baud rate values, based on raw 24MHz clock
|
137 |
|
|
|
138 |
|
|
static unsigned short select_baud[] = {
|
139 |
|
|
0, // Unused
|
140 |
|
|
10000*3, // 50
|
141 |
|
|
6667*3, // 75
|
142 |
|
|
4545*3, // 110
|
143 |
|
|
3717*3, // 134.5
|
144 |
|
|
3333*3, // 150
|
145 |
|
|
0, // 200
|
146 |
|
|
1667*3, // 300
|
147 |
|
|
833*3, // 600
|
148 |
|
|
417*3, // 1200
|
149 |
|
|
277*3, // 1800
|
150 |
|
|
208*3, // 2400
|
151 |
|
|
139*3, // 3600
|
152 |
|
|
104*3, // 4800
|
153 |
|
|
69*3, // 7200
|
154 |
|
|
52*3, // 9600
|
155 |
|
|
(69*3)/2, // 14400
|
156 |
|
|
26*3, // 19200
|
157 |
|
|
13*3, // 38400
|
158 |
|
|
26, // 57600
|
159 |
|
|
13, // 115200
|
160 |
|
|
0, // 230400
|
161 |
|
|
};
|
162 |
|
|
|
163 |
|
|
#endif // CYGONCE_ARM_AEB_SERIAL_H
|