source: anotherchoice/tags/jsp-1.4.4-full-UTF8/config/armv4-ghs/integrator/integrator.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: 8.2 KB
RevLine 
[363]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 * 2003 by Advanced Data Controls, Corp
9 *
10 * 上記著作権者
11は,以下の (1)〜(4) の条件か,Free Software Foundation
12 * によってå…
13¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
14 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
15 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
16å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
17 * 利用と呼ぶ)することを無償で許諾する.
18 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
19 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
20 * スコード中に含まれていること.
21 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
22 * 用できる形で再é…
23å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
24å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
25 * 者
26マニュアルなど)に,上記の著作権表示,この利用条件および下記
27 * の無保証規定を掲載すること.
28 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
29 * 用できない形で再é…
30å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
31 * と.
32 * (a) 再é…
33å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
34マニュアルなど)に,上記の著
35 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
36 * (b) 再é…
37å¸ƒã®å½¢æ…
38‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
39 * 報告すること.
40 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
41 * 害からも,上記著作権者
42およびTOPPERSプロジェクトをå…
43è²¬ã™ã‚‹ã“と.
44 *
45 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
46お
47 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
48 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
49 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
50 *
51 * @(#) $Id: integrator.c,v 1.4 2003/12/24 08:05:00 honda Exp $
52 *
53 */
54
55/*
56 * Integrator 内
57部機能用ドライバ
58 */
59#include <s_services.h>
60#include <integrator.h>
61
62
63/*
64 * シリアルI/Oポート初期化ブロック
65 */
66const SIOPINIB siopinib_table[TNUM_SIOP] = {
67 {(VP)UART1_DR,(VP)UART1_CR,(VP)UART1_LCRL,
68 (VP)UART1_LCRM,(VP)UART1_LCRH,(VP)UART1_IIR,
69 (VP)UART1_FR,IRQ_UART1
70 }
71#if TNUM_SIOP >= 2
72 ,
73 {(VP)UART0_DR,(VP)UART0_CR,(VP)UART0_LCRL,
74 (VP)UART0_LCRM,(VP)UART0_LCRH,(VP)UART0_IIR,
75 (VP)UART0_FR,IRQ_UART0
76 }
77
78#endif /* TNUM_SIOP >= 2 */
79};
80
81
82/*
83 * シリアルI/Oポート管理ブロックのエリア
84 */
85SIOPCB siopcb_table[TNUM_SIOP];
86
87
88/*
89 * シリアルI/OポートIDから管理ブロックを取り出すためのマクロ
90 */
91#define INDEX_SIOP(siopid) ((UINT)((siopid) - 1))
92#define get_siopcb(siopid) (&(siopcb_table[INDEX_SIOP(siopid)]))
93
94
95/*
96 * 文字を受信したか?
97 */
98Inline BOOL
99uart_getready(SIOPCB *siopcb)
100{
101 return((sil_rew_mem((VP)(siopcb->siopinib->int_identifier)) & IIR_RIS)!=0);
102}
103
104/*
105 * 文字を送信できるか?
106 */
107Inline BOOL
108uart_putready(SIOPCB *siopcb)
109{
110 return((sil_rew_mem((VP)(siopcb->siopinib->flag_register)) & UFR_BUSY)==0);
111}
112
113/*
114 * 受信した文字の取り出し
115 */
116Inline UB
117uart_getchar(SIOPCB *siopcb)
118{
119 return(sil_rew_mem((VP)(siopcb->siopinib->uart_data)));
120}
121
122/*
123 * 送信する文字の書き込み
124 */
125Inline void
126uart_putchar(SIOPCB *siopcb, UB c)
127{
128 sil_wrw_mem((VP)(siopcb->siopinib->uart_data),c);
129}
130
131/*
132 * 送信割込み許可
133 */
134Inline void
135uart_enable_send(SIOPCB *siopcb)
136{
137 sil_wrw_mem((VP)(siopcb->siopinib->uart_control),
138 (sil_rew_mem((VP)(siopcb->siopinib->uart_control)) | UCR_TIE));
139}
140
141/*
142 * 送信割込み禁止
143 */
144Inline void
145uart_disable_send(SIOPCB *siopcb)
146{
147 sil_wrw_mem((VP)(siopcb->siopinib->uart_control),
148 (sil_rew_mem((VP)(siopcb->siopinib->uart_control)) & ~UCR_TIE));
149}
150
151
152/*
153 * 受信割込み許可
154 */
155Inline void
156uart_enable_rcv(SIOPCB *siopcb)
157{
158 sil_wrw_mem((VP)(siopcb->siopinib->uart_control),
159 (sil_rew_mem((VP)(siopcb->siopinib->uart_control)) | UCR_RIE));
160}
161
162/*
163 * 受信割込み禁止
164 */
165Inline void
166uart_disable_rcv(SIOPCB *siopcb)
167{
168
169 sil_wrw_mem((VP)(siopcb->siopinib->uart_control),
170 (sil_rew_mem((VP)(siopcb->siopinib->uart_control)) & ~UCR_RIE));
171
172}
173
174
175
176/*
177 * SIOドライバの初期化ルーチン
178 * 1ポートしかないため,あまり意味はない
179 */
180void
181uart_initialize()
182{
183 SIOPCB *siopcb;
184 UINT i;
185
186 /*
187 * シリアルI/Oポート管理ブロックの初期化
188 */
189 for (siopcb = siopcb_table, i = 0; i < TNUM_SIOP; siopcb++, i++) {
190 siopcb->siopinib = &(siopinib_table[i]);
191 siopcb->openflag = FALSE;
192 siopcb->sendflag = FALSE;
193 }
194}
195
196/*
197 * オープンしているポートがあるか
198 */
199BOOL
200uart_openflag(void)
201{
202 return(siopcb_table[0].openflag);
203}
204
205/*
206 * シリアルI/Oポートのオープン
207 */
208SIOPCB *
209uart_opn_por(ID siopid, VP_INT exinf)
210{
211 SIOPCB *siopcb;
212 const SIOPINIB *siopinib;
213
214 siopcb = get_siopcb(siopid);
215 siopinib = siopcb->siopinib;
216
217 /* Disable Interrupt */
218 sil_wrw_mem((VP)siopinib->uart_control, ~UCR_UARTEN);
219 /* 19200bps */
220 sil_wrw_mem((VP)siopinib->linectrl_lo, ULCRL_19200);
221 sil_wrw_mem((VP)siopinib->linectrl_mid, ULCRM_19200);
222 /* 8Data, 1Stop, No Parity */
223 sil_wrw_mem((VP)siopinib->linectrl_hi, ULCRH_WLEN_8BIT);
224
225
226 /*
227 * 割込み関連の設定
228 */
229 sil_wrw_mem((VP)siopinib->uart_control, UCR_UARTEN); /* Enable Interrupt */
230 sil_wrw_mem((VP)IRQ0_ENABLESET,siopinib->irq_bit);/*Enable interrupt register*/
231
232 siopcb->exinf = exinf;
233 siopcb->getready = siopcb->putready = FALSE;
234 siopcb->openflag = TRUE;
235
236 return(siopcb);
237}
238
239
240
241/*
242 * シリアルI/Oポートのクローズ
243 */
244void
245uart_cls_por(SIOPCB *siopcb)
246{
247 sil_wrw_mem((VP)(siopcb->siopinib->uart_control),
248 (sil_rew_mem((VP)(siopcb->siopinib->uart_control))&~UCR_UARTEN)); /* Disable Interrupt */
249
250 siopcb->openflag = FALSE;
251}
252
253/*
254 * シリアルI/Oポートへの文字送信
255 */
256BOOL
257uart_snd_chr(SIOPCB *siopcb, char c)
258{
259 if (uart_putready(siopcb)){
260 uart_putchar(siopcb, c);
261 return(TRUE);
262 }
263 return(FALSE);
264}
265
266/*
267 * シリアルI/Oポートからの文字受信
268 */
269INT
270uart_rcv_chr(SIOPCB *siopcb)
271{
272 if (uart_getready(siopcb)) {
273 return((INT)(UB) uart_getchar(siopcb));
274 }
275 return(-1);
276}
277
278/*
279 * シリアルI/Oポートからのコールバックの許可
280 */
281void
282uart_ena_cbr(SIOPCB *siopcb, UINT cbrtn)
283{
284 switch (cbrtn) {
285 case SIO_ERDY_SND:
286 uart_enable_send(siopcb);
287 break;
288 case SIO_ERDY_RCV:
289 uart_enable_rcv(siopcb);
290 break;
291 }
292}
293
294
295/*
296 * シリアルI/Oポートからのコールバックの禁止
297 */
298void
299uart_dis_cbr(SIOPCB *siopcb, UINT cbrtn)
300{
301 switch (cbrtn) {
302 case SIO_ERDY_SND:
303 uart_disable_send(siopcb);
304 break;
305 case SIO_ERDY_RCV:
306 uart_disable_rcv(siopcb);
307 break;
308 }
309}
310
311
312
313/*
314 * シリアルI/Oポートに対する割込み処理
315 */
316static void
317uart_isr_siop(SIOPCB *siopcb)
318{
319 if (uart_getready(siopcb)) {
320 /*
321 * 受信通知コールバックルーチンを呼び出す.
322 */
323 uart_ierdy_rcv(siopcb->exinf);
324 }
325 if (uart_putready(siopcb)) {
326 /*
327 * 送信可能コールバックルーチンを呼び出す.
328 */
329 uart_ierdy_snd(siopcb->exinf);
330 }
331}
332
333
334/*
335 * SIOの割込みサービスルーチン
336 */
337void
338uart_isr0()
339{
340 uart_isr_siop(&(siopcb_table[0]));
341}
342
343#if TNUM_SIOP >= 2
344void
345uart_isr1()
346{
347 uart_isr_siop(&(siopcb_table[1]));
348}
349#endif
Note: See TracBrowser for help on using the repository browser.