[136] | 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 | * ä¸è¨èä½æ¨©è
|
---|
| 12 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
| 13 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
| 14 | * å¤ã»åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 16 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 17 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 18 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 19 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 20 | * ç¨ã§ããå½¢ã§åé
|
---|
| 21 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 22 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 23 | * è
|
---|
| 24 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 25 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 26 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 27 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 28 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 29 | * ã¨ï¼
|
---|
| 30 | * (a) åé
|
---|
| 31 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 32 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 33 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 34 | * (b) åé
|
---|
| 35 | å¸ã®å½¢æ
|
---|
| 36 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 37 | * å ±åãããã¨ï¼
|
---|
| 38 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 39 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 40 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 41 | 責ãããã¨ï¼
|
---|
| 42 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
| 43 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 44 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
| 45 | * å
|
---|
| 46 | 責ãããã¨ï¼
|
---|
| 47 | *
|
---|
| 48 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 49 | ã
|
---|
| 50 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
| 51 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
| 52 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
| 53 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
| 54 | *
|
---|
| 55 | * @(#) $Id: upd72001.c 2254 2011-10-07 08:28:12Z ertl-hiro $
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | /*
|
---|
| 59 | * μPD72001ç¨ ç°¡æSIOãã©ã¤ã
|
---|
| 60 | */
|
---|
| 61 |
|
---|
| 62 | #include <sil.h>
|
---|
| 63 | #include "target_syssvc.h"
|
---|
| 64 | #include "upd72001.h"
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | * ããã¤ã¹ã¬ã¸ã¹ã¿ã®ã¢ã¯ã»ã¹ééæéï¼nsecåä½ï¼
|
---|
| 68 | *
|
---|
| 69 | * 200ã¨ããå¤ã«ãã¾ãæ ¹æ ã¯ãªãï¼
|
---|
| 70 | */
|
---|
| 71 | #define UPD72001_DELAY 200U
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * μPD72001ã®ã¬ã¸ã¹ã¿ã®çªå·
|
---|
| 75 | */
|
---|
| 76 | #define UPD72001_CR0 0x00U /* ã³ã³ããã¼ã«ã¬ã¸ã¹ã¿ */
|
---|
| 77 | #define UPD72001_CR1 0x01U
|
---|
| 78 | #define UPD72001_CR2 0x02U
|
---|
| 79 | #define UPD72001_CR3 0x03U
|
---|
| 80 | #define UPD72001_CR4 0x04U
|
---|
| 81 | #define UPD72001_CR5 0x05U
|
---|
| 82 | #define UPD72001_CR10 0x0aU
|
---|
| 83 | #define UPD72001_CR12 0x0cU
|
---|
| 84 | #define UPD72001_CR14 0x0eU
|
---|
| 85 | #define UPD72001_CR15 0x0fU
|
---|
| 86 |
|
---|
| 87 | #define UPD72001_SR0 0x00U /* ã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ */
|
---|
| 88 |
|
---|
| 89 | /*
|
---|
| 90 | * ã³ã³ããã¼ã«ã¬ã¸ã¹ã¿ã®è¨å®å¤
|
---|
| 91 | */
|
---|
| 92 | #define CR_RESET 0x18U /* ãã¼ããªã»ããã³ãã³ã */
|
---|
| 93 |
|
---|
| 94 | #define CR0_EOI 0x38U /* EOIï¼End of Interruptï¼*/
|
---|
| 95 |
|
---|
| 96 | #define CR1_DOWN 0x00U /* å
|
---|
| 97 | ¨å²è¾¼ã¿ãç¦æ¢ */
|
---|
| 98 | #define CR1_RECV 0x10U /* åä¿¡å²è¾¼ã¿è¨±å¯ããã */
|
---|
| 99 | #define CR1_SEND 0x02U /* éä¿¡å²è¾¼ã¿è¨±å¯ããã */
|
---|
| 100 |
|
---|
| 101 | #define CR3_DEF 0xc1U /* ãã¼ã¿ 8bitï¼åä¿¡ã¤ãã¼ãã« */
|
---|
| 102 | #define CR4_DEF 0x44U /* ã¹ãããããã 1bitï¼ããªãã£ãªã */
|
---|
| 103 | #define CR5_DEF 0xeaU /* ãã¼ã¿ 8bitï¼éä¿¡ã¤ãã¼ãã« */
|
---|
| 104 |
|
---|
| 105 | #define CR10_DEF 0x00U /* NRZ */
|
---|
| 106 | #define CR14_DEF 0x07U /* ãã¼ã¬ã¼ãã¸ã§ãã¬ã¼ã¿ã¤ãã¼ãã« */
|
---|
| 107 | #define CR15_DEF 0x56U /* ãã¼ã¬ã¼ãã¸ã§ãã¬ã¼ã¿ä½¿ç¨ */
|
---|
| 108 |
|
---|
| 109 | #define SR0_RECV 0x01U /* åä¿¡éç¥ããã */
|
---|
| 110 | #define SR0_SEND 0x04U /* éä¿¡å¯è½ããã */
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | * ã·ãªã¢ã«I/Oãã¼ãåæåãããã¯ã®å®ç¾©
|
---|
| 114 | */
|
---|
| 115 | typedef struct sio_port_initialization_block {
|
---|
| 116 | void *data; /* ãã¼ã¿ã¬ã¸ã¹ã¿ã®çªå° */
|
---|
| 117 | void *ctrl; /* ã³ã³ããã¼ã«ã¬ã¸ã¹ã¿ã®çªå° */
|
---|
| 118 |
|
---|
| 119 | uint8_t cr3_def; /* CR3ã®è¨å®å¤ï¼åä¿¡ãããæ°ï¼*/
|
---|
| 120 | uint8_t cr4_def; /* CR4ã®è¨å®å¤ï¼ã¹ããããããï¼ããªãã£ï¼*/
|
---|
| 121 | uint8_t cr5_def; /* CR5ã®è¨å®å¤ï¼éä¿¡ãããæ°ï¼*/
|
---|
| 122 | uint8_t brg1_def; /* ãã¼ã¬ã¼ãä¸ä½ã®è¨å®å¤ */
|
---|
| 123 | uint8_t brg2_def; /* ãã¼ã¬ã¼ãä¸ä½ã®è¨å®å¤ */
|
---|
| 124 | } SIOPINIB;
|
---|
| 125 |
|
---|
| 126 | /*
|
---|
| 127 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®å®ç¾©
|
---|
| 128 | */
|
---|
| 129 | struct sio_port_control_block {
|
---|
| 130 | const SIOPINIB *p_siopinib; /* ã·ãªã¢ã«I/Oãã¼ãåæåããã㯠*/
|
---|
| 131 | intptr_t exinf; /* æ¡å¼µæ
|
---|
| 132 | å ± */
|
---|
| 133 | bool_t openflag; /* ãªã¼ãã³æ¸ã¿ãã©ã° */
|
---|
| 134 | uint8_t cr1; /* CR1ã®è¨å®å¤ï¼å²è¾¼ã¿è¨±å¯ï¼*/
|
---|
| 135 | bool_t getready; /* æåãåä¿¡ããç¶æ
|
---|
| 136 | */
|
---|
| 137 | bool_t putready; /* æåãéä¿¡ã§ããç¶æ
|
---|
| 138 | */
|
---|
| 139 | };
|
---|
| 140 |
|
---|
| 141 | /*
|
---|
| 142 | * ã·ãªã¢ã«I/Oãã¼ãåæåãããã¯
|
---|
| 143 | */
|
---|
| 144 | const SIOPINIB siopinib_table[TNUM_SIOP] = {
|
---|
| 145 | { (void *) TADR_UPD72001_DATAA, (void *) TADR_UPD72001_CTRLA,
|
---|
| 146 | CR3_DEF, CR4_DEF, CR5_DEF, BRG1_DEF, BRG2_DEF },
|
---|
| 147 | { (void *) TADR_UPD72001_DATAB, (void *) TADR_UPD72001_CTRLB,
|
---|
| 148 | CR3_DEF, CR4_DEF, CR5_DEF, BRG1_DEF, BRG2_DEF }
|
---|
| 149 | };
|
---|
| 150 |
|
---|
| 151 | /*
|
---|
| 152 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®ã¨ãªã¢
|
---|
| 153 | */
|
---|
| 154 | SIOPCB siopcb_table[TNUM_SIOP];
|
---|
| 155 |
|
---|
| 156 | /*
|
---|
| 157 | * ã·ãªã¢ã«I/Oãã¼ãIDãã管çãããã¯ãåãåºãããã®ãã¯ã
|
---|
| 158 | */
|
---|
| 159 | #define INDEX_SIOP(siopid) ((uint_t)((siopid) - 1))
|
---|
| 160 | #define get_siopcb(siopid) (&(siopcb_table[INDEX_SIOP(siopid)]))
|
---|
| 161 |
|
---|
| 162 | /*
|
---|
| 163 | * ããã¤ã¹ã¬ã¸ã¹ã¿ã¸ã®ã¢ã¯ã»ã¹é¢æ°
|
---|
| 164 | */
|
---|
| 165 | Inline uint8_t
|
---|
| 166 | upd72001_read_reg(void *addr)
|
---|
| 167 | {
|
---|
| 168 | uint8_t val;
|
---|
| 169 |
|
---|
| 170 | val = upd72001_reb_reg(addr);
|
---|
| 171 | sil_dly_nse(UPD72001_DELAY);
|
---|
| 172 | return(val);
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | Inline void
|
---|
| 176 | upd72001_write_reg(void *addr, uint8_t val)
|
---|
| 177 | {
|
---|
| 178 | upd72001_wrb_reg(addr, val);
|
---|
| 179 | sil_dly_nse(UPD72001_DELAY);
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | Inline uint8_t
|
---|
| 183 | upd72001_read_ctrl(void *addr, uint8_t reg)
|
---|
| 184 | {
|
---|
| 185 | upd72001_write_reg(addr, reg);
|
---|
| 186 | return(upd72001_read_reg(addr));
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | Inline void
|
---|
| 190 | upd72001_write_ctrl(void *addr, uint8_t reg, uint8_t val)
|
---|
| 191 | {
|
---|
| 192 | upd72001_write_reg(addr, reg);
|
---|
| 193 | upd72001_write_reg(addr, val);
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | Inline void
|
---|
| 197 | upd72001_write_brg(void *addr, uint8_t reg, uint8_t val,
|
---|
| 198 | uint8_t brg2, uint8_t brg1)
|
---|
| 199 | {
|
---|
| 200 | upd72001_write_reg(addr, reg);
|
---|
| 201 | upd72001_write_reg(addr, val);
|
---|
| 202 | upd72001_write_reg(addr, brg2);
|
---|
| 203 | upd72001_write_reg(addr, brg1);
|
---|
| 204 | (void) upd72001_read_reg(addr); /* ããã¼ãªã¼ã */
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | /*
|
---|
| 208 | * ç¶æ
|
---|
| 209 | ã®èªåºãï¼SR0ã®èªåºãï¼
|
---|
| 210 | *
|
---|
| 211 | * μPD72001ã¯ï¼ç¶æ
|
---|
| 212 | ï¼SR0ï¼ãä¸åº¦èªãã¨åä¿¡éç¥ããããè½ã¡ã¦ãã¾ãã
|
---|
| 213 | * ãï¼ç¶æ
|
---|
| 214 | ãèªã¿åºãé¢æ°ãè¨ãï¼ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ä¸ã®
|
---|
| 215 | * getreadyã«åä¿¡éç¥ç¶æ
|
---|
| 216 | ï¼putreadyã«éä¿¡å¯è½ç¶æ
|
---|
| 217 | ãä¿åãã¦ããï¼éä¿¡
|
---|
| 218 | * å¯è½ç¶æ
|
---|
| 219 | ã®ä¿åã¯ä¸è¦ãããããªãï¼ï¼
|
---|
| 220 | * ç¶æ
|
---|
| 221 | ã¬ã¸ã¹ã¿ãèªãã§ãåä¿¡éç¥ããããè½ã¡ãªãããã¤ã¹ï¼ãã¡ããæ®
|
---|
| 222 | * éã¨æãããï¼ã§ã¯ï¼ãã®é¢æ°ã¯å¿
|
---|
| 223 | è¦ãªãï¼
|
---|
| 224 | */
|
---|
| 225 | static void
|
---|
| 226 | upd72001_get_stat(SIOPCB *p_siopcb)
|
---|
| 227 | {
|
---|
| 228 | uint8_t sr0;
|
---|
| 229 |
|
---|
| 230 | sr0 = upd72001_read_ctrl(p_siopcb->p_siopinib->ctrl, UPD72001_SR0);
|
---|
| 231 | if ((sr0 & SR0_RECV) != 0) {
|
---|
| 232 | p_siopcb->getready = true;
|
---|
| 233 | }
|
---|
| 234 | if ((sr0 & SR0_SEND) != 0) {
|
---|
| 235 | p_siopcb->putready = true;
|
---|
| 236 | }
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | /*
|
---|
| 240 | * æåãåä¿¡ã§ãããï¼
|
---|
| 241 | */
|
---|
| 242 | Inline bool_t
|
---|
| 243 | upd72001_getready(SIOPCB *p_siopcb)
|
---|
| 244 | {
|
---|
| 245 | upd72001_get_stat(p_siopcb);
|
---|
| 246 | return(p_siopcb->getready);
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | /*
|
---|
| 250 | * æåãéä¿¡ã§ãããï¼
|
---|
| 251 | */
|
---|
| 252 | Inline bool_t
|
---|
| 253 | upd72001_putready(SIOPCB *p_siopcb)
|
---|
| 254 | {
|
---|
| 255 | upd72001_get_stat(p_siopcb);
|
---|
| 256 | return(p_siopcb->putready);
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | /*
|
---|
| 260 | * åä¿¡ããæåã®ååºã
|
---|
| 261 | */
|
---|
| 262 | Inline char
|
---|
| 263 | upd72001_getchar(SIOPCB *p_siopcb)
|
---|
| 264 | {
|
---|
| 265 | p_siopcb->getready = false;
|
---|
| 266 | return((char) upd72001_read_reg(p_siopcb->p_siopinib->data));
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | /*
|
---|
| 270 | * éä¿¡ããæåã®æ¸è¾¼ã¿
|
---|
| 271 | */
|
---|
| 272 | Inline void
|
---|
| 273 | upd72001_putchar(SIOPCB *p_siopcb, char c)
|
---|
| 274 | {
|
---|
| 275 | p_siopcb->putready = false;
|
---|
| 276 | upd72001_write_reg(p_siopcb->p_siopinib->data, (uint8_t) c);
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | /*
|
---|
| 280 | * EOIï¼End Of Interruptï¼çºè¡
|
---|
| 281 | */
|
---|
| 282 | Inline void
|
---|
| 283 | upd72001_eoi(void)
|
---|
| 284 | {
|
---|
| 285 | upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR0, CR0_EOI);
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | /*
|
---|
| 289 | * SIOãã©ã¤ãã®åæå
|
---|
| 290 | */
|
---|
| 291 | void
|
---|
| 292 | upd72001_initialize(void)
|
---|
| 293 | {
|
---|
| 294 | SIOPCB *p_siopcb;
|
---|
| 295 | uint_t i;
|
---|
| 296 |
|
---|
| 297 | /*
|
---|
| 298 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®åæå
|
---|
| 299 | */
|
---|
| 300 | for (i = 0; i < TNUM_SIOP; i++) {
|
---|
| 301 | p_siopcb = &(siopcb_table[i]);
|
---|
| 302 | p_siopcb->p_siopinib = &(siopinib_table[i]);
|
---|
| 303 | p_siopcb->openflag = false;
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | /*
|
---|
| 308 | * ãªã¼ãã³ãã¦ãããã¼ãããããï¼
|
---|
| 309 | */
|
---|
| 310 | bool_t
|
---|
| 311 | upd72001_openflag(void)
|
---|
| 312 | {
|
---|
| 313 | return(siopcb_table[0].openflag || siopcb_table[1].openflag);
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | /*
|
---|
| 317 | * ã·ãªã¢ã«I/Oãã¼ãã®ãªã¼ãã³
|
---|
| 318 | */
|
---|
| 319 | SIOPCB *
|
---|
| 320 | upd72001_opn_por(ID siopid, intptr_t exinf)
|
---|
| 321 | {
|
---|
| 322 | SIOPCB *p_siopcb;
|
---|
| 323 | const SIOPINIB *p_siopinib;
|
---|
| 324 |
|
---|
| 325 | p_siopcb = get_siopcb(siopid);
|
---|
| 326 | p_siopinib = p_siopcb->p_siopinib;
|
---|
| 327 |
|
---|
| 328 | upd72001_write_reg(p_siopinib->ctrl, CR_RESET);
|
---|
| 329 | if (!upd72001_openflag()) {
|
---|
| 330 | upd72001_write_ctrl((void *) TADR_UPD72001_CTRLA, UPD72001_CR2, 0x18);
|
---|
| 331 | upd72001_write_ctrl((void *) TADR_UPD72001_CTRLB, UPD72001_CR2, 0x00);
|
---|
| 332 | }
|
---|
| 333 | p_siopcb->cr1 = CR1_DOWN;
|
---|
| 334 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR1, p_siopcb->cr1);
|
---|
| 335 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR4, p_siopinib->cr4_def);
|
---|
| 336 | upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x01U,
|
---|
| 337 | p_siopinib->brg2_def, p_siopinib->brg1_def);
|
---|
| 338 | upd72001_write_brg(p_siopinib->ctrl, UPD72001_CR12, 0x02U,
|
---|
| 339 | p_siopinib->brg2_def, p_siopinib->brg1_def);
|
---|
| 340 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR15, CR15_DEF);
|
---|
| 341 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR14, CR14_DEF);
|
---|
| 342 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR10, CR10_DEF);
|
---|
| 343 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR3, p_siopinib->cr3_def);
|
---|
| 344 | upd72001_write_ctrl(p_siopinib->ctrl, UPD72001_CR5, p_siopinib->cr5_def);
|
---|
| 345 | p_siopcb->exinf = exinf;
|
---|
| 346 | p_siopcb->getready = false;
|
---|
| 347 | p_siopcb->putready = false;
|
---|
| 348 | p_siopcb->openflag = true;
|
---|
| 349 | return(p_siopcb);
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | /*
|
---|
| 353 | * ã·ãªã¢ã«I/Oãã¼ãã®ã¯ãã¼ãº
|
---|
| 354 | */
|
---|
| 355 | void
|
---|
| 356 | upd72001_cls_por(SIOPCB *p_siopcb)
|
---|
| 357 | {
|
---|
| 358 | upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl, UPD72001_CR1, CR1_DOWN);
|
---|
| 359 | p_siopcb->openflag = false;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | /*
|
---|
| 363 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®æåéä¿¡
|
---|
| 364 | */
|
---|
| 365 | bool_t
|
---|
| 366 | upd72001_snd_chr(SIOPCB *p_siopcb, char c)
|
---|
| 367 | {
|
---|
| 368 | if (upd72001_putready(p_siopcb)) {
|
---|
| 369 | upd72001_putchar(p_siopcb, c);
|
---|
| 370 | return(true);
|
---|
| 371 | }
|
---|
| 372 | return(false);
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 | /*
|
---|
| 376 | * ã·ãªã¢ã«I/Oãã¼ãããã®æååä¿¡
|
---|
| 377 | */
|
---|
| 378 | int_t
|
---|
| 379 | upd72001_rcv_chr(SIOPCB *p_siopcb)
|
---|
| 380 | {
|
---|
| 381 | if (upd72001_getready(p_siopcb)) {
|
---|
| 382 | return((int_t)(uint8_t) upd72001_getchar(p_siopcb));
|
---|
| 383 | }
|
---|
| 384 | return(-1);
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | /*
|
---|
| 388 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
|
---|
| 389 | */
|
---|
| 390 | void
|
---|
| 391 | upd72001_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
|
---|
| 392 | {
|
---|
| 393 | uint8_t cr1_bit;
|
---|
| 394 |
|
---|
| 395 | switch (cbrtn) {
|
---|
| 396 | case SIO_RDY_SND:
|
---|
| 397 | cr1_bit = CR1_SEND;
|
---|
| 398 | break;
|
---|
| 399 | case SIO_RDY_RCV:
|
---|
| 400 | cr1_bit = CR1_RECV;
|
---|
| 401 | break;
|
---|
| 402 | default:
|
---|
| 403 | cr1_bit = 0U;
|
---|
| 404 | break;
|
---|
| 405 | }
|
---|
| 406 | p_siopcb->cr1 |= cr1_bit;
|
---|
| 407 | upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
|
---|
| 408 | UPD72001_CR1, p_siopcb->cr1);
|
---|
| 409 | }
|
---|
| 410 |
|
---|
| 411 | /*
|
---|
| 412 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ¢
|
---|
| 413 | */
|
---|
| 414 | void
|
---|
| 415 | upd72001_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
|
---|
| 416 | {
|
---|
| 417 | uint8_t cr1_bit;
|
---|
| 418 |
|
---|
| 419 | switch (cbrtn) {
|
---|
| 420 | case SIO_RDY_SND:
|
---|
| 421 | cr1_bit = CR1_SEND;
|
---|
| 422 | break;
|
---|
| 423 | case SIO_RDY_RCV:
|
---|
| 424 | cr1_bit = CR1_RECV;
|
---|
| 425 | break;
|
---|
| 426 | default:
|
---|
| 427 | cr1_bit = 0U;
|
---|
| 428 | break;
|
---|
| 429 | }
|
---|
| 430 | p_siopcb->cr1 &= ~cr1_bit;
|
---|
| 431 | upd72001_write_ctrl(p_siopcb->p_siopinib->ctrl,
|
---|
| 432 | UPD72001_CR1, p_siopcb->cr1);
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | /*
|
---|
| 436 | * ã·ãªã¢ã«I/Oãã¼ãã«å¯¾ããå²è¾¼ã¿å¦ç
|
---|
| 437 | */
|
---|
| 438 | static void
|
---|
| 439 | upd72001_isr_siop(SIOPCB *p_siopcb)
|
---|
| 440 | {
|
---|
| 441 | if ((p_siopcb->cr1 & CR1_RECV) != 0U) {
|
---|
| 442 | if (upd72001_getready(p_siopcb)) {
|
---|
| 443 | /*
|
---|
| 444 | * åä¿¡éç¥ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
|
---|
| 445 | */
|
---|
| 446 | upd72001_irdy_rcv(p_siopcb->exinf);
|
---|
| 447 | }
|
---|
| 448 | }
|
---|
| 449 | if ((p_siopcb->cr1 & CR1_SEND) != 0U) {
|
---|
| 450 | if (upd72001_putready(p_siopcb)) {
|
---|
| 451 | /*
|
---|
| 452 | * éä¿¡å¯è½ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
|
---|
| 453 | */
|
---|
| 454 | upd72001_irdy_snd(p_siopcb->exinf);
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
| 458 |
|
---|
| 459 | /*
|
---|
| 460 | * SIOã®å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³
|
---|
| 461 | */
|
---|
| 462 | void
|
---|
| 463 | upd72001_isr(void)
|
---|
| 464 | {
|
---|
| 465 | if (siopcb_table[0].openflag) {
|
---|
| 466 | upd72001_isr_siop(&(siopcb_table[0]));
|
---|
| 467 | }
|
---|
| 468 | if (siopcb_table[1].openflag) {
|
---|
| 469 | upd72001_isr_siop(&(siopcb_table[1]));
|
---|
| 470 | }
|
---|
| 471 | upd72001_eoi();
|
---|
| 472 | }
|
---|