|
0
|
1 #ifndef CYGONCE_DEVS_SERIAL_RS232_MN10300_SERIAL_MN10300_2_HXX |
|
|
2 #define CYGONCE_DEVS_SERIAL_RS232_MN10300_SERIAL_MN10300_2_HXX |
|
|
3 |
|
|
4 //========================================================================== |
|
|
5 // |
|
|
6 // serial_mn10300_2.hxx |
|
|
7 // |
|
|
8 // Header file for the mn10300 serial port #2 |
|
|
9 // |
|
|
10 //========================================================================== |
|
|
11 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //========================================================================== |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): proven |
|
|
36 // Contributors: proven |
|
|
37 // Date: 1998-04-22 |
|
|
38 // Purpose: Define Cyg_Device_Serial_mn10300_2 data structure |
|
|
39 // Description: This file contains the C++ class declaration of |
|
|
40 // Cyg_Device_Serial_mn10300_2. There can be only one. |
|
|
41 // Usage: #include <cyg/devs/serial/rs232/mn10300/serial_mn10300_2.hxx> |
|
|
42 // |
|
|
43 //####DESCRIPTIONEND#### |
|
|
44 // |
|
|
45 //========================================================================== |
|
|
46 |
|
|
47 #include <pkgconf/devs.h> // Device configureation file |
|
|
48 |
|
|
49 #ifdef CYG_DEVICE_SERIAL_RS232_MN10300_2 |
|
|
50 // Include Configureation options specific to the device |
|
|
51 #include CYG_DEVICE_SERIAL_RS232_MN10300_2 |
|
|
52 |
|
|
53 #include <cyg/kernel/ktypes.h> |
|
|
54 #include <cyg/infra/cyg_ass.h> // assertion macros |
|
|
55 #include <cyg/infra/cyg_trac.h> // tracing macros |
|
|
56 |
|
|
57 #include <cyg/kernel/intr.hxx> // Cyg_ISR, Cyg_DSR |
|
|
58 #include <cyg/kernel/sched.hxx> // intr.hxx |
|
|
59 #include <cyg/kernel/sched.inl> // intr.hxx |
|
|
60 #include <cyg/hal/hal_intr.h> // vectors |
|
|
61 #ifdef CYG_DEVICE_SERIAL_RS232_MUTEX |
|
|
62 #include <cyg/kernel/mutex.hxx> |
|
|
63 #endif |
|
|
64 #include <cyg/devs/serial/rs232/common/rs232.hxx> |
|
|
65 |
|
|
66 // ------------------------------------------------------------------------- |
|
|
67 // The mn10300 serial 2 device is unique. |
|
|
68 |
|
|
69 #ifdef CYG_DEVICE_INTERNAL |
|
|
70 // Define the serial registers. |
|
|
71 #define CYG_DEVICE_SERIAL_RS232_CR ((volatile cyg_uint16 *)0x34000820) |
|
|
72 #define CYG_DEVICE_SERIAL_RS232_ICR ((volatile cyg_uint8 *) 0x34000824) |
|
|
73 #define CYG_DEVICE_SERIAL_RS232_TXR ((volatile cyg_uint8 *) 0x34000828) |
|
|
74 #define CYG_DEVICE_SERIAL_RS232_RXR ((volatile cyg_uint8 *) 0x34000829) |
|
|
75 |
|
|
76 #define CYG_DEVICE_SERIAL_RS232_SR_ADDR 0x3400082c |
|
|
77 #define CYG_DEVICE_SERIAL_RS232_SR_SIZE cyg_uint8 |
|
|
78 #define CYG_DEVICE_SERIAL_RS232_SR \ |
|
|
79 ((volatile CYG_DEVICE_SERIAL_RS232_SR_SIZE *) CYG_DEVICE_SERIAL_RS232_SR_ADDR) |
|
|
80 |
|
|
81 #define CYG_DEVICE_SERIAL_RS232_TR ((volatile cyg_uint8 *) 0x3400082d) |
|
|
82 |
|
|
83 // Timer 2 provides the baud rate divisor for serial 2 exclusivly |
|
|
84 #define TIMER2_MD ((volatile cyg_uint8 *)0x34001002) |
|
|
85 #define TIMER2_BR ((volatile cyg_uint8 *)0x34001012) |
|
|
86 #define TIMER2_CR ((volatile cyg_uint8 *)0x34001022) |
|
|
87 |
|
|
88 #define PORT3_MD ((volatile cyg_uint8 *)0x36008025) |
|
|
89 |
|
|
90 |
|
|
91 #define CYG_DEVICE_SERIAL_RS232_TVEC CYG_VECTOR_SERIAL_2_TX |
|
|
92 #define CYG_DEVICE_SERIAL_RS232_RVEC CYG_VECTOR_SERIAL_2_RX |
|
|
93 |
|
|
94 // Here are the values for the timers to set the various baud rates |
|
|
95 // Timer 1 is the serial 2 timer register (division ratio 2) |
|
|
96 // The values for 9600, 19200 and 38400 match thos used by CygMon. |
|
|
97 // (Matsushita suggested values in comment.) |
|
|
98 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B0 0 |
|
|
99 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B600 126 |
|
|
100 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B1200 125 |
|
|
101 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B2400 124 |
|
|
102 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B4800 124 |
|
|
103 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B9600 70 // 119 |
|
|
104 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B19200 70 // 111 |
|
|
105 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B38400 22 // 97 |
|
|
106 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B57600 88 |
|
|
107 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B115200 64 |
|
|
108 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B230400 64 |
|
|
109 #define CYG_DEVICE_SERIAL_RS232_T1_VALUE_B460800 32 |
|
|
110 |
|
|
111 // Timer 2 is the 8 bit timer 2 register (division ratio 1) |
|
|
112 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B0 0 |
|
|
113 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B600 196 |
|
|
114 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B1200 98 |
|
|
115 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B2400 49 |
|
|
116 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B4800 24 |
|
|
117 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B9600 21 // 12 |
|
|
118 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B19200 10 // 6 |
|
|
119 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B38400 16 // 3 |
|
|
120 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B57600 2 |
|
|
121 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B115200 1 |
|
|
122 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B230400 0 |
|
|
123 #define CYG_DEVICE_SERIAL_RS232_T2_VALUE_B460800 0 |
|
|
124 |
|
|
125 // Now set the default baudrate |
|
|
126 #ifndef CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE |
|
|
127 #error "Must specify a default baud rate" |
|
|
128 #else |
|
|
129 #if ((CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE > 0) && \ |
|
|
130 (CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE < 600)) |
|
|
131 #error "Baud rates less than 600 are not supported for the mn10300 at this time" |
|
|
132 #endif |
|
|
133 #define CYG_DEVICE_SERIAL_RS232_DEFAULT_BAUD_RATE \ |
|
|
134 CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE |
|
|
135 #endif // CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE |
|
|
136 |
|
|
137 #include <cyg/devs/serial/rs232/common/baud.h> |
|
|
138 |
|
|
139 #endif // CYG_DEVICE_INTERNAL |
|
|
140 |
|
|
141 // ------------------------------------------------------------------------- |
|
|
142 // Cyg_Device_Serial_RS232_mn10300_2 |
|
|
143 |
|
|
144 #define CYG_CLASS_DEVICE_SERIAL_RS232_MN10300_2 Cyg_Device_Serial_RS232_mn10300_2 |
|
|
145 |
|
|
146 class CYG_CLASS_DEVICE_SERIAL_RS232_MN10300_2 |
|
|
147 : public Cyg_Device_Serial_RS232 |
|
|
148 { |
|
|
149 #ifdef CYG_DEVICE_INTERNAL |
|
|
150 #include <cyg/devs/serial/rs232/common/rs232.ht> |
|
|
151 #endif |
|
|
152 |
|
|
153 protected: |
|
|
154 /* Internal routines */ |
|
|
155 cyg_int32 io_read(Cyg_IORB * iorb); |
|
|
156 cyg_int32 io_write(Cyg_IORB * iorb); |
|
|
157 void io_write_flush(void); |
|
|
158 |
|
|
159 public: |
|
|
160 |
|
|
161 /* Constructor */ |
|
|
162 CYG_CLASS_DEVICE_SERIAL_RS232_MN10300_2(); |
|
|
163 |
|
|
164 cyg_int32 io_read_cancel(Cyg_IORB * iorb); |
|
|
165 cyg_int32 io_write_cancel(Cyg_IORB * iorb); |
|
|
166 |
|
|
167 cyg_int32 io_read_assert(Cyg_IORB * iorb); |
|
|
168 cyg_int32 io_write_assert(Cyg_IORB * iorb); |
|
|
169 cyg_int32 io_read_blocking(Cyg_IORB * iorb); |
|
|
170 cyg_int32 io_write_blocking(Cyg_IORB * iorb); |
|
|
171 cyg_int32 io_read_asynchronous(Cyg_IORB * iorb); |
|
|
172 cyg_int32 io_write_asynchronous(Cyg_IORB * iorb); |
|
|
173 |
|
|
174 cyg_int32 set_kmode(cyg_uint32); |
|
|
175 cyg_int32 get_kmode(void); |
|
|
176 |
|
|
177 cyg_int32 set_baud_rate(cyg_uint32); |
|
|
178 cyg_int32 get_baud_rate(void); |
|
|
179 |
|
|
180 cyg_int32 set_line_mode(cyg_uint32); |
|
|
181 cyg_int32 get_line_mode(void); |
|
|
182 |
|
|
183 #ifdef CYG_DEVICE_SERIAL_RS232_MN10300_2_READ_MODES |
|
|
184 cyg_int32 set_read_mode(cyg_uint32); |
|
|
185 cyg_int32 set_read_data(cyg_uint32 /* mode */, const char * /* data */, cyg_uint32 /* count */); |
|
|
186 #endif |
|
|
187 #ifdef CYG_DEVICE_SERIAL_RS232_MN10300_2_WRITE_MODES |
|
|
188 cyg_int32 set_write_mode(cyg_uint32); |
|
|
189 #endif |
|
|
190 }; |
|
|
191 |
|
|
192 // Declare exported variables |
|
|
193 #ifdef CYG_DEVICE_SERIAL_RS232_MN10300_2_NAME |
|
|
194 #ifdef CYG_DEVICE_SERIAL_RS232_MN10300_2_DECLARE |
|
|
195 extern CYG_CLASS_DEVICE_SERIAL_RS232_MN10300_2 CYG_DEVICE_SERIAL_RS232_MN10300_2_NAME; |
|
|
196 #endif |
|
|
197 #endif |
|
|
198 |
|
|
199 #endif // CYG_DEVICE_SERIAL_RS232_MN10300_2 |
|
|
200 |
|
|
201 #endif // CYGONCE_DEVS_SERIAL_RS232_MN10300_SERIAL_MN10300_2_HXX |
|
|
202 // End of serial_mn10300_2.hxx |
|
|
203 |