1 | /*
|
---|
2 | * TOPPERS/JSP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Just Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | *
|
---|
9 | * ä¸è¨è使¨©è
|
---|
10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
11 | * ã«ãã£ã¦å
|
---|
12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
15 | å¸ï¼ä»¥ä¸ï¼
|
---|
16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
21 | * ç¨ã§ããå½¢ã§åé
|
---|
22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
24 | * è
|
---|
25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
30 | * ã¨ï¼
|
---|
31 | * (a) åé
|
---|
32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
34 | * 使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
35 | * (b) åé
|
---|
36 | å¸ã®å½¢æ
|
---|
37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
38 | * å ±åãããã¨ï¼
|
---|
39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
40 | * 害ãããï¼ä¸è¨è使¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
42 | 責ãããã¨ï¼
|
---|
43 | *
|
---|
44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨è使¨©è
|
---|
45 | ã
|
---|
46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id: tl16c550cfn.h,v 1.3 2003/12/04 08:25:44 honda Exp $
|
---|
51 | */
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * TL16C550CFNç¨ ç°¡æSIOãã©ã¤ã
|
---|
55 | */
|
---|
56 | #ifndef _TL16C550CFN_H_
|
---|
57 | #define _TL16C550CFN_H_
|
---|
58 |
|
---|
59 | #include <t_config.h>
|
---|
60 |
|
---|
61 | /***********************************************
|
---|
62 | * I/O ã¡ã¢ãªã»ããããã»ã¬ã¸ã¹ã¿ *
|
---|
63 | ***********************************************/
|
---|
64 | /*
|
---|
65 | * complex Programmable Logic Device (CPLD) *
|
---|
66 | * I/O ã¡ã¢ãªã»ããããã»ã¬ã¸ã¹ã¿ *
|
---|
67 | */
|
---|
68 |
|
---|
69 | /* ã¬ã¸ã¹ã¿ãã¢ãã¬ã¹ã*/
|
---|
70 | #ifndef _MACRO_ONLY
|
---|
71 | volatile ioport UH port0;
|
---|
72 | volatile ioport UH port1;
|
---|
73 | volatile ioport UH port2;
|
---|
74 | volatile ioport UH port3;
|
---|
75 | volatile ioport UH port4;
|
---|
76 | volatile ioport UH port5;
|
---|
77 | volatile ioport UH port6;
|
---|
78 | #endif /* _MACRO_ONLY */
|
---|
79 |
|
---|
80 | /* CPLDãã¬ã¸ã¹ã¿ */
|
---|
81 | #define CPLD_CTRL1 port0
|
---|
82 | #define CPLD_STAT port1
|
---|
83 | #define CPLD_DMCTRL port2
|
---|
84 | #define CPLD_DBIO port3
|
---|
85 | #define CPLD_CTRL2 port4
|
---|
86 | #define CPLD_SEM0 port5
|
---|
87 | #define CPLD_SEM1 port6
|
---|
88 |
|
---|
89 | /*
|
---|
90 | * UART I/O ã¡ã¢ãªã»ããããã»ã¬ã¸ã¹ã¿ *
|
---|
91 | */
|
---|
92 | /* ã¬ã¸ã¹ã¿ ã¢ãã¬ã¹ */
|
---|
93 | #ifndef _MACRO_ONLY
|
---|
94 | volatile ioport UH port4000;
|
---|
95 | volatile ioport UH port4001;
|
---|
96 | volatile ioport UH port4002;
|
---|
97 | volatile ioport UH port4003;
|
---|
98 | volatile ioport UH port4004;
|
---|
99 | volatile ioport UH port4005;
|
---|
100 | volatile ioport UH port4006;
|
---|
101 | volatile ioport UH port4007;
|
---|
102 | #endif /* _MACRO_ONLY */
|
---|
103 |
|
---|
104 | /* UART ã¬ã¸ã¹ã¿ */
|
---|
105 | #define UART_RBR port4000
|
---|
106 | #define UART_THR port4000
|
---|
107 | #define UART_IER port4001
|
---|
108 | #define UART_IIR port4002
|
---|
109 | #define UART_FCR port4002
|
---|
110 | #define UART_LCR port4003
|
---|
111 | #define UART_MCR port4004
|
---|
112 | #define UART_LSR port4005
|
---|
113 | #define UART_MSR port4006
|
---|
114 | #define UART_SCR port4007
|
---|
115 | /*
|
---|
116 | * 以ä¸ã®ã¬ã¸ã¹ã¿ã«ã¢ã¯ã»ã¹ããåã«ã
|
---|
117 | * DLAB=1 (b7 of LCR) ãã»ããããå¿
|
---|
118 | è¦ããã
|
---|
119 | */
|
---|
120 | #define UART_DLL port4000
|
---|
121 | #define UART_DLM port4001
|
---|
122 |
|
---|
123 | /*
|
---|
124 | * ããããã£ã¼ã«ãã®å®ç¾©
|
---|
125 | */
|
---|
126 | #define FCR_FIFO 0x01
|
---|
127 | #define FCR_RFRST 0x02
|
---|
128 | #define FCR_TFRST 0x04
|
---|
129 | #define FIFO_TRIG 0x00
|
---|
130 |
|
---|
131 | #define LCR_DLAB 0x80
|
---|
132 |
|
---|
133 | /* åä¿¡éä¿¡å²ãè¾¼ã¿ã®å®ç¾© */
|
---|
134 | #define IER_ERBI 0x01 /* åä¿¡å²ã込㿠*/
|
---|
135 | #define IER_RIE IER_ERBI
|
---|
136 | #define IER_ETBEI 0x02 /* éä¿¡å²ã込㿠*/
|
---|
137 | #define IER_TIE IER_ETBEI
|
---|
138 |
|
---|
139 | #define LSR_DR 0x01
|
---|
140 | #define LSR_THRE 0x20
|
---|
141 | #define LSR_TEMT 0x40
|
---|
142 |
|
---|
143 | #define IIR_RXINT 0x04
|
---|
144 | #define IIR_TXINT 0x02
|
---|
145 |
|
---|
146 | /*
|
---|
147 | * UARTã®ãã¼ã¬ã¼ãã®è¨å®
|
---|
148 | */
|
---|
149 | /*
|
---|
150 | * BAUD RATE 2 : 115200 bps
|
---|
151 | * BAUD RATE 4 : 57600 bps
|
---|
152 | */
|
---|
153 | #define UART_BAUD_RATE 2
|
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 | #ifndef _MACRO_ONLY
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * ã·ãªã¢ã«I/Oãã¼ãåæåãããã¯
|
---|
161 | */
|
---|
162 | typedef struct sio_port_initialization_block {
|
---|
163 | VP dummy;
|
---|
164 | } SIOPINIB;
|
---|
165 |
|
---|
166 | /*
|
---|
167 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯
|
---|
168 | */
|
---|
169 | typedef struct sio_port_control_block {
|
---|
170 | const SIOPINIB *siopinib; /* ã·ãªã¢ã«I/Oãã¼ãåæåããã㯠*/
|
---|
171 | VP_INT exinf; /* æ¡å¼µæ
|
---|
172 | å ± */
|
---|
173 | BOOL openflag; /* ãªã¼ãã³æ¸ã¿ãã©ã° */
|
---|
174 | BOOL getready; /* æåãåä¿¡ããç¶æ
|
---|
175 | */
|
---|
176 | BOOL putready; /* æåãåä¿¡ã§ããç¶æ
|
---|
177 | */
|
---|
178 | } SIOPCB;
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * ã³ã¼ã«ããã¯ã«ã¼ãã³ã®èå¥çªå·
|
---|
182 | */
|
---|
183 | #define SIO_ERDY_SND 1u /* éä¿¡å¯è½ã³ã¼ã«ãã㯠*/
|
---|
184 | #define SIO_ERDY_RCV 2u /* åä¿¡éç¥ã³ã¼ã«ãã㯠*/
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * ã«ã¼ãã«èµ·åæç¨ã®åæå(sys_putcã使ç¨ãããã)
|
---|
188 | */
|
---|
189 | extern void uart_init(void);
|
---|
190 |
|
---|
191 | /*
|
---|
192 | * SIOãã©ã¤ãã®åæåã«ã¼ãã³
|
---|
193 | */
|
---|
194 | extern void uart_initialize(void);
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * ãªã¼ãã³ãã¦ãããã¼ãããããï¼
|
---|
198 | */
|
---|
199 | extern BOOL uart_openflag(void);
|
---|
200 |
|
---|
201 | /*
|
---|
202 | * ã·ãªã¢ã«I/Oãã¼ãã®ãªã¼ãã³
|
---|
203 | */
|
---|
204 | extern SIOPCB *uart_opn_por(ID siopid, VP_INT exinf);
|
---|
205 |
|
---|
206 | /*
|
---|
207 | * ã·ãªã¢ã«I/Oãã¼ãã®ã¯ãã¼ãº
|
---|
208 | */
|
---|
209 | extern void uart_cls_por(SIOPCB *siopcb);
|
---|
210 |
|
---|
211 | /*
|
---|
212 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®æåéä¿¡
|
---|
213 | */
|
---|
214 | extern BOOL uart_snd_chr(SIOPCB *siopcb, char chr);
|
---|
215 |
|
---|
216 | /*
|
---|
217 | * ã·ãªã¢ã«I/Oãã¼ãããã®æååä¿¡
|
---|
218 | */
|
---|
219 | extern INT uart_rcv_chr(SIOPCB *siopcb);
|
---|
220 |
|
---|
221 | /*
|
---|
222 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
|
---|
223 | */
|
---|
224 | extern void uart_ena_cbr(SIOPCB *siopcb, UINT cbrtn);
|
---|
225 |
|
---|
226 | /*
|
---|
227 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ¢
|
---|
228 | */
|
---|
229 | extern void uart_dis_cbr(SIOPCB *siopcb, UINT cbrtn);
|
---|
230 |
|
---|
231 | /*
|
---|
232 | * SIOã®å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³
|
---|
233 | */
|
---|
234 | extern void uart_isr(void);
|
---|
235 |
|
---|
236 | /*
|
---|
237 | * ã·ãªã¢ã«I/Oãã¼ãããã®éä¿¡å¯è½ã³ã¼ã«ããã¯
|
---|
238 | */
|
---|
239 | extern void uart_ierdy_snd(VP_INT exinf);
|
---|
240 |
|
---|
241 | /*
|
---|
242 | * ã·ãªã¢ã«I/Oãã¼ãããã®åä¿¡éç¥ã³ã¼ã«ããã¯
|
---|
243 | */
|
---|
244 | extern void uart_ierdy_rcv(VP_INT exinf);
|
---|
245 |
|
---|
246 | /* ãã¼ãªã³ã°ã§ã·ãªã¢ã«ã«éä¿¡ */
|
---|
247 | Inline char
|
---|
248 | uart_putc(char c)
|
---|
249 | {
|
---|
250 | while ((UART_LSR & LSR_THRE) == 0); /* éä¿¡ã¬ã¸ã¹ã¿ã空ãã©ãã */
|
---|
251 | UART_THR = c;
|
---|
252 | return(c);
|
---|
253 | }
|
---|
254 |
|
---|
255 | #endif /* _MACRO_ONLY */
|
---|
256 |
|
---|
257 | #endif /* _TL16C550CFN_H_ */
|
---|