source: anotherchoice/tags/jsp-1.4.4-full-UTF8/config/s1c33/dmt33209/hw_serial.c@ 363

Last change on this file since 363 was 363, checked in by ykominami, 5 years ago

add tags/jsp-1.4.4-full-UTF8

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 *
9 * Copyright (C) 2004 by SEIKO EPSON Corp, JAPAN
10 *
11 * 上記著作権者
12は,以下の (1)〜(4) の条件か,Free Software Foundation
13 * によってå…
14¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
15 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
16 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
17å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
18 * 利用と呼ぶ)することを無償で許諾する.
19 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
20 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
21 * スコード中に含まれていること.
22 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
23 * 用できる形で再é…
24å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
25å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
26 * 者
27マニュアルなど)に,上記の著作権表示,この利用条件および下記
28 * の無保証規定を掲載すること.
29 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
30 * 用できない形で再é…
31å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
32 * と.
33 * (a) 再é…
34å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
35マニュアルなど)に,上記の著
36 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
37 * (b) 再é…
38å¸ƒã®å½¢æ…
39‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
40 * 報告すること.
41 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
42 * 害からも,上記著作権者
43およびTOPPERSプロジェクトをå…
44è²¬ã™ã‚‹ã“と.
45 *
46 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
47お
48 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
49 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
50 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
51 *
52 */
53
54/*
55 * ターゲット依存シリアルI/Oモジュール
56 */
57
58#include "jsp_kernel.h"
59#include "hw_serial.h"
60
61/*
62 * シリアルポートの初期化ブロック
63 */
64
65const SIOPINIB siopinib_table[TNUM_PORT] = {
66
67 {
68 0,
69 S1C33_INHNO_SERIAL0ERR,
70 S1C33_INHNO_SERIAL0RX,
71 S1C33_INHNO_SERIAL0TX,
72 },
73#if TNUM_PORT == 2
74 {
75 1,
76 S1C33_INHN1_SERIAL0ERR,
77 S1C33_INHN1_SERIAL0RX,
78 S1C33_INHN1_SERIAL0TX,
79 },
80#endif /* of #if TNUM_PORT == 2 */
81};
82
83
84/*
85 * シリアルポートの制御ブロック
86 */
87
88SIOPCB siopcb_table[TNUM_PORT];
89
90/*
91 * SIO ID から管理ブロックへの変換マクロ
92 */
93#define get_siopinib(sioid) (&(siopinib_table[INDEX_SIO(sioid)]))
94#define get_siopcb(sioid) (&(siopcb_table[INDEX_SIO(sioid)]))
95
96/*
97 * 受信割り込みサービスルーチン.
98 */
99
100void
101sio_in_service(ID sioid)
102{
103 SIOPCB *pcb;
104
105 sio_clr_errflag(INDEX_SIO(sioid));
106 pcb = get_siopcb(sioid);
107 if (pcb->rx_cbrflag){
108 /* 受信可能コールバックルーチンを呼出す。*/
109 sio_ierdy_rcv(pcb->exinf);
110 }
111}
112
113/*
114 * 送信完了割り込みサービスルーチン
115 */
116
117void
118sio_out_service(ID sioid)
119{
120 SIOPCB *pcb;
121
122 pcb = get_siopcb(sioid);
123 if (pcb->tx_cbrflag){
124 /* 送信可能コールバックルーチンを呼出す。*/
125 sio_ierdy_snd(pcb->exinf);
126 }
127}
128
129#ifdef SIO_ERR_HANDLER
130
131/*
132 * 受信エラー割り込みサービスルーチン
133 */
134
135void
136sio_err_service(ID sioid)
137{
138 SIOPCB *pcb;
139 UB status;
140
141 /* エラーフラグをクリア */
142 sio_clr_errflag(INDEX_SIO(sioid));
143
144 /* ポートを再度初期化する */
145 sio_opn_por(sioid, (VP_INT)NULL);
146}
147
148#endif /* of #ifdef SIO_ERR_HANDLER */
149
150/*
151 * シリアルポート制御テーブル初期化
152 */
153
154void
155sio_initialize (void)
156{
157 int iLoop;
158
159 /*
160 * SIO 制御ブロックの初期化
161 */
162 for (iLoop = 0 ; iLoop < TNUM_PORT ; iLoop++ ) {
163 siopcb_table[iLoop].inib = &siopinib_table[iLoop];
164 siopcb_table[iLoop].exinf = (VP_INT)NULL;
165 siopcb_table[iLoop].openflag = FALSE;
166 siopcb_table[iLoop].tx_cbrflag = FALSE;
167 siopcb_table[iLoop].rx_cbrflag = FALSE;
168 }
169}
170
171/*
172 * コールバックを許可する
173 */
174void
175sio_ena_cbr(SIOPCB *siopcb, UINT cbrtn)
176{
177 UB ch_no, sio_ctl;
178
179 ch_no = siopcb->inib->ch_no;
180 sio_ctl = ((s1c33Serial_t *)S1C33_SERIAL_BASE)->stChannel01[ch_no].bControl;
181 switch (cbrtn){
182 case SIO_ERDY_SND:
183 siopcb->tx_cbrflag = TRUE;
184 break;
185 case SIO_ERDY_RCV:
186 siopcb->rx_cbrflag = TRUE;
187 break;
188 }
189
190 return;
191}
192
193/*
194 * コールバックを禁止する
195 */
196void
197sio_dis_cbr(SIOPCB *siopcb, UINT cbrtn)
198{
199 UB ch_no, sio_ctl;
200
201 ch_no = siopcb->inib->ch_no;
202 sio_ctl = ((s1c33Serial_t *)S1C33_SERIAL_BASE)->stChannel01[ch_no].bControl;
203 switch (cbrtn){
204 case SIO_ERDY_SND:
205 siopcb->tx_cbrflag = FALSE;
206 break;
207 case SIO_ERDY_RCV:
208 siopcb->rx_cbrflag = FALSE;
209 break;
210 }
211
212 /*
213 * 送信機能有効ビットを設定する
214 */
215 ((s1c33Serial_t *)S1C33_SERIAL_BASE)->stChannel01[ch_no].bControl = sio_ctl;
216
217 return;
218}
219
220/*
221 * SIO 割り込み
222 */
223
224void
225sio_in_handler (void)
226{
227 sio_clr_factor(SIO_INT_RCV);
228 sio_in_service(1);
229}
230
231void
232sio_out_handler (void)
233{
234 sio_clr_factor(SIO_INT_SND);
235 sio_out_service(1);
236 }
237
238#ifdef SIO_ERR_HANDLER
239
240void
241sio_err_handler (void)
242{
243 sio_clr_factor(SIO_INT_ERR);
244 sio_err_service(1);
245 }
246
247#endif /* of #ifdef SIO_ERR_HANDLER */
248
249#if TNUM_PORT >= 2
250
251void
252sio_in2_handler (void)
253{
254 sio_clr_factor(SIO_INT_RCV << 3);
255 sio_in_handler(2);
256 }
257
258void
259sio_out2_handler (void)
260{
261 sio_clr_factor(SIO_INT_SND << 3);
262 sio_out_handler(2);
263 }
264
265#ifdef SIO_ERR_HANDLER
266
267void
268sio_err2_handler (void)
269{
270 sio_clr_factor(SIO_INT_ERR << 3)
271 sio_err_handler(2);
272 }
273
274#endif /* of #ifdef SIO_ERR_HANDLER */
275
276#endif /* of #if TNUM_PORT >= 2 */
Note: See TracBrowser for help on using the repository browser.