src/emu/machine/im6402.c
| r0 | r14107 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | Intersil IM6402 Universal Asynchronous Receiver/Transmitter emulation
|
| 4 | |
| 5 | Copyright the MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | ***************************************************************************/
|
| 9 | |
| 10 | #include "im6402.h"
|
| 11 | |
| 12 | |
| 13 | |
| 14 | //**************************************************************************
|
| 15 | // DEVICE DEFINITIONS
|
| 16 | //**************************************************************************
|
| 17 | |
| 18 | const device_type IM6402 = &device_creator<im6402_device>;
|
| 19 | |
| 20 | |
| 21 | |
| 22 | //**************************************************************************
|
| 23 | // MACROS / CONSTANTS
|
| 24 | //**************************************************************************
|
| 25 | |
| 26 | #define LOG 0
|
| 27 | |
| 28 | |
| 29 | |
| 30 | //**************************************************************************
|
| 31 | // INLINE HELPERS
|
| 32 | //**************************************************************************
|
| 33 | |
| 34 | //-------------------------------------------------
|
| 35 | // set_dr -
|
| 36 | //-------------------------------------------------
|
| 37 | |
| 38 | inline void im6402_device::set_dr(int state)
|
| 39 | {
|
| 40 | m_dr = state;
|
| 41 |
|
| 42 | m_out_dr_func(state);
|
| 43 | }
|
| 44 | |
| 45 | |
| 46 | //-------------------------------------------------
|
| 47 | // set_tbre -
|
| 48 | //-------------------------------------------------
|
| 49 | |
| 50 | inline void im6402_device::set_tbre(int state)
|
| 51 | {
|
| 52 | m_tbre = state;
|
| 53 |
|
| 54 | m_out_tbre_func(state);
|
| 55 | }
|
| 56 | |
| 57 | |
| 58 | //-------------------------------------------------
|
| 59 | // set_tre -
|
| 60 | //-------------------------------------------------
|
| 61 | |
| 62 | inline void im6402_device::set_tre(int state)
|
| 63 | {
|
| 64 | m_tre = state;
|
| 65 |
|
| 66 | m_out_tre_func(state);
|
| 67 | }
|
| 68 | |
| 69 | |
| 70 | //-------------------------------------------------
|
| 71 | // receive -
|
| 72 | //-------------------------------------------------
|
| 73 | |
| 74 | inline void im6402_device::receive()
|
| 75 | {
|
| 76 | if (m_in_rri_func.isnull())
|
| 77 | {
|
| 78 | receive_register_update_bit(get_in_data_bit());
|
| 79 | }
|
| 80 | else
|
| 81 | {
|
| 82 | receive_register_update_bit(m_in_rri_func());
|
| 83 | }
|
| 84 | |
| 85 | if (is_receive_register_full())
|
| 86 | {
|
| 87 | receive_register_extract();
|
| 88 | m_rbr = get_received_char();
|
| 89 | |
| 90 | if (m_dr)
|
| 91 | {
|
| 92 | m_oe = 1;
|
| 93 | }
|
| 94 | |
| 95 | set_dr(ASSERT_LINE);
|
| 96 | }
|
| 97 | }
|
| 98 | |
| 99 | |
| 100 | //-------------------------------------------------
|
| 101 | // transmit -
|
| 102 | //-------------------------------------------------
|
| 103 | |
| 104 | inline void im6402_device::transmit()
|
| 105 | {
|
| 106 | if (is_transmit_register_empty() && !m_tbre)
|
| 107 | {
|
| 108 | transmit_register_setup(m_tbr);
|
| 109 | |
| 110 | set_tbre(ASSERT_LINE);
|
| 111 | set_tre(CLEAR_LINE);
|
| 112 | }
|
| 113 |
|
| 114 | if (!is_transmit_register_empty())
|
| 115 | {
|
| 116 | int bit = transmit_register_get_data_bit();
|
| 117 | |
| 118 | m_out_tro_func(bit);
|
| 119 | serial_connection_out();
|
| 120 | |
| 121 | if (is_transmit_register_empty())
|
| 122 | {
|
| 123 | set_tre(ASSERT_LINE);
|
| 124 | }
|
| 125 | }
|
| 126 | }
|
| 127 | |
| 128 | |
| 129 | |
| 130 | //**************************************************************************
|
| 131 | // LIVE DEVICE
|
| 132 | //**************************************************************************
|
| 133 | |
| 134 | //-------------------------------------------------
|
| 135 | // im6402_device - constructor
|
| 136 | //-------------------------------------------------
|
| 137 | |
| 138 | im6402_device::im6402_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
| 139 | : device_t(mconfig, IM6402, "Intersil IM6402", tag, owner, clock),
|
| 140 | device_serial_interface(mconfig, *this)
|
| 141 | {
|
| 142 | }
|
| 143 | |
| 144 | |
| 145 | //-------------------------------------------------
|
| 146 | // device_config_complete - perform any
|
| 147 | // operations now that the configuration is
|
| 148 | // complete
|
| 149 | //-------------------------------------------------
|
| 150 | |
| 151 | void im6402_device::device_config_complete()
|
| 152 | {
|
| 153 | // inherit a copy of the static data
|
| 154 | const im6402_interface *intf = reinterpret_cast<const im6402_interface *>(static_config());
|
| 155 | if (intf != NULL)
|
| 156 | *static_cast<im6402_interface *>(this) = *intf;
|
| 157 | |
| 158 | // or initialize to defaults if none provided
|
| 159 | else
|
| 160 | {
|
| 161 | memset(&m_in_rri_cb, 0, sizeof(m_in_rri_cb));
|
| 162 | memset(&m_out_tro_cb, 0, sizeof(m_out_tro_cb));
|
| 163 | memset(&m_out_dr_cb, 0, sizeof(m_out_dr_cb));
|
| 164 | memset(&m_out_tbre_cb, 0, sizeof(m_out_tbre_cb));
|
| 165 | memset(&m_out_tre_cb, 0, sizeof(m_out_tre_cb));
|
| 166 | }
|
| 167 | }
|
| 168 | |
| 169 | |
| 170 | //-------------------------------------------------
|
| 171 | // device_start - device-specific startup
|
| 172 | //-------------------------------------------------
|
| 173 | |
| 174 | void im6402_device::device_start()
|
| 175 | {
|
| 176 | // resolve callbacks
|
| 177 | m_in_rri_func.resolve(m_in_rri_cb, *this);
|
| 178 | m_out_tro_func.resolve(m_out_tro_cb, *this);
|
| 179 | m_out_dr_func.resolve(m_out_dr_cb, *this);
|
| 180 | m_out_tbre_func.resolve(m_out_tbre_cb, *this);
|
| 181 | m_out_tre_func.resolve(m_out_tre_cb, *this);
|
| 182 | |
| 183 | // create the timers
|
| 184 | if (m_rrc > 0)
|
| 185 | {
|
| 186 | m_rx_timer = timer_alloc(TIMER_RX);
|
| 187 | m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rrc));
|
| 188 | }
|
| 189 | |
| 190 | if (m_trc > 0)
|
| 191 | {
|
| 192 | m_tx_timer = timer_alloc(TIMER_TX);
|
| 193 | m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_trc));
|
| 194 | }
|
| 195 | |
| 196 | // state saving
|
| 197 | save_item(NAME(m_dr));
|
| 198 | save_item(NAME(m_tbre));
|
| 199 | save_item(NAME(m_tre));
|
| 200 | save_item(NAME(m_pe));
|
| 201 | save_item(NAME(m_fe));
|
| 202 | save_item(NAME(m_oe));
|
| 203 | save_item(NAME(m_cls1));
|
| 204 | save_item(NAME(m_cls2));
|
| 205 | save_item(NAME(m_sbs));
|
| 206 | save_item(NAME(m_sfd));
|
| 207 | save_item(NAME(m_epe));
|
| 208 | save_item(NAME(m_pi));
|
| 209 | save_item(NAME(m_rbr));
|
| 210 | save_item(NAME(m_rrc_count));
|
| 211 | save_item(NAME(m_tbr));
|
| 212 | save_item(NAME(m_trc_count));
|
| 213 | }
|
| 214 | |
| 215 | |
| 216 | //-------------------------------------------------
|
| 217 | // device_reset - device-specific reset
|
| 218 | //-------------------------------------------------
|
| 219 | |
| 220 | void im6402_device::device_reset()
|
| 221 | {
|
| 222 | m_rrc_count = 0;
|
| 223 | m_trc_count = 0;
|
| 224 | |
| 225 | m_rbr = 0;
|
| 226 | m_pe = 0;
|
| 227 | m_fe = 0;
|
| 228 | m_oe = 0;
|
| 229 |
|
| 230 | set_dr(CLEAR_LINE);
|
| 231 | set_tbre(ASSERT_LINE);
|
| 232 | set_tre(ASSERT_LINE);
|
| 233 | }
|
| 234 | |
| 235 | |
| 236 | //-------------------------------------------------
|
| 237 | // device_timer - handler timer events
|
| 238 | //-------------------------------------------------
|
| 239 | |
| 240 | void im6402_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
| 241 | {
|
| 242 | switch (id)
|
| 243 | {
|
| 244 | case TIMER_RX:
|
| 245 | rrc_w(1);
|
| 246 | break;
|
| 247 | |
| 248 | case TIMER_TX:
|
| 249 | trc_w(1);
|
| 250 | break;
|
| 251 | }
|
| 252 | }
|
| 253 | |
| 254 | |
| 255 | //-------------------------------------------------
|
| 256 | // input_callback -
|
| 257 | //-------------------------------------------------
|
| 258 | |
| 259 | void im6402_device::input_callback(UINT8 state)
|
| 260 | {
|
| 261 | }
|
| 262 | |
| 263 | |
| 264 | //-------------------------------------------------
|
| 265 | // read - receiver buffer register read
|
| 266 | //-------------------------------------------------
|
| 267 | |
| 268 | READ8_MEMBER( im6402_device::read )
|
| 269 | {
|
| 270 | return m_rbr;
|
| 271 | }
|
| 272 | |
| 273 | |
| 274 | //-------------------------------------------------
|
| 275 | // write - transmitter buffer register write
|
| 276 | //-------------------------------------------------
|
| 277 | |
| 278 | WRITE8_MEMBER( im6402_device::write )
|
| 279 | {
|
| 280 | m_tbr = data;
|
| 281 | |
| 282 | set_tbre(CLEAR_LINE);
|
| 283 | }
|
| 284 | |
| 285 | |
| 286 | //-------------------------------------------------
|
| 287 | // rrc_w - receiver register clock
|
| 288 | //-------------------------------------------------
|
| 289 | |
| 290 | WRITE_LINE_MEMBER( im6402_device::rrc_w )
|
| 291 | {
|
| 292 | if (state)
|
| 293 | {
|
| 294 | m_rrc_count++;
|
| 295 | |
| 296 | if (m_rrc_count == 16)
|
| 297 | {
|
| 298 | receive();
|
| 299 | m_rrc_count = 0;
|
| 300 | }
|
| 301 | }
|
| 302 | }
|
| 303 | |
| 304 | |
| 305 | //-------------------------------------------------
|
| 306 | // trc_w - transmitter register clock
|
| 307 | //-------------------------------------------------
|
| 308 | |
| 309 | WRITE_LINE_MEMBER( im6402_device::trc_w )
|
| 310 | {
|
| 311 | if (state)
|
| 312 | {
|
| 313 | m_trc_count++;
|
| 314 | |
| 315 | if (m_trc_count == 16)
|
| 316 | {
|
| 317 | transmit();
|
| 318 | m_trc_count = 0;
|
| 319 | }
|
| 320 | } |
| 321 | }
|
| 322 | |
| 323 | |
| 324 | //-------------------------------------------------
|
| 325 | // dr_r - data received
|
| 326 | //-------------------------------------------------
|
| 327 | |
| 328 | READ_LINE_MEMBER( im6402_device::dr_r )
|
| 329 | {
|
| 330 | return m_dr;
|
| 331 | }
|
| 332 | |
| 333 | |
| 334 | //-------------------------------------------------
|
| 335 | // tbre_r - transmitter buffer register empty
|
| 336 | //-------------------------------------------------
|
| 337 | |
| 338 | READ_LINE_MEMBER( im6402_device::tbre_r )
|
| 339 | {
|
| 340 | return m_tbre;
|
| 341 | }
|
| 342 | |
| 343 | |
| 344 | //-------------------------------------------------
|
| 345 | // tre_r - transmitter register empty
|
| 346 | //-------------------------------------------------
|
| 347 | |
| 348 | READ_LINE_MEMBER( im6402_device::tre_r )
|
| 349 | {
|
| 350 | return m_tre;
|
| 351 | }
|
| 352 | |
| 353 | |
| 354 | //-------------------------------------------------
|
| 355 | // pe_r - parity error
|
| 356 | //-------------------------------------------------
|
| 357 | |
| 358 | READ_LINE_MEMBER( im6402_device::pe_r )
|
| 359 | {
|
| 360 | return m_pe;
|
| 361 | }
|
| 362 | |
| 363 | |
| 364 | //-------------------------------------------------
|
| 365 | // fe_r - framing error
|
| 366 | //-------------------------------------------------
|
| 367 | |
| 368 | READ_LINE_MEMBER( im6402_device::fe_r )
|
| 369 | {
|
| 370 | return m_fe;
|
| 371 | }
|
| 372 | |
| 373 | |
| 374 | //-------------------------------------------------
|
| 375 | // oe_r - overrun error
|
| 376 | //-------------------------------------------------
|
| 377 | |
| 378 | READ_LINE_MEMBER( im6402_device::oe_r )
|
| 379 | {
|
| 380 | return m_oe;
|
| 381 | }
|
| 382 | |
| 383 | |
| 384 | //-------------------------------------------------
|
| 385 | // rrd_w - receiver register disable
|
| 386 | //-------------------------------------------------
|
| 387 | |
| 388 | WRITE_LINE_MEMBER( im6402_device::rrd_w )
|
| 389 | {
|
| 390 | }
|
| 391 | |
| 392 | |
| 393 | //-------------------------------------------------
|
| 394 | // sfd_w - status flags disable
|
| 395 | //-------------------------------------------------
|
| 396 | |
| 397 | WRITE_LINE_MEMBER( im6402_device::sfd_w )
|
| 398 | {
|
| 399 | }
|
| 400 | |
| 401 | |
| 402 | //-------------------------------------------------
|
| 403 | // drr_w - data received reset
|
| 404 | //-------------------------------------------------
|
| 405 | |
| 406 | WRITE_LINE_MEMBER( im6402_device::drr_w )
|
| 407 | {
|
| 408 | if (state)
|
| 409 | {
|
| 410 | set_dr(CLEAR_LINE);
|
| 411 | }
|
| 412 | }
|
| 413 | |
| 414 | |
| 415 | //-------------------------------------------------
|
| 416 | // mr_w - master reset
|
| 417 | //-------------------------------------------------
|
| 418 | |
| 419 | WRITE_LINE_MEMBER( im6402_device::mr_w )
|
| 420 | {
|
| 421 | if (state)
|
| 422 | {
|
| 423 | device_reset();
|
| 424 | }
|
| 425 | }
|
| 426 | |
| 427 | |
| 428 | //-------------------------------------------------
|
| 429 | // crl_w - control register load
|
| 430 | //-------------------------------------------------
|
| 431 | |
| 432 | WRITE_LINE_MEMBER( im6402_device::crl_w )
|
| 433 | {
|
| 434 | if (state)
|
| 435 | {
|
| 436 | int word_length = 5 + ((m_cls2 << 1) | m_cls1);
|
| 437 | int stop_bits = 1 + m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0;
|
| 438 | int parity_code;
|
| 439 | |
| 440 | if (m_pi) parity_code = SERIAL_PARITY_NONE; |
| 441 | else if (m_epe) parity_code = SERIAL_PARITY_EVEN; |
| 442 | else parity_code = SERIAL_PARITY_ODD;
|
| 443 | |
| 444 | set_data_frame(word_length, stop_bits, parity_code);
|
| 445 | }
|
| 446 | }
|
| 447 | |
| 448 | |
| 449 | //-------------------------------------------------
|
| 450 | // pi_w - parity inhibit
|
| 451 | //-------------------------------------------------
|
| 452 | |
| 453 | WRITE_LINE_MEMBER( im6402_device::pi_w )
|
| 454 | {
|
| 455 | m_pi = state;
|
| 456 | }
|
| 457 | |
| 458 | |
| 459 | //-------------------------------------------------
|
| 460 | // sbs_w - stop bit select
|
| 461 | //-------------------------------------------------
|
| 462 | |
| 463 | WRITE_LINE_MEMBER( im6402_device::sbs_w )
|
| 464 | {
|
| 465 | m_sbs = state;
|
| 466 | }
|
| 467 | |
| 468 | |
| 469 | //-------------------------------------------------
|
| 470 | // cls1_w - character length select 1
|
| 471 | //-------------------------------------------------
|
| 472 | |
| 473 | WRITE_LINE_MEMBER( im6402_device::cls1_w )
|
| 474 | {
|
| 475 | m_cls1 = state;
|
| 476 | }
|
| 477 | |
| 478 | |
| 479 | //-------------------------------------------------
|
| 480 | // cls2_w - character length select 2
|
| 481 | //-------------------------------------------------
|
| 482 | |
| 483 | WRITE_LINE_MEMBER( im6402_device::cls2_w )
|
| 484 | {
|
| 485 | m_cls2 = state;
|
| 486 | }
|
| 487 | |
| 488 | |
| 489 | //-------------------------------------------------
|
| 490 | // epe_w - even parity enable
|
| 491 | //-------------------------------------------------
|
| 492 | |
| 493 | WRITE_LINE_MEMBER( im6402_device::epe_w )
|
| 494 | {
|
| 495 | m_epe = state;
|
| 496 | }
|
src/emu/machine/im6402.h
| r0 | r14107 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | Intersil IM6402 Universal Asynchronous Receiver/Transmitter emulation
|
| 4 | |
| 5 | Copyright the MESS Team.
|
| 6 | Visit http://mamedev.org for licensing and usage restrictions.
|
| 7 | |
| 8 | ****************************************************************************
|
| 9 | _____ _____
|
| 10 | Vcc 1 |* \_/ | 40 NOTE
|
| 11 | NOTE 2 | | 39 EPE
|
| 12 | GND 3 | | 38 CLS1
|
| 13 | RRD 4 | | 37 CLS2
|
| 14 | RBR8 5 | | 36 SBS
|
| 15 | RBR7 6 | | 35 PI
|
| 16 | RBR6 7 | | 34 CRL
|
| 17 | RBR5 8 | | 33 TBR8
|
| 18 | RBR4 9 | | 32 TBR7
|
| 19 | RBR3 10 | IM6402 | 31 TBR6
|
| 20 | RBR2 11 | IM6403 | 30 TBR5
|
| 21 | RBR1 12 | | 29 TBR4
|
| 22 | PE 13 | | 28 TBR3
|
| 23 | FE 14 | | 27 TBR2
|
| 24 | OE 15 | | 26 TBR1
|
| 25 | SFD 16 | | 25 TRO
|
| 26 | NOTE 17 | | 24 TRE
|
| 27 | DRR 18 | | 23 TRBL
|
| 28 | DR 19 | | 22 TBRE
|
| 29 | RRI 20 |_____________| 21 MR
|
| 30 | |
| 31 | |
| 32 | NOTE: PIN IM6402 IM6403
|
| 33 | ---------------------------
|
| 34 | 2 N/C CONTROL
|
| 35 | 17 RRC OSC IN
|
| 36 | 40 TRC OSC OUT
|
| 37 |
|
| 38 | ***************************************************************************/
|
| 39 | |
| 40 | #pragma once
|
| 41 | |
| 42 | #ifndef __IM6402__
|
| 43 | #define __IM6402__
|
| 44 | |
| 45 | #include "emu.h"
|
| 46 | |
| 47 | |
| 48 | |
| 49 | /***************************************************************************
|
| 50 | DEVICE CONFIGURATION MACROS
|
| 51 | ***************************************************************************/
|
| 52 | |
| 53 | #define MCFG_IM6402_ADD(_tag, _config) \
|
| 54 | MCFG_DEVICE_ADD(_tag, IM6402, 0) \
|
| 55 | MCFG_DEVICE_CONFIG(_config)
|
| 56 | |
| 57 | |
| 58 | #define IM6402_INTERFACE(_name) \
|
| 59 | const im6402_interface (_name) =
|
| 60 | |
| 61 | |
| 62 | |
| 63 | /***************************************************************************
|
| 64 | TYPE DEFINITIONS
|
| 65 | ***************************************************************************/
|
| 66 | |
| 67 | // ======================> im6402_interface
|
| 68 | |
| 69 | struct im6402_interface
|
| 70 | {
|
| 71 | int m_rrc;
|
| 72 | int m_trc;
|
| 73 |
|
| 74 | devcb_read_line m_in_rri_cb;
|
| 75 | devcb_write_line m_out_tro_cb;
|
| 76 | devcb_write_line m_out_dr_cb;
|
| 77 | devcb_write_line m_out_tbre_cb;
|
| 78 | devcb_write_line m_out_tre_cb;
|
| 79 | };
|
| 80 | |
| 81 | |
| 82 | // ======================> im6402_device
|
| 83 | |
| 84 | class im6402_device : public device_t, |
| 85 | public device_serial_interface,
|
| 86 | public im6402_interface
|
| 87 | {
|
| 88 | public:
|
| 89 | // construction/destruction
|
| 90 | im6402_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
| 91 | |
| 92 | DECLARE_READ8_MEMBER( read );
|
| 93 | DECLARE_WRITE8_MEMBER( write );
|
| 94 |
|
| 95 | DECLARE_READ_LINE_MEMBER( dr_r );
|
| 96 | DECLARE_READ_LINE_MEMBER( tbre_r );
|
| 97 | DECLARE_READ_LINE_MEMBER( tre_r );
|
| 98 | DECLARE_READ_LINE_MEMBER( pe_r );
|
| 99 | DECLARE_READ_LINE_MEMBER( fe_r );
|
| 100 | DECLARE_READ_LINE_MEMBER( oe_r );
|
| 101 | |
| 102 | DECLARE_WRITE_LINE_MEMBER( rrc_w );
|
| 103 | DECLARE_WRITE_LINE_MEMBER( trc_w );
|
| 104 | DECLARE_WRITE_LINE_MEMBER( rrd_w );
|
| 105 | DECLARE_WRITE_LINE_MEMBER( sfd_w );
|
| 106 | DECLARE_WRITE_LINE_MEMBER( drr_w );
|
| 107 | DECLARE_WRITE_LINE_MEMBER( mr_w );
|
| 108 | DECLARE_WRITE_LINE_MEMBER( crl_w );
|
| 109 | DECLARE_WRITE_LINE_MEMBER( pi_w );
|
| 110 | DECLARE_WRITE_LINE_MEMBER( sbs_w );
|
| 111 | DECLARE_WRITE_LINE_MEMBER( cls1_w );
|
| 112 | DECLARE_WRITE_LINE_MEMBER( cls2_w );
|
| 113 | DECLARE_WRITE_LINE_MEMBER( epe_w );
|
| 114 | |
| 115 | protected:
|
| 116 | // device-level overrides
|
| 117 | virtual void device_config_complete();
|
| 118 | virtual void device_start();
|
| 119 | virtual void device_reset();
|
| 120 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
| 121 |
|
| 122 | // device_serial_interface overrides
|
| 123 | virtual void input_callback(UINT8 state);
|
| 124 | |
| 125 | private:
|
| 126 | inline void set_dr(int state);
|
| 127 | inline void set_tbre(int state);
|
| 128 | inline void set_tre(int state);
|
| 129 | inline void receive();
|
| 130 | inline void transmit();
|
| 131 |
|
| 132 | static const device_timer_id TIMER_RX = 0;
|
| 133 | static const device_timer_id TIMER_TX = 1;
|
| 134 | |
| 135 | devcb_resolved_read_line m_in_rri_func;
|
| 136 | devcb_resolved_write_line m_out_tro_func;
|
| 137 | devcb_resolved_write_line m_out_dr_func;
|
| 138 | devcb_resolved_write_line m_out_tbre_func;
|
| 139 | devcb_resolved_write_line m_out_tre_func;
|
| 140 | |
| 141 | // status
|
| 142 | int m_dr;
|
| 143 | int m_tbre;
|
| 144 | int m_tre;
|
| 145 | int m_pe;
|
| 146 | int m_fe;
|
| 147 | int m_oe;
|
| 148 |
|
| 149 | // control
|
| 150 | int m_cls1;
|
| 151 | int m_cls2;
|
| 152 | int m_sbs;
|
| 153 | int m_sfd;
|
| 154 | int m_epe;
|
| 155 | int m_pi;
|
| 156 |
|
| 157 | // receiver
|
| 158 | UINT8 m_rbr;
|
| 159 | int m_rrc_count;
|
| 160 |
|
| 161 | // transmitter
|
| 162 | UINT8 m_tbr;
|
| 163 | int m_trc_count;
|
| 164 |
|
| 165 | // timers
|
| 166 | emu_timer *m_rx_timer;
|
| 167 | emu_timer *m_tx_timer;
|
| 168 | };
|
| 169 | |
| 170 | |
| 171 | // device type definition
|
| 172 | extern const device_type IM6402;
|
| 173 | |
| 174 | |
| 175 | |
| 176 | #endif
|
src/mess/drivers/kyocera.c
| r14106 | r14107 | |
| 227 | 227 | 7 |
| 228 | 228 | |
| 229 | 229 | */ |
| 230 | | /* |
| 230 | |
| 231 | 231 | m_uart->sbs_w(BIT(data, 0)); |
| 232 | 232 | m_uart->epe_w(BIT(data, 1)); |
| 233 | 233 | m_uart->pi_w(BIT(data, 2)); |
| 234 | 234 | m_uart->cls1_w(BIT(data, 3)); |
| 235 | 235 | m_uart->cls2_w(BIT(data, 4)); |
| 236 | | */ |
| 236 | |
| 237 | m_uart->crl_w(1); |
| 237 | 238 | } |
| 238 | 239 | |
| 239 | 240 | READ8_MEMBER( kc85_state::uart_status_r ) |
| r14106 | r14107 | |
| 255 | 256 | |
| 256 | 257 | UINT8 data = 0x40; |
| 257 | 258 | |
| 258 | | // carrier detect |
| 259 | | //data |= m_uart->cd_r(); |
| 259 | // TODO carrier detect |
| 260 | 260 | |
| 261 | 261 | // overrun error |
| 262 | | //data |= m_uart->oe_r() << 1; |
| 262 | data |= m_uart->oe_r() << 1; |
| 263 | 263 | |
| 264 | 264 | // framing error |
| 265 | | //data |= m_uart->fe_r() << 2; |
| 265 | data |= m_uart->fe_r() << 2; |
| 266 | 266 | |
| 267 | 267 | // parity error |
| 268 | | //data |= m_uart->pe_r() << 3; |
| 268 | data |= m_uart->pe_r() << 3; |
| 269 | 269 | |
| 270 | 270 | // transmit buffer register empty |
| 271 | | //data |= m_uart->tbre_r() << 4; |
| 271 | data |= m_uart->tbre_r() << 4; |
| 272 | 272 | |
| 273 | 273 | // rp TODO |
| 274 | 274 | data |= 0x20; |
| r14106 | r14107 | |
| 298 | 298 | |
| 299 | 299 | UINT8 data = 0x40; |
| 300 | 300 | |
| 301 | | // data carrier detect / ring detect |
| 302 | | //data |= m_uart->cd_r(); |
| 301 | // TODO data carrier detect / ring detect |
| 303 | 302 | |
| 304 | 303 | // overrun error |
| 305 | | //data |= m_uart->oe_r() << 1; |
| 304 | data |= m_uart->oe_r() << 1; |
| 306 | 305 | |
| 307 | 306 | // framing error |
| 308 | | //data |= m_uart->fe_r() << 2; |
| 307 | data |= m_uart->fe_r() << 2; |
| 309 | 308 | |
| 310 | 309 | // parity error |
| 311 | | //data |= m_uart->pe_r() << 3; |
| 310 | data |= m_uart->pe_r() << 3; |
| 312 | 311 | |
| 313 | 312 | // transmit buffer register empty |
| 314 | | //data |= m_uart->tbre_r() << 4; |
| 313 | data |= m_uart->tbre_r() << 4; |
| 315 | 314 | |
| 316 | 315 | // rp TODO |
| 317 | 316 | data |= 0x20; |
| r14106 | r14107 | |
| 585 | 584 | // AM_RANGE(0x90, 0x90) AM_MIRROR(0x0f) optional answering telephone unit |
| 586 | 585 | // AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0f) optional modem |
| 587 | 586 | AM_RANGE(0xb0, 0xb7) AM_MIRROR(0x08) AM_DEVREADWRITE(I8155_TAG, i8155_device, io_r, io_w) |
| 588 | | // AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x0f) AM_DEVREADWRITE(IM6402_TAG, data_r, data_w) |
| 587 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x0f) AM_DEVREADWRITE(IM6402_TAG, im6402_device, read, write) |
| 589 | 588 | AM_RANGE(0xd0, 0xd0) AM_MIRROR(0x0f) AM_READWRITE(uart_status_r, uart_ctrl_w) |
| 590 | 589 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x0f) AM_READWRITE(keyboard_r, ctrl_w) |
| 591 | 590 | AM_RANGE(0xf0, 0xf1) AM_MIRROR(0x0e) AM_READWRITE(lcd_r, lcd_w) |
| r14106 | r14107 | |
| 606 | 605 | AM_RANGE(0x90, 0x90) AM_MIRROR(0x0f) AM_WRITE(scp_w) |
| 607 | 606 | AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0f) AM_READWRITE(bank_r, bank_w) |
| 608 | 607 | AM_RANGE(0xb0, 0xb7) AM_MIRROR(0x08) AM_DEVREADWRITE(I8155_TAG, i8155_device, io_r, io_w) |
| 609 | | // AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x0f) AM_DEVREADWRITE(IM6402_TAG, data_r, data_w) |
| 608 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x0f) AM_DEVREADWRITE(IM6402_TAG, im6402_device, read, write) |
| 610 | 609 | AM_RANGE(0xd0, 0xd0) AM_MIRROR(0x0f) AM_READ(uart_status_r) AM_WRITE_BASE(kc85_state, uart_ctrl_w) |
| 611 | 610 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x0f) AM_READ_BASE(kc85_state, keyboard_r) |
| 612 | 611 | AM_RANGE(0xf0, 0xf1) AM_MIRROR(0x0e) AM_READWRITE_BASE(kc85_state, lcd_r, lcd_w) |
| r14106 | r14107 | |
| 989 | 988 | { |
| 990 | 989 | speaker_level_w(m_speaker, state); |
| 991 | 990 | } |
| 991 | |
| 992 | m_uart->trc_w(state); |
| 993 | m_uart->rrc_w(state); |
| 992 | 994 | } |
| 993 | 995 | |
| 994 | 996 | static I8155_INTERFACE( kc85_8155_intf ) |
| r14106 | r14107 | |
| 1093 | 1095 | DEVCB_DRIVER_LINE_MEMBER(tandy200_state, i8155_to_w) /* timer output */ |
| 1094 | 1096 | }; |
| 1095 | 1097 | |
| 1098 | /* IM6402 Interface */ |
| 1099 | |
| 1100 | static IM6402_INTERFACE( uart_intf ) |
| 1101 | { |
| 1102 | 0, |
| 1103 | 0, |
| 1104 | DEVCB_NULL, |
| 1105 | DEVCB_NULL, |
| 1106 | DEVCB_NULL, |
| 1107 | DEVCB_NULL, |
| 1108 | DEVCB_NULL |
| 1109 | }; |
| 1110 | |
| 1096 | 1111 | /* I8251 Interface */ |
| 1097 | 1112 | |
| 1098 | 1113 | static const i8251_interface tandy200_uart_intf = |
| r14106 | r14107 | |
| 1299 | 1314 | /* devices */ |
| 1300 | 1315 | MCFG_I8155_ADD(I8155_TAG, XTAL_4_9152MHz/2, kc85_8155_intf) |
| 1301 | 1316 | MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, kc85_upd1990a_intf) |
| 1317 | MCFG_IM6402_ADD(IM6402_TAG, uart_intf) |
| 1302 | 1318 | MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics) |
| 1303 | 1319 | MCFG_CASSETTE_ADD(CASSETTE_TAG, kc85_cassette_interface) |
| 1304 | 1320 | |
| r14106 | r14107 | |
| 1335 | 1351 | /* devices */ |
| 1336 | 1352 | MCFG_I8155_ADD(I8155_TAG, XTAL_4_9152MHz/2, kc85_8155_intf) |
| 1337 | 1353 | MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, kc85_upd1990a_intf) |
| 1354 | MCFG_IM6402_ADD(IM6402_TAG, uart_intf) |
| 1338 | 1355 | MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics) |
| 1339 | 1356 | MCFG_CASSETTE_ADD(CASSETTE_TAG, kc85_cassette_interface) |
| 1340 | 1357 | |
| r14106 | r14107 | |
| 1377 | 1394 | /* devices */ |
| 1378 | 1395 | MCFG_I8155_ADD(I8155_TAG, XTAL_4_9152MHz/2, kc85_8155_intf) |
| 1379 | 1396 | MCFG_UPD1990A_ADD(UPD1990A_TAG, XTAL_32_768kHz, kc85_upd1990a_intf) |
| 1397 | MCFG_IM6402_ADD(IM6402_TAG, uart_intf) |
| 1380 | 1398 | MCFG_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics) |
| 1381 | 1399 | MCFG_CASSETTE_ADD(CASSETTE_TAG, kc85_cassette_interface) |
| 1382 | 1400 | // MCFG_MC14412_ADD(MC14412_TAG, XTAL_1MHz) |