1 | /*
|
---|
2 | * TOPPERS/JSP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Just Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2006-2010 by Witz Corporation, JAPAN
|
---|
7 | *
|
---|
8 | * The above copyright holders grant permission gratis to use,
|
---|
9 | * duplicate, modify, or redistribute (hereafter called use) this
|
---|
10 | * software (including the one made by modifying this software),
|
---|
11 | * provided that the following four conditions (1) through (4) are
|
---|
12 | * satisfied.
|
---|
13 | *
|
---|
14 | * (1) When this software is used in the form of source code, the above
|
---|
15 | * copyright notice, this use conditions, and the disclaimer shown
|
---|
16 | * below must be retained in the source code without modification.
|
---|
17 | *
|
---|
18 | * (2) When this software is redistributed in the forms usable for the
|
---|
19 | * development of other software, such as in library form, the above
|
---|
20 | * copyright notice, this use conditions, and the disclaimer shown
|
---|
21 | * below must be shown without modification in the document provided
|
---|
22 | * with the redistributed software, such as the user manual.
|
---|
23 | *
|
---|
24 | * (3) When this software is redistributed in the forms unusable for the
|
---|
25 | * development of other software, such as the case when the software
|
---|
26 | * is embedded in a piece of equipment, either of the following two
|
---|
27 | * conditions must be satisfied:
|
---|
28 | *
|
---|
29 | * (a) The above copyright notice, this use conditions, and the
|
---|
30 | * disclaimer shown below must be shown without modification in
|
---|
31 | * the document provided with the redistributed software, such as
|
---|
32 | * the user manual.
|
---|
33 | *
|
---|
34 | * (b) How the software is to be redistributed must be reported to the
|
---|
35 | * TOPPERS Project according to the procedure described
|
---|
36 | * separately.
|
---|
37 | *
|
---|
38 | * (4) The above copyright holders and the TOPPERS Project are exempt
|
---|
39 | * from responsibility for any type of damage directly or indirectly
|
---|
40 | * caused from the use of this software and are indemnified by any
|
---|
41 | * users or end users of this software from any and all causes of
|
---|
42 | * action whatsoever.
|
---|
43 | *
|
---|
44 | * THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND
|
---|
45 | * THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES,
|
---|
46 | * INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR
|
---|
47 | * PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE
|
---|
48 | * TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR
|
---|
49 | * INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE.
|
---|
50 | *
|
---|
51 | * ä¸è¨è使¨©è
|
---|
52 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
53 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»
|
---|
54 | * åé
|
---|
55 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
56 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®è使¨©
|
---|
57 | * 表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ã¹
|
---|
58 | * ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
59 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ç¨
|
---|
60 | * ã§ããå½¢ã§åé
|
---|
61 | å¸ããå ´åã«ã¯ï¼åé
|
---|
62 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
63 | ã
|
---|
64 | * ãã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è使¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿
|
---|
65 | * 証è¦å®ãæ²è¼ãããã¨ï¼
|
---|
66 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ç¨
|
---|
67 | * ã§ããªãå½¢ã§åé
|
---|
68 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
69 | * (a) åé
|
---|
70 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
71 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½
|
---|
72 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
73 | * (b) åé
|
---|
74 | å¸ã®å½¢æ
|
---|
75 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«å ±
|
---|
76 | * åãããã¨ï¼
|
---|
77 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³
|
---|
78 | * ãããï¼ä¸è¨è使¨©è
|
---|
79 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
80 | 責ãããã¨ï¼ã¾ãï¼
|
---|
81 | * æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãçç±ã«åºã¥
|
---|
82 | * ãè«æ±ãããï¼ä¸è¨è使¨©è
|
---|
83 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
84 | 責ãããã¨ï¼
|
---|
85 | *
|
---|
86 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨è使¨©è
|
---|
87 | ãã
|
---|
88 | * ã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®çã«å¯¾ã
|
---|
89 | * ãé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨
|
---|
90 | * ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè²
|
---|
91 | * ããªãï¼
|
---|
92 | *
|
---|
93 | * @(#) $Id: uart.h,v 1.1 2006/04/10 08:19:25 honda Exp $
|
---|
94 | */
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * éåæéä¿¡ (UART)ã·ãªã¢ã«ãã£ã³ãã«ããã¤ã¹ï¼SIOï¼ãã©ã¤ã
|
---|
98 | * ï¼Zup-F16æ¡å¼µãã¼ãç¨ï¼
|
---|
99 | */
|
---|
100 |
|
---|
101 | #ifndef _UART_H_
|
---|
102 | #define _UART_H_
|
---|
103 |
|
---|
104 | /*
|
---|
105 | * ã·ãªã¢ã«ã³ã³ããã¼ã«ã¬ã¸ã¹ã¿ã®è¨å®å¤
|
---|
106 | */
|
---|
107 | /* 19200bps = (6144000*4)/4/(BRCK)/(BRS+(16-BRK)/16)/16 */
|
---|
108 | /* BRCK=4åå¨,BRS=5ã«ã¦ã³ã,+(16-BRK)/16 ã¯æªä½¿ç¨ */
|
---|
109 | #define BRCR_19200 (TBIT_SIOBRCK2 | 5)
|
---|
110 | #define BRADD_19200 0
|
---|
111 | /* 38400bps = (6144000*4)/4/(BRCK)/(BRS+(16-BRK)/16)/16 */
|
---|
112 | /* BRCK=1åå¨,BRS=10ã«ã¦ã³ã,+(16-BRK)/16 ã¯æªä½¿ç¨ */
|
---|
113 | #define BRCR_38400 (TBIT_SIOBRCK0 | 10)
|
---|
114 | #define BRADD_38400 0
|
---|
115 | #define INT_LEVEL_UART 5 /* å²è¾¼ã¿ã¬ãã« */
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * ã·ãªã¢ã«I/Oã®å²è¾¼ã¿ãã³ãã©ã®ãã¯ã¿çªå·
|
---|
119 | */
|
---|
120 | #define INHNO_SERIAL_IN1 INT_NO_RX1
|
---|
121 | #define INHNO_SERIAL_OUT1 INT_NO_TX1
|
---|
122 | #define INHNO_SERIAL_IN2 INT_NO_RX0
|
---|
123 | #define INHNO_SERIAL_OUT2 INT_NO_TX0
|
---|
124 |
|
---|
125 | #ifndef _MACRO_ONLY
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * ã·ãªã¢ã«I/Oãã¼ãåæåãããã¯ã®å®ç¾©
|
---|
129 | */
|
---|
130 | typedef struct sio_port_initialization_block {
|
---|
131 | UH cntrl; /* ã³ã³ããã¼ã«ã¬ã¸ã¹ã¿ã®çªå° */
|
---|
132 | UH hint; /* å²è¾¼ã¿ã¬ã¸ã¹ã¿ã®çªå° */
|
---|
133 |
|
---|
134 | UB pcrfc_def; /* ããã©ã¼ã«ãã®è¨å®å¤ (P9CR/P9FC) */
|
---|
135 | UB scmod0_def; /* ããã©ã¼ã«ãã®è¨å®å¤ (SCMOD0) */
|
---|
136 | UB sccr_def; /* ããã©ã¼ã«ãã®è¨å®å¤ (SCCR) */
|
---|
137 | UB brcr_def; /* ããã©ã¼ã«ãã®è¨å®å¤ (BRCR) */
|
---|
138 | UB bradd_def; /* ããã©ã¼ã«ãã®è¨å®å¤ (BRADD) */
|
---|
139 | UB int_clr; /* å²è¾¼ã¿è¦æ±ãã©ã°ã¯ãªã¢ã³ãã³ã */
|
---|
140 | } SIOPINIB;
|
---|
141 |
|
---|
142 | /*
|
---|
143 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®å®ç¾©
|
---|
144 | */
|
---|
145 | typedef struct sio_port_control_block {
|
---|
146 | const SIOPINIB *siopinib; /* ã·ãªã¢ã«I/Oãã¼ãåæåããã㯠*/
|
---|
147 | VP_INT exinf; /* æ¡å¼µæ
|
---|
148 | å ± */
|
---|
149 | INT rxb; /* åä¿¡ãããã¡ */
|
---|
150 | volatile UB sts_flag; /* éä¿¡ãããã¡ç©ºãã©ã° */
|
---|
151 | } SIOPCB;
|
---|
152 |
|
---|
153 | /*
|
---|
154 | * ã³ã¼ã«ããã¯ã«ã¼ãã³ã®èå¥çªå·
|
---|
155 | */
|
---|
156 | #define UART_ERDY_SND 1u /* éä¿¡å¯è½ã³ã¼ã«ãã㯠*/
|
---|
157 | #define UART_ERDY_RCV 2u /* åä¿¡éç¥ã³ã¼ã«ãã㯠*/
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * SIOãã©ã¤ãã®åæåã«ã¼ãã³
|
---|
161 | */
|
---|
162 | extern void uart_initialize(void);
|
---|
163 |
|
---|
164 | /*
|
---|
165 | * ã·ãªã¢ã«I/Oãã¼ãã®ãªã¼ãã³
|
---|
166 | */
|
---|
167 | extern SIOPCB * uart_opn_por(ID siopid, VP_INT exinf);
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * ã·ãªã¢ã«I/Oãã¼ãã®ã¯ãã¼ãº
|
---|
171 | */
|
---|
172 | extern void uart_cls_por(SIOPCB *siopcb);
|
---|
173 |
|
---|
174 | /*
|
---|
175 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®æåéä¿¡
|
---|
176 | */
|
---|
177 | extern BOOL uart_snd_chr(SIOPCB *siopcb, char c);
|
---|
178 |
|
---|
179 | /*
|
---|
180 | * ã·ãªã¢ã«I/Oãã¼ãããã®æååä¿¡
|
---|
181 | */
|
---|
182 | extern INT uart_rcv_chr(SIOPCB *siopcb);
|
---|
183 |
|
---|
184 | /*
|
---|
185 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
|
---|
186 | */
|
---|
187 | extern void uart_ena_cbr(SIOPCB *siopcb, UINT cbrtn);
|
---|
188 |
|
---|
189 | /*
|
---|
190 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ¢
|
---|
191 | */
|
---|
192 | extern void uart_dis_cbr(SIOPCB *siopcb, UINT cbrtn);
|
---|
193 |
|
---|
194 | /*
|
---|
195 | * ã·ãªã¢ã«I/Oãã¼ãããã®éä¿¡å¯è½ã³ã¼ã«ããã¯
|
---|
196 | */
|
---|
197 | extern void uart_ierdy_snd(VP_INT exinf);
|
---|
198 |
|
---|
199 | /*
|
---|
200 | * ã·ãªã¢ã«I/Oãã¼ãããã®åä¿¡éç¥ã³ã¼ã«ããã¯
|
---|
201 | */
|
---|
202 | extern void uart_ierdy_rcv(VP_INT exinf);
|
---|
203 |
|
---|
204 | #endif /* _MACRO_ONLY */
|
---|
205 | #endif /* _UART_H_ */
|
---|
206 |
|
---|