source: pdic/upd72001/upd72001.c @ 7

このファイルの 7 以降における最終更新内容7 で kominami が 2015/09/12 9:22:12 に更新しました

TOPPERS/ASP 1.9.1

ファイルサイズ: 10.8 KB
 
1/*
2 *  TOPPERS/ASP Kernel
3 *      Toyohashi Open Platform for Embedded Real-Time Systems/
4 *      Advanced Standard Profile Kernel
5 *
6 *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 *                              Toyohashi Univ. of Technology, JAPAN
8 *  Copyright (C) 2006-2011 by Embedded and Real-Time Systems Laboratory
9 *              Graduate School of Information Science, Nagoya Univ., JAPAN
10 *
11 *  Ÿåµ­Ãøºîž¢ŒÔ€Ï¡€°Ê²Œ€Î(1)¡Á(4)€ÎŸò·ï€òËþ€¿€¹Ÿì¹ç€ËžÂ€ê¡€ËÜ¥œ¥Õ¥È¥Š¥§
12 *  ¥¢¡ÊËÜ¥œ¥Õ¥È¥Š¥§¥¢€ò²þÊÑ€·€¿€â€Î€òŽÞ€à¡¥°Ê²ŒÆ±€ž¡Ë€ò»ÈÍÑ¡ŠÊ£Àœ¡Š²þ
13 *  ÊÑ¡ŠºÆÇÛÉۡʰʲŒ¡€ÍøÍрȞƀ֡ˀ¹€ë€³€È€ò̵œþ€ÇµöÂú€¹€ë¡¥
14 *  (1) ËÜ¥œ¥Õ¥È¥Š¥§¥¢€ò¥œ¡Œ¥¹¥³¡Œ¥É€Î·Á€ÇÍøÍÑ€¹€ëŸì¹ç€Ë€Ï¡€Ÿåµ­€ÎÃøºî
15 *      ž¢ÉœŒš¡€€³€ÎÍøÍÑŸò·ï€ª€è€Ó²Œµ­€Î̵ÊÝŸÚµ¬Äꀬ¡€€œ€Î€Þ€Þ€Î·Á€Ç¥œ¡Œ
16 *      ¥¹¥³¡Œ¥ÉÃæ€ËŽÞ€Þ€ì€Æ€€€ë€³€È¡¥
17 *  (2) ËÜ¥œ¥Õ¥È¥Š¥§¥¢€ò¡€¥é¥€¥Ö¥é¥ê·ÁŒ°€Ê€É¡€ÂŸ€Î¥œ¥Õ¥È¥Š¥§¥¢³«È¯€Ë»È
18 *      Íрǀ­€ë·Á€ÇºÆÇÛÉÛ€¹€ëŸì¹ç€Ë€Ï¡€ºÆÇÛÉÛ€ËÈŒ€Š¥É¥­¥å¥á¥ó¥È¡ÊÍøÍÑ
19 *      ŒÔ¥Þ¥Ë¥å¥¢¥ë€Ê€É¡Ë€Ë¡€Ÿåµ­€ÎÃøºîž¢ÉœŒš¡€€³€ÎÍøÍÑŸò·ï€ª€è€Ó²Œµ­
20 *      €Î̵ÊÝŸÚµ¬Äê€ò·ÇºÜ€¹€ë€³€È¡¥
21 *  (3) ËÜ¥œ¥Õ¥È¥Š¥§¥¢€ò¡€µ¡Žï€ËÁȀ߹þ€à€Ê€É¡€ÂŸ€Î¥œ¥Õ¥È¥Š¥§¥¢³«È¯€Ë»È
22 *      Íрǀ­€Ê€€·Á€ÇºÆÇÛÉÛ€¹€ëŸì¹ç€Ë€Ï¡€Œ¡€Î€€€º€ì€«€ÎŸò·ï€òËþ€¿€¹€³
23 *      €È¡¥
24 *    (a) ºÆÇÛÉÛ€ËÈŒ€Š¥É¥­¥å¥á¥ó¥È¡ÊÍøÍьԥޥ˥奢¥ë€Ê€É¡Ë€Ë¡€Ÿåµ­€ÎÃø
25 *        ºîž¢ÉœŒš¡€€³€ÎÍøÍÑŸò·ï€ª€è€Ó²Œµ­€Î̵ÊÝŸÚµ¬Äê€ò·ÇºÜ€¹€ë€³€È¡¥
26 *    (b) ºÆÇÛÉۀηÁÂÖ€ò¡€ÊÌ€ËÄê€á€ëÊýË¡€Ë€è€Ã€Æ¡€TOPPERS¥×¥í¥ž¥§¥¯¥È€Ë
27 *        Êó¹ð€¹€ë€³€È¡¥
28 *  (4) ËÜ¥œ¥Õ¥È¥Š¥§¥¢€ÎÍøÍрˀè€êÄŸÀÜŪ€Þ€¿€ÏŽÖÀÜŪ€ËÀž€ž€ë€€€«€Ê€ë»
29 *      ³²€«€é€â¡€Ÿåµ­Ãøºîž¢ŒÔ€ª€è€ÓTOPPERS¥×¥í¥ž¥§¥¯¥È€òÌÈÀÕ€¹€ë€³€È¡¥
30 *      €Þ€¿¡€ËÜ¥œ¥Õ¥È¥Š¥§¥¢€Î¥æ¡Œ¥¶€Þ€¿€Ï¥š¥ó¥É¥æ¡Œ¥¶€«€é€Î€€€«€Ê€ëÍý
31 *      ͳ€ËŽð€Å€¯ÀÁµá€«€é€â¡€Ÿåµ­Ãøºîž¢ŒÔ€ª€è€ÓTOPPERS¥×¥í¥ž¥§¥¯¥È€ò
32 *      ÌÈÀÕ€¹€ë€³€È¡¥
33 *
34 *  ËÜ¥œ¥Õ¥È¥Š¥§¥¢€Ï¡€ÌµÊÝŸÚ€ÇÄó¶¡€µ€ì€Æ€€€ë€â€Î€Ç€¢€ë¡¥Ÿåµ­Ãøºîž¢ŒÔ€ª
35 *  €è€ÓTOPPERS¥×¥í¥ž¥§¥¯¥È€Ï¡€ËÜ¥œ¥Õ¥È¥Š¥§¥¢€ËŽØ€·€Æ¡€ÆÃÄê€Î»ÈÍÑÌÜŪ
36 *  €ËÂЀ¹€ëŬ¹çÀ­€âŽÞ€á€Æ¡€€€€«€Ê€ëÊÝŸÚ€â¹Ô€ï€Ê€€¡¥€Þ€¿¡€ËÜ¥œ¥Õ¥È¥Š¥§
37 *  ¥¢€ÎÍøÍрˀè€êÄŸÀÜŪ€Þ€¿€ÏŽÖÀÜŪ€ËÀž€ž€¿€€€«€Ê€ë»³²€ËŽØ€·€Æ€â¡€€œ
38 *  €ÎÀÕÇ€€òÉé€ï€Ê€€¡¥
39 *
40 *  @(#) $Id$
41 */
42
43/*
44 *              ŠÌPD72001ÍÑ ŽÊ°×SIO¥É¥é¥€¥Ð
45 */
46
47#include <sil.h>
48#include "target_syssvc.h"
49#include "upd72001.h"
50
51/*
52 *  ¥Ç¥Ð¥€¥¹¥ì¥ž¥¹¥¿€Î¥¢¥¯¥»¥¹ŽÖ³Ö»þŽÖ¡Ênsecñ°Ì¡Ë
53 *
54 *  200€È€€€ŠÃ̀ˀ¢€Þ€êº¬µò€Ï€Ê€€¡¥
55 */
56#define UPD72001_DELAY  200U
57
58/*
59 *  ŠÌPD72001€Î¥ì¥ž¥¹¥¿€ÎÈÖ¹æ
60 */
61#define UPD72001_CR0    0x00U           /* ¥³¥ó¥È¥í¡Œ¥ë¥ì¥ž¥¹¥¿ */
62#define UPD72001_CR1    0x01U
63#define UPD72001_CR2    0x02U
64#define UPD72001_CR3    0x03U
65#define UPD72001_CR4    0x04U
66#define UPD72001_CR5    0x05U
67#define UPD72001_CR10   0x0aU
68#define UPD72001_CR12   0x0cU
69#define UPD72001_CR14   0x0eU
70#define UPD72001_CR15   0x0fU
71
72#define UPD72001_SR0    0x00U           /* ¥¹¥Æ¡Œ¥¿¥¹¥ì¥ž¥¹¥¿ */
73
74/*
75 *  ¥³¥ó¥È¥í¡Œ¥ë¥ì¥ž¥¹¥¿€ÎÀßÄêÃÍ
76 */
77#define CR_RESET        0x18U           /* ¥Ý¡Œ¥È¥ê¥»¥Ã¥È¥³¥Þ¥ó¥É */
78
79#define CR0_EOI         0x38U           /* EOI¡ÊEnd of Interrupt¡Ë*/
80
81#define CR1_DOWN        0x00U           /* Á޳ä¹þ€ß€ò¶Ø»ß */
82#define CR1_RECV        0x10U           /* Œõ¿®³ä¹þ€ßµö²Ä¥Ó¥Ã¥È */
83#define CR1_SEND        0x02U           /* Á÷¿®³ä¹þ€ßµö²Ä¥Ó¥Ã¥È */
84
85#define CR3_DEF         0xc1U           /* ¥Ç¡Œ¥¿ 8bit¡€Œõ¿®¥€¥Í¡Œ¥Ö¥ë */
86#define CR4_DEF         0x44U           /* ¥¹¥È¥Ã¥×¥Ó¥Ã¥È 1bit¡€¥Ñ¥ê¥Æ¥£€Ê€· */
87#define CR5_DEF         0xeaU           /* ¥Ç¡Œ¥¿ 8bit¡€Á÷¿®¥€¥Í¡Œ¥Ö¥ë */
88
89#define CR10_DEF        0x00U           /* NRZ */
90#define CR14_DEF        0x07U           /* ¥Ü¡Œ¥ì¡Œ¥È¥ž¥§¥Í¥ì¡Œ¥¿¥€¥Í¡Œ¥Ö¥ë */
91#define CR15_DEF        0x56U           /* ¥Ü¡Œ¥ì¡Œ¥È¥ž¥§¥Í¥ì¡Œ¥¿»ÈÍÑ */
92
93#define SR0_RECV        0x01U           /* Œõ¿®ÄÌÃÎ¥Ó¥Ã¥È */
94#define SR0_SEND        0x04U           /* Á÷¿®²ÄÇœ¥Ó¥Ã¥È */
95
96/*
97 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈœéŽü²œ¥Ö¥í¥Ã¥¯€ÎÄêµÁ
98 */
99typedef struct sio_port_initialization_block {
100        void            *data;                  /* ¥Ç¡Œ¥¿¥ì¥ž¥¹¥¿€ÎÈÖÃÏ */
101        void            *ctrl;                  /* ¥³¥ó¥È¥í¡Œ¥ë¥ì¥ž¥¹¥¿€ÎÈÖÃÏ */
102
103        uint8_t         cr3_def;                /* CR3€ÎÀßÄêÃ͡ʌõ¿®¥Ó¥Ã¥È¿ô¡Ë*/
104        uint8_t         cr4_def;                /* CR4€ÎÀßÄêÃ͡ʥ¹¥È¥Ã¥×¥Ó¥Ã¥È¡€¥Ñ¥ê¥Æ¥£¡Ë*/
105        uint8_t         cr5_def;                /* CR5€ÎÀßÄêÃÍ¡ÊÁ÷¿®¥Ó¥Ã¥È¿ô¡Ë*/
106        uint8_t         brg1_def;               /* ¥Ü¡Œ¥ì¡Œ¥ÈŸå°Ì€ÎÀßÄêÃÍ */
107        uint8_t         brg2_def;               /* ¥Ü¡Œ¥ì¡Œ¥È²Œ°Ì€ÎÀßÄêÃÍ */
108} SIOPINIB;
109
110/*
111 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈŽÉÍý¥Ö¥í¥Ã¥¯€ÎÄêµÁ
112 */
113struct sio_port_control_block {
114        const SIOPINIB *p_siopinib;     /* ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈœéŽü²œ¥Ö¥í¥Ã¥¯ */
115        intptr_t        exinf;                  /* ³ÈÄ¥ŸðÊó */
116        bool_t          openflag;               /* ¥ª¡Œ¥×¥óºÑ€ß¥Õ¥é¥° */
117        uint8_t         cr1;                    /* CR1€ÎÀßÄêÃ͡ʳä¹þ€ßµö²Ä¡Ë*/
118        bool_t          getready;               /* Êž»ú€òŒõ¿®€·€¿ŸõÂÖ */
119        bool_t          putready;               /* Êž»ú€òÁ÷¿®€Ç€­€ëŸõÂÖ */
120};
121
122/*
123 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈœéŽü²œ¥Ö¥í¥Ã¥¯
124 */
125const SIOPINIB siopinib_table[TNUM_SIOP] = {
126        { (void *) TADR_UPD72001_DATAA, (void *) TADR_UPD72001_CTRLA,
127                                        CR3_DEF, CR4_DEF, CR5_DEF, BRG1_DEF, BRG2_DEF },
128        { (void *) TADR_UPD72001_DATAB, (void *) TADR_UPD72001_CTRLB,
129                                        CR3_DEF, CR4_DEF, CR5_DEF, BRG1_DEF, BRG2_DEF }
130};
131
132/*
133 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈŽÉÍý¥Ö¥í¥Ã¥¯€Î¥š¥ê¥¢
134 */
135SIOPCB  siopcb_table[TNUM_SIOP];
136
137/*
138 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈID€«€éŽÉÍý¥Ö¥í¥Ã¥¯€òŒè€êœÐ€¹€¿€á€Î¥Þ¥¯¥í
139 */
140#define INDEX_SIOP(siopid)      ((uint_t)((siopid) - 1))
141#define get_siopcb(siopid)      (&(siopcb_table[INDEX_SIOP(siopid)]))
142
143/*
144 *  ¥Ç¥Ð¥€¥¹¥ì¥ž¥¹¥¿€Ø€Î¥¢¥¯¥»¥¹ŽØ¿ô
145 */
146Inline uint8_t
147upd72001_read_reg(void *addr)
148{
149        uint8_t val;
150
151        val = upd72001_reb_reg(addr);
152        sil_dly_nse(UPD72001_DELAY);
153        return(val);
154}
155
156Inline void
157upd72001_write_reg(void *addr, uint8_t val)
158{
159        upd72001_wrb_reg(addr, val);
160        sil_dly_nse(UPD72001_DELAY);
161}
162
163Inline uint8_t
164upd72001_read_ctrl(void *addr, uint8_t reg)
165{
166        upd72001_write_reg(addr, reg);
167        return(upd72001_read_reg(addr));
168}
169
170Inline void
171upd72001_write_ctrl(void *addr, uint8_t reg, uint8_t val)
172{
173        upd72001_write_reg(addr, reg);
174        upd72001_write_reg(addr, val);
175}
176
177Inline void
178upd72001_write_brg(void *addr, uint8_t reg, uint8_t val,
179                                                                        uint8_t brg2, uint8_t brg1)
180{
181        upd72001_write_reg(addr, reg);
182        upd72001_write_reg(addr, val);
183        upd72001_write_reg(addr, brg2);
184        upd72001_write_reg(addr, brg1);
185        (void) upd72001_read_reg(addr);         /* ¥À¥ß¡Œ¥ê¡Œ¥É */
186}
187
188/*
189 *  ŸõÂÖ€ÎÆÉœÐ€·¡ÊSR0€ÎÆÉœÐ€·¡Ë
190 *
191 *  ŠÌPD72001€Ï¡€ŸõÂÖ¡ÊSR0¡Ë€ò°ìÅÙÆÉ€à€ÈŒõ¿®ÄÌÃΥӥåȀ¬Íî€Á€Æ€·€Þ€Š€¿
192 *  €á¡€ŸõÂÖ€òÆÉ€ßœÐ€¹ŽØ¿ô€òÀ߀±¡€¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈŽÉÍý¥Ö¥í¥Ã¥¯Ãæ€Î
193 *  getready€ËŒõ¿®ÄÌÃΟõÂÖ¡€putready€ËÁ÷¿®²ÄÇœŸõÂÖ€òÊÝž€·€Æ€€€ë¡ÊÁ÷¿®
194 *  ²ÄÇœŸõÂÖ€ÎÊÝž€ÏÉÔÍ×€«€â€·€ì€Ê€€¡Ë¡¥
195 *  ŸõÂ֥쥞¥¹¥¿€òÆÉ€ó€Ç€âŒõ¿®ÄÌÃΥӥåȀ¬Íî€Á€Ê€€¥Ç¥Ð¥€¥¹¡Ê€³€Á€é€¬Éá
196 *  Ä̀Ȼ׀ï€ì€ë¡Ë€Ç€Ï¡€€³€ÎŽØ¿ô€ÏɬÍ׀ʀ€¡¥
197 */
198static void
199upd72001_get_stat(SIOPCB *p_siopcb)
200{
201        uint8_t sr0;
202
203        sr0 = upd72001_read_ctrl(p_siopcb->p_siopinib->ctrl, UPD72001_SR0);
204        if ((sr0 & SR0_RECV) != 0) {
205                p_siopcb->getready = true;
206        }
207        if ((sr0 & SR0_SEND) != 0) {
208                p_siopcb->putready = true;
209        }
210}
211
212/*
213 *  Êž»ú€òŒõ¿®€Ç€­€ë€«¡©
214 */
215Inline bool_t
216upd72001_getready(SIOPCB *p_siopcb)
217{
218        upd72001_get_stat(p_siopcb);
219        return(p_siopcb->getready);
220}
221
222/*
223 *  Êž»ú€òÁ÷¿®€Ç€­€ë€«¡©
224 */
225Inline bool_t
226upd72001_putready(SIOPCB *p_siopcb)
227{
228        upd72001_get_stat(p_siopcb);
229        return(p_siopcb->putready);
230}
231
232/*
233 *  Œõ¿®€·€¿Êž»ú€ÎŒèœÐ€·
234 */
235Inline char
236upd72001_getchar(SIOPCB *p_siopcb)
237{
238        p_siopcb->getready = false;
239        return((char) upd72001_read_reg(p_siopcb->p_siopinib->data));
240}
241
242/*
243 *  Á÷¿®€¹€ëÊž»ú€Îœñ¹þ€ß
244 */
245Inline void
246upd72001_putchar(SIOPCB *p_siopcb, char c)
247{
248        p_siopcb->putready = false;
249        upd72001_write_reg(p_siopcb->p_siopinib->data, (uint8_t) c);
250}
251
252/*
253 *  EOI¡ÊEnd Of Interrupt¡Ëȯ¹Ô
254 */
255Inline void
256upd72001_eoi(void)
257{
258        upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR0, CR0_EOI);
259}
260
261/*
262 *  SIO¥É¥é¥€¥Ð€ÎœéŽü²œ
263 */
264void
265upd72001_initialize(void)
266{
267        SIOPCB  *p_siopcb;
268        uint_t  i;
269
270        /*
271         *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥ÈŽÉÍý¥Ö¥í¥Ã¥¯€ÎœéŽü²œ
272         */
273        for (i = 0; i < TNUM_SIOP; i++) {
274                p_siopcb = &(siopcb_table[i]);
275                p_siopcb->p_siopinib = &(siopinib_table[i]);
276                p_siopcb->openflag = false;
277        }
278}
279
280/*
281 *  ¥ª¡Œ¥×¥ó€·€Æ€€€ë¥Ý¡Œ¥È€¬€¢€ë€«¡©
282 */
283bool_t
284upd72001_openflag(void)
285{
286        return(siopcb_table[0].openflag || siopcb_table[1].openflag);
287}
288
289/*
290 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€Î¥ª¡Œ¥×¥ó
291 */
292SIOPCB *
293upd72001_opn_por(ID siopid, intptr_t exinf)
294{
295        SIOPCB          *p_siopcb;
296        const SIOPINIB  *p_siopinib;
297
298        p_siopcb = get_siopcb(siopid);
299        p_siopinib = p_siopcb->p_siopinib;
300
301        upd72001_write_reg(p_siopinib->ctrl, CR_RESET);
302        if (!upd72001_openflag()) {
303                upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR2, 0x18);
304                upd72001_write_ctrl((void *) TADR_UPD72001_CTRLB, UPD72001_CR2, 0x00);
305        }
306        p_siopcb->cr1 = CR1_DOWN;
307        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR1, p_siopcb->cr1);
308        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR4, p_siopinib->cr4_def);
309        upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x01U,
310                                                        p_siopinib->brg2_def, p_siopinib->brg1_def);
311        upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x02U,
312                                                        p_siopinib->brg2_def, p_siopinib->brg1_def);
313        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR15, CR15_DEF);
314        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR14, CR14_DEF);
315        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR10, CR10_DEF);
316        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR3, p_siopinib->cr3_def);
317        upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR5, p_siopinib->cr5_def);
318        p_siopcb->exinf = exinf;
319        p_siopcb->getready = false;
320        p_siopcb->putready = false;
321        p_siopcb->openflag = true;
322        return(p_siopcb);
323}
324
325/*
326 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€Î¥¯¥í¡Œ¥º
327 */
328void
329upd72001_cls_por(SIOPCB *p_siopcb)
330{
331        upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl, UPD72001_CR1, CR1_DOWN);
332        p_siopcb->openflag = false;
333}
334
335/*
336 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€Ø€ÎÊž»úÁ÷¿®
337 */
338bool_t
339upd72001_snd_chr(SIOPCB *p_siopcb, char c)
340{
341        if (upd72001_putready(p_siopcb)) {
342                upd72001_putchar(p_siopcb, c);
343                return(true);
344        }
345        return(false);
346}
347
348/*
349 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€«€é€ÎÊž»úŒõ¿®
350 */
351int_t
352upd72001_rcv_chr(SIOPCB *p_siopcb)
353{
354        if (upd72001_getready(p_siopcb)) {
355                return((int_t)(uint8_t) upd72001_getchar(p_siopcb));
356        }
357        return(-1);
358}
359
360/*
361 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€«€é€Î¥³¡Œ¥ë¥Ð¥Ã¥¯€Îµö²Ä
362 */
363void
364upd72001_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
365{
366        uint8_t cr1_bit;
367
368        switch (cbrtn) {
369        case SIO_RDY_SND:
370                cr1_bit = CR1_SEND;
371                break;
372        case SIO_RDY_RCV:
373                cr1_bit = CR1_RECV;
374                break;
375        default:
376                cr1_bit = 0U;
377                break;
378        }
379        p_siopcb->cr1 |= cr1_bit;
380        upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
381                                                                        UPD72001_CR1, p_siopcb->cr1);
382}
383
384/*
385 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€«€é€Î¥³¡Œ¥ë¥Ð¥Ã¥¯€Î¶Ø»ß
386 */
387void
388upd72001_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
389{
390        uint8_t cr1_bit;
391
392        switch (cbrtn) {
393        case SIO_RDY_SND:
394                cr1_bit = CR1_SEND;
395                break;
396        case SIO_RDY_RCV:
397                cr1_bit = CR1_RECV;
398                break;
399        default:
400                cr1_bit = 0U;
401                break;
402        }
403        p_siopcb->cr1 &= ~cr1_bit;
404        upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
405                                                                        UPD72001_CR1, p_siopcb->cr1);
406}
407
408/*
409 *  ¥·¥ê¥¢¥ëI/O¥Ý¡Œ¥È€ËÂЀ¹€ë³ä¹þ€ßœèÍý
410 */
411static void
412upd72001_isr_siop(SIOPCB *p_siopcb)
413{
414        if ((p_siopcb->cr1 & CR1_RECV) != 0U) {
415                if (upd72001_getready(p_siopcb)) {
416                        /*
417                         *  Œõ¿®ÄÌÃÎ¥³¡Œ¥ë¥Ð¥Ã¥¯¥ë¡Œ¥Á¥ó€òžÆ€ÓœÐ€¹¡¥
418                         */
419                        upd72001_irdy_rcv(p_siopcb->exinf);
420                }
421        }
422        if ((p_siopcb->cr1 & CR1_SEND) != 0U) {
423                if (upd72001_putready(p_siopcb)) {
424                        /*
425                         *  Á÷¿®²ÄÇœ¥³¡Œ¥ë¥Ð¥Ã¥¯¥ë¡Œ¥Á¥ó€òžÆ€ÓœÐ€¹¡¥
426                         */
427                        upd72001_irdy_snd(p_siopcb->exinf);
428                }
429        }
430}
431
432/*
433 *  SIO€Î³ä¹þ€ß¥µ¡Œ¥Ó¥¹¥ë¡Œ¥Á¥ó
434 */
435void
436upd72001_isr(void)
437{
438        if (siopcb_table[0].openflag) {
439                upd72001_isr_siop(&(siopcb_table[0]));
440        }
441        if (siopcb_table[1].openflag) {
442                upd72001_isr_siop(&(siopcb_table[1]));
443        }
444        upd72001_eoi();
445}
詳しい使い方は TracBrowser を参照してください。