src/emu/machine/6551acia.c
| r0 | r12779 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | 6551.h |
| 4 | |
| 5 | MOS Technology 6551 Asynchronous Communications Interface Adapter |
| 6 | |
| 7 | A1 A0 Write Read |
| 8 | 0 0 Transmit Data Register Receiver Data Register |
| 9 | 0 1 Programmed Reset Status Register |
| 10 | 1 0 Command Register |
| 11 | 1 1 Control Register |
| 12 | |
| 13 | *********************************************************************/ |
| 14 | |
| 15 | #include "emu.h" |
| 16 | #include "6551acia.h" |
| 17 | |
| 18 | |
| 19 | //************************************************************************** |
| 20 | // DEVICE DEFINITIONS |
| 21 | //************************************************************************** |
| 22 | |
| 23 | const device_type ACIA6551 = &device_creator<acia6551_device>; |
| 24 | |
| 25 | //------------------------------------------------- |
| 26 | // acia6551_device - constructor |
| 27 | //------------------------------------------------- |
| 28 | |
| 29 | acia6551_device::acia6551_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 30 | : device_t(mconfig, ACIA6551, "MOS Technology 6551 ACIA", tag, owner, clock), |
| 31 | device_serial_interface(mconfig, *this) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | /*************************************************************************** |
| 36 | IMPLEMENTATION |
| 37 | ***************************************************************************/ |
| 38 | |
| 39 | /*------------------------------------------------- |
| 40 | input_callback - called when other side |
| 41 | has updated state |
| 42 | -------------------------------------------------*/ |
| 43 | void acia6551_device::input_callback(UINT8 state) |
| 44 | { |
| 45 | m_input_state = state; |
| 46 | } |
| 47 | |
| 48 | /*------------------------------------------------- |
| 49 | timer_callback |
| 50 | -------------------------------------------------*/ |
| 51 | void acia6551_device::timer_callback() |
| 52 | { |
| 53 | /* get bit received from other side and update receive register */ |
| 54 | receive_register_update_bit(get_in_data_bit()); |
| 55 | |
| 56 | if (is_receive_register_full()) |
| 57 | { |
| 58 | receive_register_extract(); |
| 59 | receive_character(get_received_char()); |
| 60 | } |
| 61 | |
| 62 | /* transmit register full? */ |
| 63 | if ((m_status_register & (1<<4))==0) |
| 64 | { |
| 65 | /* if transmit reg is empty */ |
| 66 | if (is_transmit_register_empty()) |
| 67 | { |
| 68 | /* set it up */ |
| 69 | transmit_register_setup(m_transmit_data_register); |
| 70 | /* acia transmit reg now empty */ |
| 71 | m_status_register |=(1<<4); |
| 72 | /* and refresh ints */ |
| 73 | refresh_ints(); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /* if transmit is not empty... transmit data */ |
| 78 | if (!is_transmit_register_empty()) |
| 79 | { |
| 80 | // logerror("UART6551\n"); |
| 81 | transmit_register_send_bit(); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | static TIMER_CALLBACK(acia_6551_timer_callback) |
| 86 | { |
| 87 | reinterpret_cast<acia6551_device *>(ptr)->timer_callback(); |
| 88 | } |
| 89 | |
| 90 | //------------------------------------------------- |
| 91 | // device_start - device-specific startup |
| 92 | //------------------------------------------------- |
| 93 | |
| 94 | void acia6551_device::device_start() |
| 95 | { |
| 96 | /* transmit data reg is empty */ |
| 97 | m_status_register |= (1<<4); |
| 98 | m_timer = machine().scheduler().timer_alloc(FUNC(acia_6551_timer_callback), (void *) this); |
| 99 | |
| 100 | transmit_register_reset(); |
| 101 | receive_register_reset(); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | |
| 106 | /*------------------------------------------------- |
| 107 | refresh_ints - update interrupt output |
| 108 | -------------------------------------------------*/ |
| 109 | |
| 110 | void acia6551_device::refresh_ints() |
| 111 | { |
| 112 | int interrupt_state; |
| 113 | |
| 114 | interrupt_state = 0; |
| 115 | |
| 116 | /* receive interrupts */ |
| 117 | |
| 118 | /* receive data register full? */ |
| 119 | if (m_status_register & (1<<3)) |
| 120 | { |
| 121 | /* receiver interrupt enable? */ |
| 122 | if ((m_command_register & (1<<1))==0) |
| 123 | { |
| 124 | /* trigger a interrupt */ |
| 125 | interrupt_state = 1; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | /* set state of irq bit in status register */ |
| 130 | m_status_register &= ~(1<<7); |
| 131 | |
| 132 | if (interrupt_state) |
| 133 | { |
| 134 | m_status_register |=(1<<7); |
| 135 | } |
| 136 | |
| 137 | //if (m_irq_callback != NULL) |
| 138 | //(*m_irq_callback)(interrupt_state); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | |
| 143 | /*------------------------------------------------- |
| 144 | receive_character |
| 145 | -------------------------------------------------*/ |
| 146 | |
| 147 | void acia6551_device::receive_character(UINT8 ch) |
| 148 | { |
| 149 | /* receive register full? */ |
| 150 | if (m_status_register & (1<<3)) |
| 151 | { |
| 152 | /* set overrun error */ |
| 153 | m_status_register |= (1<<2); |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | /* set new byte */ |
| 158 | m_receive_data_register = ch; |
| 159 | /* receive register is full */ |
| 160 | m_status_register |= (1<<3); |
| 161 | /* update ints */ |
| 162 | refresh_ints(); |
| 163 | } |
| 164 | |
| 165 | |
| 166 | |
| 167 | /*------------------------------------------------- |
| 168 | read |
| 169 | -------------------------------------------------*/ |
| 170 | |
| 171 | READ8_MEMBER(acia6551_device::read) |
| 172 | { |
| 173 | unsigned char data; |
| 174 | |
| 175 | data = 0x0ff; |
| 176 | switch (offset & 0x03) |
| 177 | { |
| 178 | case 0: |
| 179 | { |
| 180 | /* clear parity error, framing error and overrun error */ |
| 181 | /* when read of data reigster is done */ |
| 182 | m_status_register &=~((1<<0) | (1<<1) | (1<<2)); |
| 183 | /* clear receive data register full flag */ |
| 184 | m_status_register &=~(1<<3); |
| 185 | /* return data */ |
| 186 | data = m_receive_data_register; |
| 187 | } |
| 188 | break; |
| 189 | |
| 190 | /* |
| 191 | Status cleared by |
| 192 | b0 Parity error * (1: error) self clearing ** |
| 193 | b1 Framing error * (1: error) self clearing ** |
| 194 | b2 Overrun * (1: error) self clearing ** |
| 195 | b3 Receive Data Register Full (1: full) Read Receive Data Register |
| 196 | b4 Transmit Data Reg Empty (1: empty) Write Transmit Data Register |
| 197 | b5 DCD (0: DCD low, 1: DCD high) Not resettable, reflects DCD state |
| 198 | b6 DSR (0: DSR low, 1: DCD high) Not resettable, reflects DSR state |
| 199 | b7 IRQ (0: no int., 1: interrupt) Read Status Register |
| 200 | */ |
| 201 | case 1: |
| 202 | { |
| 203 | data = m_status_register; |
| 204 | /* clear interrupt */ |
| 205 | m_status_register &= ~(1<<7); |
| 206 | } |
| 207 | break; |
| 208 | |
| 209 | case 2: |
| 210 | data = m_command_register; |
| 211 | break; |
| 212 | |
| 213 | case 3: |
| 214 | data = m_control_register; |
| 215 | break; |
| 216 | |
| 217 | default: |
| 218 | break; |
| 219 | } |
| 220 | |
| 221 | logerror("6551 R %04x %02x\n",offset & 0x03,data); |
| 222 | |
| 223 | return data; |
| 224 | } |
| 225 | |
| 226 | |
| 227 | |
| 228 | /*------------------------------------------------- |
| 229 | update_data_form |
| 230 | -------------------------------------------------*/ |
| 231 | |
| 232 | void acia6551_device::update_data_form() |
| 233 | { |
| 234 | int word_length = 8-((m_control_register>>5) & 0x03); |
| 235 | int stop_bit_count = (m_control_register>>7)+1; |
| 236 | int parity = 0; |
| 237 | if (m_command_register & (1<<5)) |
| 238 | { |
| 239 | parity = SERIAL_PARITY_ODD; |
| 240 | } |
| 241 | else |
| 242 | { |
| 243 | parity = SERIAL_PARITY_NONE; |
| 244 | } |
| 245 | |
| 246 | set_data_frame(word_length, stop_bit_count, parity); |
| 247 | } |
| 248 | |
| 249 | |
| 250 | |
| 251 | /*------------------------------------------------- |
| 252 | write |
| 253 | -------------------------------------------------*/ |
| 254 | |
| 255 | WRITE8_MEMBER(acia6551_device::write) |
| 256 | { |
| 257 | logerror("6551 W %04x %02x\n",offset & 0x03, data); |
| 258 | |
| 259 | switch (offset & 0x03) |
| 260 | { |
| 261 | case 0: |
| 262 | { |
| 263 | /* clear transmit data register empty */ |
| 264 | m_status_register &= ~(1<<4); |
| 265 | /* store byte */ |
| 266 | m_transmit_data_register = data; |
| 267 | |
| 268 | } |
| 269 | break; |
| 270 | |
| 271 | case 1: |
| 272 | { |
| 273 | /* telstrat writes 0x07f! */ |
| 274 | } |
| 275 | break; |
| 276 | |
| 277 | |
| 278 | /* |
| 279 | Command Register: |
| 280 | |
| 281 | b0 Data Terminal Ready |
| 282 | 0 : disable receiver and all interrupts (DTR high) |
| 283 | 1 : enable receiver and all interrupts (DTR low) |
| 284 | b1 Receiver Interrupt Enable |
| 285 | 0 : IRQ interrupt enabled from bit 3 of status register |
| 286 | 1 : IRQ interrupt disabled |
| 287 | b3,b2 Transmitter Control |
| 288 | Transmit Interrupt RTS level Transmitter |
| 289 | 00 disabled high off |
| 290 | 01 enabled low on |
| 291 | 10 disabled low on |
| 292 | 11 disabled low Transmit BRK |
| 293 | b4 Normal/Echo Mode for Receiver |
| 294 | 0 : normal |
| 295 | 1 : echo (bits 2 and 3 must be 0) |
| 296 | b5 Parity Enable |
| 297 | 0 : parity disabled, no parity bit generated or received |
| 298 | 1 : parity enabled |
| 299 | b7,b6 Parity |
| 300 | 00 : odd parity receiver and transmitter |
| 301 | 01 : even parity receiver and transmitter |
| 302 | 10 : mark parity bit transmitted, parity check disabled |
| 303 | 11 : space parity bit transmitted, parity check disabled |
| 304 | */ |
| 305 | |
| 306 | case 2: |
| 307 | { |
| 308 | m_command_register = data; |
| 309 | |
| 310 | /* update state of dtr */ |
| 311 | m_connection_state &=~SERIAL_STATE_DTR; |
| 312 | if (m_command_register & (1<<0)) |
| 313 | { |
| 314 | m_connection_state |=SERIAL_STATE_DTR; |
| 315 | } |
| 316 | |
| 317 | /* update state of rts */ |
| 318 | switch ((m_command_register>>2) & 0x03) |
| 319 | { |
| 320 | case 0: |
| 321 | { |
| 322 | m_connection_state &=~SERIAL_STATE_RTS; |
| 323 | } |
| 324 | break; |
| 325 | |
| 326 | case 1: |
| 327 | case 2: |
| 328 | case 3: |
| 329 | { |
| 330 | m_connection_state |=SERIAL_STATE_RTS; |
| 331 | } |
| 332 | break; |
| 333 | } |
| 334 | |
| 335 | serial_connection_out(); |
| 336 | update_data_form(); |
| 337 | } |
| 338 | break; |
| 339 | |
| 340 | /* |
| 341 | Control register: |
| 342 | |
| 343 | b3-b0 baud rate generator: |
| 344 | 0000 : 16x external clock |
| 345 | 0001 : 50 baud |
| 346 | 0010 : 75 25 |
| 347 | 0011 : 110 35 |
| 348 | 0100 : 134.5 |
| 349 | 0101 : 150 |
| 350 | 0110 : 300 150 |
| 351 | 0111 : 600 300 |
| 352 | 1000 : 1200 600 |
| 353 | 1001 : 1800 600 |
| 354 | 1010 : 2400 600 |
| 355 | 1011 : 3600 1200 |
| 356 | 1100 : 4800 1200 |
| 357 | 1101 : 7200 2400 |
| 358 | 1110 : 9600 2400 |
| 359 | 1111 : 19,200 9600 |
| 360 | b4 receiver clock source |
| 361 | 0 : external receiver clock |
| 362 | 1 : baud rate generator |
| 363 | b6,b5 word length |
| 364 | 00 : 8 bits |
| 365 | 01 : 7 |
| 366 | 10 : 6 |
| 367 | 11 : 5 |
| 368 | b7 stop bits |
| 369 | 0 : 1 stop bit |
| 370 | 1 : 2 stop bits |
| 371 | (1 stop bit if parity and word length = 8) |
| 372 | (1 1/2 stop bits if word length = 5 and no parity) |
| 373 | */ |
| 374 | case 3: |
| 375 | { |
| 376 | unsigned char previous_control_register; |
| 377 | |
| 378 | previous_control_register = m_control_register; |
| 379 | |
| 380 | if (((previous_control_register^data) & 0x07)!=0) |
| 381 | { |
| 382 | int rate; |
| 383 | |
| 384 | rate = data & 0x07; |
| 385 | |
| 386 | /* baud rate changed? */ |
| 387 | m_timer->reset(); |
| 388 | |
| 389 | if (rate==0) |
| 390 | { |
| 391 | /* 16x external clock */ |
| 392 | logerror("6551: external clock not supported!\n"); |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | int baud_rate; |
| 397 | |
| 398 | switch (rate) |
| 399 | { |
| 400 | |
| 401 | default: |
| 402 | case 1: |
| 403 | { |
| 404 | baud_rate = 50; |
| 405 | } |
| 406 | break; |
| 407 | |
| 408 | case 2: |
| 409 | { |
| 410 | baud_rate = 75; |
| 411 | } |
| 412 | break; |
| 413 | |
| 414 | case 3: |
| 415 | { |
| 416 | baud_rate = 110; |
| 417 | } |
| 418 | break; |
| 419 | |
| 420 | case 4: |
| 421 | { |
| 422 | baud_rate = 135; |
| 423 | } |
| 424 | break; |
| 425 | |
| 426 | case 5: |
| 427 | { |
| 428 | baud_rate = 150; |
| 429 | } |
| 430 | break; |
| 431 | |
| 432 | case 6: |
| 433 | { |
| 434 | baud_rate = 300; |
| 435 | } |
| 436 | break; |
| 437 | |
| 438 | case 7: |
| 439 | { |
| 440 | baud_rate = 600; |
| 441 | } |
| 442 | break; |
| 443 | |
| 444 | case 8: |
| 445 | { |
| 446 | baud_rate = 1200; |
| 447 | } |
| 448 | break; |
| 449 | |
| 450 | case 9: |
| 451 | { |
| 452 | baud_rate = 1800; |
| 453 | } |
| 454 | break; |
| 455 | |
| 456 | case 10: |
| 457 | { |
| 458 | baud_rate = 2400; |
| 459 | } |
| 460 | break; |
| 461 | |
| 462 | case 11: |
| 463 | { |
| 464 | baud_rate = 3600; |
| 465 | } |
| 466 | break; |
| 467 | |
| 468 | case 12: |
| 469 | { |
| 470 | baud_rate = 4800; |
| 471 | } |
| 472 | break; |
| 473 | |
| 474 | case 13: |
| 475 | { |
| 476 | baud_rate = 7200; |
| 477 | } |
| 478 | break; |
| 479 | |
| 480 | case 14: |
| 481 | { |
| 482 | baud_rate = 9600; |
| 483 | } |
| 484 | break; |
| 485 | |
| 486 | case 15: |
| 487 | { |
| 488 | baud_rate = 19200; |
| 489 | } |
| 490 | break; |
| 491 | } |
| 492 | |
| 493 | m_timer->adjust(attotime::zero, 0, attotime::from_hz(baud_rate)); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | m_control_register = data; |
| 498 | update_data_form(); |
| 499 | } |
| 500 | break; |
| 501 | |
| 502 | default: |
| 503 | break; |
| 504 | } |
| 505 | |
| 506 | } |
src/emu/machine/i8251.c
| r0 | r12779 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | i8251.c |
| 4 | |
| 5 | Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include "emu.h" |
| 10 | #include "i8251.h" |
| 11 | |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | MACROS |
| 15 | ***************************************************************************/ |
| 16 | |
| 17 | #define VERBOSE 0 |
| 18 | |
| 19 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | GLOBAL VARIABLES |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | const i8251_interface default_i8251_interface = { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; |
| 26 | |
| 27 | |
| 28 | /*************************************************************************** |
| 29 | IMPLEMENTATION |
| 30 | ***************************************************************************/ |
| 31 | |
| 32 | /*------------------------------------------------- |
| 33 | i8251_in_callback |
| 34 | -------------------------------------------------*/ |
| 35 | |
| 36 | void i8251_device::input_callback(UINT8 state) |
| 37 | { |
| 38 | int changed = m_input_state^state; |
| 39 | |
| 40 | m_input_state = state; |
| 41 | |
| 42 | /* did cts change state? */ |
| 43 | if (changed & SERIAL_STATE_CTS) |
| 44 | { |
| 45 | /* yes */ |
| 46 | /* update tx ready */ |
| 47 | /* update_tx_ready(); */ |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | //************************************************************************** |
| 52 | // DEVICE DEFINITIONS |
| 53 | //************************************************************************** |
| 54 | |
| 55 | const device_type I8251 = &device_creator<i8251_device>; |
| 56 | |
| 57 | //------------------------------------------------- |
| 58 | // i8251_device - constructor |
| 59 | //------------------------------------------------- |
| 60 | |
| 61 | i8251_device::i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 62 | : device_t(mconfig, I8251, "I8251", tag, owner, clock), |
| 63 | device_serial_interface(mconfig, *this) |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | //------------------------------------------------- |
| 68 | // device_config_complete - perform any |
| 69 | // operations now that the configuration is |
| 70 | // complete |
| 71 | //------------------------------------------------- |
| 72 | |
| 73 | void i8251_device::device_config_complete() |
| 74 | { |
| 75 | // inherit a copy of the static data |
| 76 | const i8251_interface *intf = reinterpret_cast<const i8251_interface *>(static_config()); |
| 77 | if (intf != NULL) |
| 78 | *static_cast<i8251_interface *>(this) = *intf; |
| 79 | |
| 80 | // or initialize to defaults if none provided |
| 81 | else |
| 82 | { |
| 83 | memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb)); |
| 84 | memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb)); |
| 85 | memset(&m_in_dsr_cb, 0, sizeof(m_in_dsr_cb)); |
| 86 | memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb)); |
| 87 | memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb)); |
| 88 | memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb)); |
| 89 | memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb)); |
| 90 | memset(&m_out_txempty_cb, 0, sizeof(m_out_txempty_cb)); |
| 91 | memset(&m_out_syndet_cb, 0, sizeof(m_out_syndet_cb)); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | //------------------------------------------------- |
| 96 | // device_start - device-specific startup |
| 97 | //------------------------------------------------- |
| 98 | |
| 99 | void i8251_device::device_start() |
| 100 | { |
| 101 | // resolve callbacks |
| 102 | m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this); |
| 103 | m_out_txrdy_func.resolve(m_out_txrdy_cb, *this); |
| 104 | m_out_txempty_func.resolve(m_out_txempty_cb, *this); |
| 105 | |
| 106 | m_input_state = 0; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | /*------------------------------------------------- |
| 113 | update_rx_ready |
| 114 | -------------------------------------------------*/ |
| 115 | |
| 116 | void i8251_device::update_rx_ready() |
| 117 | { |
| 118 | int state; |
| 119 | |
| 120 | state = m_status & I8251_STATUS_RX_READY; |
| 121 | |
| 122 | /* masked? */ |
| 123 | if ((m_command & (1<<2))==0) |
| 124 | { |
| 125 | state = 0; |
| 126 | } |
| 127 | |
| 128 | m_out_rxrdy_func(state != 0); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | |
| 133 | /*------------------------------------------------- |
| 134 | receive_clock |
| 135 | -------------------------------------------------*/ |
| 136 | |
| 137 | void i8251_device::receive_clock() |
| 138 | { |
| 139 | /* receive enable? */ |
| 140 | if (m_command & (1<<2)) |
| 141 | { |
| 142 | //logerror("I8251\n"); |
| 143 | /* get bit received from other side and update receive register */ |
| 144 | receive_register_update_bit(get_in_data_bit()); |
| 145 | |
| 146 | if (is_receive_register_full()) |
| 147 | { |
| 148 | receive_register_extract(); |
| 149 | receive_character(get_received_char()); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | |
| 155 | |
| 156 | /*------------------------------------------------- |
| 157 | transmit_clock |
| 158 | -------------------------------------------------*/ |
| 159 | |
| 160 | void i8251_device::transmit_clock() |
| 161 | { |
| 162 | /* transmit enable? */ |
| 163 | if (m_command & (1<<0)) |
| 164 | { |
| 165 | |
| 166 | /* transmit register full? */ |
| 167 | if ((m_status & I8251_STATUS_TX_READY)==0) |
| 168 | { |
| 169 | /* if transmit reg is empty */ |
| 170 | if (is_transmit_register_empty()) |
| 171 | { |
| 172 | /* set it up */ |
| 173 | transmit_register_setup(m_data); |
| 174 | /* i8251 transmit reg now empty */ |
| 175 | m_status |=I8251_STATUS_TX_EMPTY; |
| 176 | /* ready for next transmit */ |
| 177 | m_status |=I8251_STATUS_TX_READY; |
| 178 | |
| 179 | update_tx_empty(); |
| 180 | update_tx_ready(); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /* if transmit is not empty... transmit data */ |
| 185 | if (!is_transmit_register_empty()) |
| 186 | { |
| 187 | // logerror("I8251\n"); |
| 188 | transmit_register_send_bit(); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | #if 0 |
| 193 | /* hunt mode? */ |
| 194 | /* after each bit has been shifted in, it is compared against the current sync byte */ |
| 195 | if (m_command & (1<<7)) |
| 196 | { |
| 197 | /* data matches sync byte? */ |
| 198 | if (m_data == m_sync_bytes[m_sync_byte_offset]) |
| 199 | { |
| 200 | /* sync byte matches */ |
| 201 | /* update for next sync byte? */ |
| 202 | m_sync_byte_offset++; |
| 203 | |
| 204 | /* do all sync bytes match? */ |
| 205 | if (m_sync_byte_offset == m_sync_byte_count) |
| 206 | { |
| 207 | /* ent hunt mode */ |
| 208 | m_command &=~(1<<7); |
| 209 | } |
| 210 | } |
| 211 | else |
| 212 | { |
| 213 | /* if there is no match, reset */ |
| 214 | m_sync_byte_offset = 0; |
| 215 | } |
| 216 | } |
| 217 | #endif |
| 218 | } |
| 219 | |
| 220 | |
| 221 | |
| 222 | /*------------------------------------------------- |
| 223 | update_tx_ready |
| 224 | -------------------------------------------------*/ |
| 225 | |
| 226 | void i8251_device::update_tx_ready() |
| 227 | { |
| 228 | /* clear tx ready state */ |
| 229 | int tx_ready; |
| 230 | |
| 231 | /* tx ready output is set if: |
| 232 | DB Buffer Empty & |
| 233 | CTS is set & |
| 234 | Transmit enable is 1 |
| 235 | */ |
| 236 | |
| 237 | tx_ready = 0; |
| 238 | |
| 239 | /* transmit enable? */ |
| 240 | if ((m_command & (1<<0))!=0) |
| 241 | { |
| 242 | /* other side has rts set (comes in as CTS at this side) */ |
| 243 | if (m_input_state & SERIAL_STATE_CTS) |
| 244 | { |
| 245 | if (m_status & I8251_STATUS_TX_EMPTY) |
| 246 | { |
| 247 | /* enable transfer */ |
| 248 | tx_ready = 1; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | m_out_txrdy_func(tx_ready); |
| 254 | } |
| 255 | |
| 256 | |
| 257 | |
| 258 | /*------------------------------------------------- |
| 259 | update_tx_empty |
| 260 | -------------------------------------------------*/ |
| 261 | |
| 262 | void i8251_device::update_tx_empty() |
| 263 | { |
| 264 | if (m_status & I8251_STATUS_TX_EMPTY) |
| 265 | { |
| 266 | /* tx is in marking state (high) when tx empty! */ |
| 267 | set_out_data_bit(1); |
| 268 | serial_connection_out(); |
| 269 | } |
| 270 | |
| 271 | m_out_txempty_func((m_status & I8251_STATUS_TX_EMPTY) != 0); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | |
| 276 | //------------------------------------------------- |
| 277 | // device_reset - device-specific reset |
| 278 | //------------------------------------------------- |
| 279 | |
| 280 | void i8251_device::device_reset() |
| 281 | { |
| 282 | LOG(("I8251: Reset\n")); |
| 283 | |
| 284 | /* what is the default setup when the 8251 has been reset??? */ |
| 285 | |
| 286 | /* i8251 datasheet explains the state of tx pin at reset */ |
| 287 | /* tx is set to 1 */ |
| 288 | set_out_data_bit(1); |
| 289 | |
| 290 | /* assumption, rts is set to 1 */ |
| 291 | m_connection_state &= ~SERIAL_STATE_RTS; |
| 292 | serial_connection_out(); |
| 293 | |
| 294 | transmit_register_reset(); |
| 295 | receive_register_reset(); |
| 296 | /* expecting mode byte */ |
| 297 | m_flags |= I8251_EXPECTING_MODE; |
| 298 | /* not expecting a sync byte */ |
| 299 | m_flags &= ~I8251_EXPECTING_SYNC_BYTE; |
| 300 | |
| 301 | /* no character to read by cpu */ |
| 302 | /* transmitter is ready and is empty */ |
| 303 | m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 304 | m_mode_byte = 0; |
| 305 | m_command = 0; |
| 306 | |
| 307 | /* update tx empty pin output */ |
| 308 | update_tx_empty(); |
| 309 | /* update rx ready pin output */ |
| 310 | update_rx_ready(); |
| 311 | /* update tx ready pin output */ |
| 312 | update_tx_ready(); |
| 313 | } |
| 314 | |
| 315 | |
| 316 | |
| 317 | /*------------------------------------------------- |
| 318 | control_w |
| 319 | -------------------------------------------------*/ |
| 320 | |
| 321 | WRITE8_MEMBER(i8251_device::control_w) |
| 322 | { |
| 323 | if (m_flags & I8251_EXPECTING_MODE) |
| 324 | { |
| 325 | if (m_flags & I8251_EXPECTING_SYNC_BYTE) |
| 326 | { |
| 327 | LOG(("I8251: Sync byte\n")); |
| 328 | |
| 329 | LOG(("Sync byte: %02x\n", data)); |
| 330 | /* store sync byte written */ |
| 331 | m_sync_bytes[m_sync_byte_offset] = data; |
| 332 | m_sync_byte_offset++; |
| 333 | |
| 334 | if (m_sync_byte_offset == m_sync_byte_count) |
| 335 | { |
| 336 | /* finished transfering sync bytes, now expecting command */ |
| 337 | m_flags &= ~(I8251_EXPECTING_MODE | I8251_EXPECTING_SYNC_BYTE); |
| 338 | m_sync_byte_offset = 0; |
| 339 | // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 340 | } |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | LOG(("I8251: Mode byte\n")); |
| 345 | |
| 346 | m_mode_byte = data; |
| 347 | |
| 348 | /* Synchronous or Asynchronous? */ |
| 349 | if ((data & 0x03)!=0) |
| 350 | { |
| 351 | /* Asynchronous |
| 352 | |
| 353 | bit 7,6: stop bit length |
| 354 | 0 = inhibit |
| 355 | 1 = 1 bit |
| 356 | 2 = 1.5 bits |
| 357 | 3 = 2 bits |
| 358 | bit 5: parity type |
| 359 | 0 = parity odd |
| 360 | 1 = parity even |
| 361 | bit 4: parity test enable |
| 362 | 0 = disable |
| 363 | 1 = enable |
| 364 | bit 3,2: character length |
| 365 | 0 = 5 bits |
| 366 | 1 = 6 bits |
| 367 | 2 = 7 bits |
| 368 | 3 = 8 bits |
| 369 | bit 1,0: baud rate factor |
| 370 | 0 = defines command byte for synchronous or asynchronous |
| 371 | 1 = x1 |
| 372 | 2 = x16 |
| 373 | 3 = x64 |
| 374 | */ |
| 375 | |
| 376 | LOG(("I8251: Asynchronous operation\n")); |
| 377 | |
| 378 | LOG(("Character length: %d\n", (((data>>2) & 0x03)+5))); |
| 379 | |
| 380 | if (data & (1<<4)) |
| 381 | { |
| 382 | LOG(("enable parity checking\n")); |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | LOG(("parity check disabled\n")); |
| 387 | } |
| 388 | |
| 389 | if (data & (1<<5)) |
| 390 | { |
| 391 | LOG(("even parity\n")); |
| 392 | } |
| 393 | else |
| 394 | { |
| 395 | LOG(("odd parity\n")); |
| 396 | } |
| 397 | |
| 398 | { |
| 399 | UINT8 stop_bit_length; |
| 400 | |
| 401 | stop_bit_length = (data>>6) & 0x03; |
| 402 | |
| 403 | switch (stop_bit_length) |
| 404 | { |
| 405 | case 0: |
| 406 | { |
| 407 | /* inhibit */ |
| 408 | LOG(("stop bit: inhibit\n")); |
| 409 | } |
| 410 | break; |
| 411 | |
| 412 | case 1: |
| 413 | { |
| 414 | /* 1 */ |
| 415 | LOG(("stop bit: 1 bit\n")); |
| 416 | } |
| 417 | break; |
| 418 | |
| 419 | case 2: |
| 420 | { |
| 421 | /* 1.5 */ |
| 422 | LOG(("stop bit: 1.5 bits\n")); |
| 423 | } |
| 424 | break; |
| 425 | |
| 426 | case 3: |
| 427 | { |
| 428 | /* 2 */ |
| 429 | LOG(("stop bit: 2 bits\n")); |
| 430 | } |
| 431 | break; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | int word_length = ((data>>2) & 0x03)+5; |
| 436 | int parity = SERIAL_PARITY_NONE; |
| 437 | int stop_bit_count = 1; |
| 438 | switch ((data>>6) & 0x03) |
| 439 | { |
| 440 | case 0: |
| 441 | case 1: |
| 442 | stop_bit_count = 1; |
| 443 | break; |
| 444 | case 2: |
| 445 | case 3: |
| 446 | stop_bit_count = 2; |
| 447 | break; |
| 448 | } |
| 449 | set_data_frame(word_length,stop_bit_count,parity); |
| 450 | |
| 451 | #if 0 |
| 452 | /* data bits */ |
| 453 | m_receive_char_length = (((data>>2) & 0x03)+5); |
| 454 | |
| 455 | if (data & (1<<4)) |
| 456 | { |
| 457 | /* parity */ |
| 458 | m_receive_char_length++; |
| 459 | } |
| 460 | |
| 461 | /* stop bits */ |
| 462 | m_receive_char_length++; |
| 463 | |
| 464 | m_receive_flags &=~I8251_TRANSFER_RECEIVE_SYNCHRONISED; |
| 465 | m_receive_flags |= I8251_TRANSFER_RECEIVE_WAITING_FOR_START_BIT; |
| 466 | #endif |
| 467 | /* not expecting mode byte now */ |
| 468 | m_flags &= ~I8251_EXPECTING_MODE; |
| 469 | // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | /* bit 7: Number of sync characters |
| 474 | 0 = 1 character |
| 475 | 1 = 2 character |
| 476 | bit 6: Synchronous mode |
| 477 | 0 = Internal synchronisation |
| 478 | 1 = External synchronisation |
| 479 | bit 5: parity type |
| 480 | 0 = parity odd |
| 481 | 1 = parity even |
| 482 | bit 4: parity test enable |
| 483 | 0 = disable |
| 484 | 1 = enable |
| 485 | bit 3,2: character length |
| 486 | 0 = 5 bits |
| 487 | 1 = 6 bits |
| 488 | 2 = 7 bits |
| 489 | 3 = 8 bits |
| 490 | bit 1,0 = 0 |
| 491 | */ |
| 492 | LOG(("I8251: Synchronous operation\n")); |
| 493 | |
| 494 | /* setup for sync byte(s) */ |
| 495 | m_flags |= I8251_EXPECTING_SYNC_BYTE; |
| 496 | m_sync_byte_offset = 0; |
| 497 | if (data & 0x07) |
| 498 | { |
| 499 | m_sync_byte_count = 1; |
| 500 | } |
| 501 | else |
| 502 | { |
| 503 | m_sync_byte_count = 2; |
| 504 | } |
| 505 | |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | /* command */ |
| 512 | LOG(("I8251: Command byte\n")); |
| 513 | |
| 514 | m_command = data; |
| 515 | |
| 516 | LOG(("Command byte: %02x\n", data)); |
| 517 | |
| 518 | if (data & (1<<7)) |
| 519 | { |
| 520 | LOG(("hunt mode\n")); |
| 521 | } |
| 522 | |
| 523 | if (data & (1<<5)) |
| 524 | { |
| 525 | LOG(("/rts set to 0\n")); |
| 526 | } |
| 527 | else |
| 528 | { |
| 529 | LOG(("/rts set to 1\n")); |
| 530 | } |
| 531 | |
| 532 | if (data & (1<<2)) |
| 533 | { |
| 534 | LOG(("receive enable\n")); |
| 535 | } |
| 536 | else |
| 537 | { |
| 538 | LOG(("receive disable\n")); |
| 539 | } |
| 540 | |
| 541 | if (data & (1<<1)) |
| 542 | { |
| 543 | LOG(("/dtr set to 0\n")); |
| 544 | } |
| 545 | else |
| 546 | { |
| 547 | LOG(("/dtr set to 1\n")); |
| 548 | } |
| 549 | |
| 550 | if (data & (1<<0)) |
| 551 | { |
| 552 | LOG(("transmit enable\n")); |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | LOG(("transmit disable\n")); |
| 557 | } |
| 558 | |
| 559 | |
| 560 | /* bit 7: |
| 561 | 0 = normal operation |
| 562 | 1 = hunt mode |
| 563 | bit 6: |
| 564 | 0 = normal operation |
| 565 | 1 = internal reset |
| 566 | bit 5: |
| 567 | 0 = /RTS set to 1 |
| 568 | 1 = /RTS set to 0 |
| 569 | bit 4: |
| 570 | 0 = normal operation |
| 571 | 1 = reset error flag |
| 572 | bit 3: |
| 573 | 0 = normal operation |
| 574 | 1 = send break character |
| 575 | bit 2: |
| 576 | 0 = receive disable |
| 577 | 1 = receive enable |
| 578 | bit 1: |
| 579 | 0 = /DTR set to 1 |
| 580 | 1 = /DTR set to 0 |
| 581 | bit 0: |
| 582 | 0 = transmit disable |
| 583 | 1 = transmit enable |
| 584 | */ |
| 585 | |
| 586 | m_connection_state &=~SERIAL_STATE_RTS; |
| 587 | if (data & (1<<5)) |
| 588 | { |
| 589 | /* rts set to 0 */ |
| 590 | m_connection_state |= SERIAL_STATE_RTS; |
| 591 | } |
| 592 | |
| 593 | m_connection_state &=~SERIAL_STATE_DTR; |
| 594 | if (data & (1<<1)) |
| 595 | { |
| 596 | m_connection_state |= SERIAL_STATE_DTR; |
| 597 | } |
| 598 | |
| 599 | if ((data & (1<<0))==0) |
| 600 | { |
| 601 | /* held in high state when transmit disable */ |
| 602 | set_out_data_bit(1); |
| 603 | } |
| 604 | |
| 605 | |
| 606 | /* refresh outputs */ |
| 607 | serial_connection_out(); |
| 608 | |
| 609 | if (data & (1<<4)) |
| 610 | { |
| 611 | m_status &= ~(I8251_STATUS_PARITY_ERROR | I8251_STATUS_OVERRUN_ERROR | I8251_STATUS_FRAMING_ERROR); |
| 612 | } |
| 613 | |
| 614 | if (data & (1<<6)) |
| 615 | { |
| 616 | reset(); |
| 617 | } |
| 618 | |
| 619 | update_rx_ready(); |
| 620 | update_tx_ready(); |
| 621 | |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | |
| 626 | |
| 627 | /*------------------------------------------------- |
| 628 | status_r |
| 629 | -------------------------------------------------*/ |
| 630 | |
| 631 | READ8_MEMBER(i8251_device::status_r) |
| 632 | { |
| 633 | LOG(("status: %02x\n", m_status)); |
| 634 | return m_status; |
| 635 | } |
| 636 | |
| 637 | |
| 638 | |
| 639 | /*------------------------------------------------- |
| 640 | data_w |
| 641 | -------------------------------------------------*/ |
| 642 | |
| 643 | WRITE8_MEMBER(i8251_device::data_w) |
| 644 | { |
| 645 | m_data = data; |
| 646 | |
| 647 | logerror("write data: %02x\n",data); |
| 648 | |
| 649 | /* writing clears */ |
| 650 | m_status &=~I8251_STATUS_TX_READY; |
| 651 | |
| 652 | /* if transmitter is active, then tx empty will be signalled */ |
| 653 | |
| 654 | update_tx_ready(); |
| 655 | } |
| 656 | |
| 657 | |
| 658 | |
| 659 | /*------------------------------------------------- |
| 660 | receive_character - called when last |
| 661 | bit of data has been received |
| 662 | -------------------------------------------------*/ |
| 663 | |
| 664 | void i8251_device::receive_character(UINT8 ch) |
| 665 | { |
| 666 | logerror("i8251 receive char: %02x\n",ch); |
| 667 | |
| 668 | m_data = ch; |
| 669 | |
| 670 | /* char has not been read and another has arrived! */ |
| 671 | if (m_status & I8251_STATUS_RX_READY) |
| 672 | { |
| 673 | m_status |= I8251_STATUS_OVERRUN_ERROR; |
| 674 | } |
| 675 | m_status |= I8251_STATUS_RX_READY; |
| 676 | |
| 677 | update_rx_ready(); |
| 678 | } |
| 679 | |
| 680 | |
| 681 | |
| 682 | /*------------------------------------------------- |
| 683 | data_r - read data |
| 684 | -------------------------------------------------*/ |
| 685 | |
| 686 | READ8_MEMBER(i8251_device::data_r) |
| 687 | { |
| 688 | logerror("read data: %02x, STATUS=%02x\n",m_data,m_status); |
| 689 | /* reading clears */ |
| 690 | m_status &= ~I8251_STATUS_RX_READY; |
| 691 | |
| 692 | update_rx_ready(); |
| 693 | return m_data; |
| 694 | } |
src/emu/machine/i8251.h
| r0 | r12779 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | i8251.h |
| 4 | |
| 5 | Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef __I8251_H__ |
| 10 | #define __I8251_H__ |
| 11 | |
| 12 | |
| 13 | /*************************************************************************** |
| 14 | CONSTANTS |
| 15 | ***************************************************************************/ |
| 16 | |
| 17 | #define I8251_EXPECTING_MODE 0x01 |
| 18 | #define I8251_EXPECTING_SYNC_BYTE 0x02 |
| 19 | |
| 20 | #define I8251_STATUS_FRAMING_ERROR 0x20 |
| 21 | #define I8251_STATUS_OVERRUN_ERROR 0x10 |
| 22 | #define I8251_STATUS_PARITY_ERROR 0x08 |
| 23 | #define I8251_STATUS_TX_EMPTY 0x04 |
| 24 | #define I8251_STATUS_RX_READY 0x02 |
| 25 | #define I8251_STATUS_TX_READY 0x01 |
| 26 | |
| 27 | //************************************************************************** |
| 28 | // INTERFACE CONFIGURATION MACROS |
| 29 | //************************************************************************** |
| 30 | |
| 31 | #define MCFG_I8251_ADD(_tag, _intrf) \ |
| 32 | MCFG_DEVICE_ADD(_tag, I8251, 0) \ |
| 33 | MCFG_DEVICE_CONFIG(_intrf) |
| 34 | |
| 35 | #define MCFG_I8251_REMOVE(_tag) \ |
| 36 | MCFG_DEVICE_REMOVE(_tag) |
| 37 | |
| 38 | |
| 39 | /*************************************************************************** |
| 40 | TYPE DEFINITIONS |
| 41 | ***************************************************************************/ |
| 42 | // ======================> i8251_interface |
| 43 | |
| 44 | struct i8251_interface |
| 45 | { |
| 46 | devcb_read_line m_in_rxd_cb; |
| 47 | devcb_write_line m_out_txd_cb; |
| 48 | devcb_read_line m_in_dsr_cb; |
| 49 | devcb_write_line m_out_dtr_cb; |
| 50 | devcb_write_line m_out_rts_cb; |
| 51 | devcb_write_line m_out_rxrdy_cb; |
| 52 | devcb_write_line m_out_txrdy_cb; |
| 53 | devcb_write_line m_out_txempty_cb; |
| 54 | devcb_write_line m_out_syndet_cb; |
| 55 | }; |
| 56 | |
| 57 | // ======================> i8251_device |
| 58 | |
| 59 | class i8251_device : public device_t, |
| 60 | public device_serial_interface, |
| 61 | public i8251_interface |
| 62 | { |
| 63 | public: |
| 64 | // construction/destruction |
| 65 | i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 66 | |
| 67 | /* read data register */ |
| 68 | DECLARE_READ8_MEMBER(data_r); |
| 69 | |
| 70 | /* read status register */ |
| 71 | DECLARE_READ8_MEMBER(status_r); |
| 72 | |
| 73 | /* write data register */ |
| 74 | DECLARE_WRITE8_MEMBER(data_w); |
| 75 | |
| 76 | /* write control word */ |
| 77 | DECLARE_WRITE8_MEMBER(control_w); |
| 78 | |
| 79 | /* The 8251 has seperate transmit and receive clocks */ |
| 80 | /* use these two functions to update the i8251 for each clock */ |
| 81 | /* on NC100 system, the clocks are the same */ |
| 82 | void transmit_clock(); |
| 83 | void receive_clock(); |
| 84 | |
| 85 | void receive_character(UINT8 ch); |
| 86 | |
| 87 | virtual void input_callback(UINT8 state); |
| 88 | protected: |
| 89 | // device-level overrides |
| 90 | virtual void device_start(); |
| 91 | virtual void device_config_complete(); |
| 92 | virtual void device_reset(); |
| 93 | |
| 94 | void update_rx_ready(); |
| 95 | void update_tx_ready(); |
| 96 | void update_tx_empty(); |
| 97 | private: |
| 98 | devcb_resolved_read_line m_in_rxd_func; |
| 99 | devcb_resolved_write_line m_out_txd_func; |
| 100 | devcb_resolved_read_line m_in_dsr_func; |
| 101 | devcb_resolved_write_line m_out_dtr_func; |
| 102 | devcb_resolved_write_line m_out_rts_func; |
| 103 | devcb_resolved_write_line m_out_rxrdy_func; |
| 104 | devcb_resolved_write_line m_out_txrdy_func; |
| 105 | devcb_resolved_write_line m_out_txempty_func; |
| 106 | devcb_resolved_write_line m_out_syndet_func; |
| 107 | |
| 108 | /* flags controlling how i8251_control_w operates */ |
| 109 | UINT8 m_flags; |
| 110 | /* offset into sync_bytes used during sync byte transfer */ |
| 111 | UINT8 m_sync_byte_offset; |
| 112 | /* number of sync bytes written so far */ |
| 113 | UINT8 m_sync_byte_count; |
| 114 | /* the sync bytes written */ |
| 115 | UINT8 m_sync_bytes[2]; |
| 116 | /* status of i8251 */ |
| 117 | UINT8 m_status; |
| 118 | UINT8 m_command; |
| 119 | /* mode byte - bit definitions depend on mode - e.g. synchronous, asynchronous */ |
| 120 | UINT8 m_mode_byte; |
| 121 | |
| 122 | /* data being received */ |
| 123 | UINT8 m_data; |
| 124 | }; |
| 125 | |
| 126 | // device type definition |
| 127 | extern const device_type I8251; |
| 128 | |
| 129 | extern const i8251_interface default_i8251_interface; |
| 130 | |
| 131 | #endif /* __I8251_H__ */ |
src/mess/machine/i8251.c
| r12778 | r12779 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | i8251.c |
| 4 | | |
| 5 | | Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code |
| 6 | | |
| 7 | | *********************************************************************/ |
| 8 | | |
| 9 | | #include "emu.h" |
| 10 | | #include "i8251.h" |
| 11 | | |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | MACROS |
| 15 | | ***************************************************************************/ |
| 16 | | |
| 17 | | #define VERBOSE 0 |
| 18 | | |
| 19 | | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 20 | | |
| 21 | | /*************************************************************************** |
| 22 | | GLOBAL VARIABLES |
| 23 | | ***************************************************************************/ |
| 24 | | |
| 25 | | const i8251_interface default_i8251_interface = { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; |
| 26 | | |
| 27 | | |
| 28 | | /*************************************************************************** |
| 29 | | IMPLEMENTATION |
| 30 | | ***************************************************************************/ |
| 31 | | |
| 32 | | /*------------------------------------------------- |
| 33 | | i8251_in_callback |
| 34 | | -------------------------------------------------*/ |
| 35 | | |
| 36 | | void i8251_device::input_callback(UINT8 state) |
| 37 | | { |
| 38 | | int changed = m_input_state^state; |
| 39 | | |
| 40 | | m_input_state = state; |
| 41 | | |
| 42 | | /* did cts change state? */ |
| 43 | | if (changed & SERIAL_STATE_CTS) |
| 44 | | { |
| 45 | | /* yes */ |
| 46 | | /* update tx ready */ |
| 47 | | /* update_tx_ready(); */ |
| 48 | | } |
| 49 | | } |
| 50 | | |
| 51 | | //************************************************************************** |
| 52 | | // DEVICE DEFINITIONS |
| 53 | | //************************************************************************** |
| 54 | | |
| 55 | | const device_type I8251 = &device_creator<i8251_device>; |
| 56 | | |
| 57 | | //------------------------------------------------- |
| 58 | | // i8251_device - constructor |
| 59 | | //------------------------------------------------- |
| 60 | | |
| 61 | | i8251_device::i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 62 | | : device_t(mconfig, I8251, "I8251", tag, owner, clock), |
| 63 | | device_serial_interface(mconfig, *this) |
| 64 | | { |
| 65 | | } |
| 66 | | |
| 67 | | //------------------------------------------------- |
| 68 | | // device_config_complete - perform any |
| 69 | | // operations now that the configuration is |
| 70 | | // complete |
| 71 | | //------------------------------------------------- |
| 72 | | |
| 73 | | void i8251_device::device_config_complete() |
| 74 | | { |
| 75 | | // inherit a copy of the static data |
| 76 | | const i8251_interface *intf = reinterpret_cast<const i8251_interface *>(static_config()); |
| 77 | | if (intf != NULL) |
| 78 | | *static_cast<i8251_interface *>(this) = *intf; |
| 79 | | |
| 80 | | // or initialize to defaults if none provided |
| 81 | | else |
| 82 | | { |
| 83 | | memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb)); |
| 84 | | memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb)); |
| 85 | | memset(&m_in_dsr_cb, 0, sizeof(m_in_dsr_cb)); |
| 86 | | memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb)); |
| 87 | | memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb)); |
| 88 | | memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb)); |
| 89 | | memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb)); |
| 90 | | memset(&m_out_txempty_cb, 0, sizeof(m_out_txempty_cb)); |
| 91 | | memset(&m_out_syndet_cb, 0, sizeof(m_out_syndet_cb)); |
| 92 | | } |
| 93 | | } |
| 94 | | |
| 95 | | //------------------------------------------------- |
| 96 | | // device_start - device-specific startup |
| 97 | | //------------------------------------------------- |
| 98 | | |
| 99 | | void i8251_device::device_start() |
| 100 | | { |
| 101 | | // resolve callbacks |
| 102 | | m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this); |
| 103 | | m_out_txrdy_func.resolve(m_out_txrdy_cb, *this); |
| 104 | | m_out_txempty_func.resolve(m_out_txempty_cb, *this); |
| 105 | | |
| 106 | | m_input_state = 0; |
| 107 | | } |
| 108 | | |
| 109 | | |
| 110 | | |
| 111 | | |
| 112 | | /*------------------------------------------------- |
| 113 | | update_rx_ready |
| 114 | | -------------------------------------------------*/ |
| 115 | | |
| 116 | | void i8251_device::update_rx_ready() |
| 117 | | { |
| 118 | | int state; |
| 119 | | |
| 120 | | state = m_status & I8251_STATUS_RX_READY; |
| 121 | | |
| 122 | | /* masked? */ |
| 123 | | if ((m_command & (1<<2))==0) |
| 124 | | { |
| 125 | | state = 0; |
| 126 | | } |
| 127 | | |
| 128 | | m_out_rxrdy_func(state != 0); |
| 129 | | } |
| 130 | | |
| 131 | | |
| 132 | | |
| 133 | | /*------------------------------------------------- |
| 134 | | receive_clock |
| 135 | | -------------------------------------------------*/ |
| 136 | | |
| 137 | | void i8251_device::receive_clock() |
| 138 | | { |
| 139 | | /* receive enable? */ |
| 140 | | if (m_command & (1<<2)) |
| 141 | | { |
| 142 | | //logerror("I8251\n"); |
| 143 | | /* get bit received from other side and update receive register */ |
| 144 | | receive_register_update_bit(get_in_data_bit()); |
| 145 | | |
| 146 | | if (is_receive_register_full()) |
| 147 | | { |
| 148 | | receive_register_extract(); |
| 149 | | receive_character(get_received_char()); |
| 150 | | } |
| 151 | | } |
| 152 | | } |
| 153 | | |
| 154 | | |
| 155 | | |
| 156 | | /*------------------------------------------------- |
| 157 | | transmit_clock |
| 158 | | -------------------------------------------------*/ |
| 159 | | |
| 160 | | void i8251_device::transmit_clock() |
| 161 | | { |
| 162 | | /* transmit enable? */ |
| 163 | | if (m_command & (1<<0)) |
| 164 | | { |
| 165 | | |
| 166 | | /* transmit register full? */ |
| 167 | | if ((m_status & I8251_STATUS_TX_READY)==0) |
| 168 | | { |
| 169 | | /* if transmit reg is empty */ |
| 170 | | if (is_transmit_register_empty()) |
| 171 | | { |
| 172 | | /* set it up */ |
| 173 | | transmit_register_setup(m_data); |
| 174 | | /* i8251 transmit reg now empty */ |
| 175 | | m_status |=I8251_STATUS_TX_EMPTY; |
| 176 | | /* ready for next transmit */ |
| 177 | | m_status |=I8251_STATUS_TX_READY; |
| 178 | | |
| 179 | | update_tx_empty(); |
| 180 | | update_tx_ready(); |
| 181 | | } |
| 182 | | } |
| 183 | | |
| 184 | | /* if transmit is not empty... transmit data */ |
| 185 | | if (!is_transmit_register_empty()) |
| 186 | | { |
| 187 | | // logerror("I8251\n"); |
| 188 | | transmit_register_send_bit(); |
| 189 | | } |
| 190 | | } |
| 191 | | |
| 192 | | #if 0 |
| 193 | | /* hunt mode? */ |
| 194 | | /* after each bit has been shifted in, it is compared against the current sync byte */ |
| 195 | | if (m_command & (1<<7)) |
| 196 | | { |
| 197 | | /* data matches sync byte? */ |
| 198 | | if (m_data == m_sync_bytes[m_sync_byte_offset]) |
| 199 | | { |
| 200 | | /* sync byte matches */ |
| 201 | | /* update for next sync byte? */ |
| 202 | | m_sync_byte_offset++; |
| 203 | | |
| 204 | | /* do all sync bytes match? */ |
| 205 | | if (m_sync_byte_offset == m_sync_byte_count) |
| 206 | | { |
| 207 | | /* ent hunt mode */ |
| 208 | | m_command &=~(1<<7); |
| 209 | | } |
| 210 | | } |
| 211 | | else |
| 212 | | { |
| 213 | | /* if there is no match, reset */ |
| 214 | | m_sync_byte_offset = 0; |
| 215 | | } |
| 216 | | } |
| 217 | | #endif |
| 218 | | } |
| 219 | | |
| 220 | | |
| 221 | | |
| 222 | | /*------------------------------------------------- |
| 223 | | update_tx_ready |
| 224 | | -------------------------------------------------*/ |
| 225 | | |
| 226 | | void i8251_device::update_tx_ready() |
| 227 | | { |
| 228 | | /* clear tx ready state */ |
| 229 | | int tx_ready; |
| 230 | | |
| 231 | | /* tx ready output is set if: |
| 232 | | DB Buffer Empty & |
| 233 | | CTS is set & |
| 234 | | Transmit enable is 1 |
| 235 | | */ |
| 236 | | |
| 237 | | tx_ready = 0; |
| 238 | | |
| 239 | | /* transmit enable? */ |
| 240 | | if ((m_command & (1<<0))!=0) |
| 241 | | { |
| 242 | | /* other side has rts set (comes in as CTS at this side) */ |
| 243 | | if (m_input_state & SERIAL_STATE_CTS) |
| 244 | | { |
| 245 | | if (m_status & I8251_STATUS_TX_EMPTY) |
| 246 | | { |
| 247 | | /* enable transfer */ |
| 248 | | tx_ready = 1; |
| 249 | | } |
| 250 | | } |
| 251 | | } |
| 252 | | |
| 253 | | m_out_txrdy_func(tx_ready); |
| 254 | | } |
| 255 | | |
| 256 | | |
| 257 | | |
| 258 | | /*------------------------------------------------- |
| 259 | | update_tx_empty |
| 260 | | -------------------------------------------------*/ |
| 261 | | |
| 262 | | void i8251_device::update_tx_empty() |
| 263 | | { |
| 264 | | if (m_status & I8251_STATUS_TX_EMPTY) |
| 265 | | { |
| 266 | | /* tx is in marking state (high) when tx empty! */ |
| 267 | | set_out_data_bit(1); |
| 268 | | serial_connection_out(); |
| 269 | | } |
| 270 | | |
| 271 | | m_out_txempty_func((m_status & I8251_STATUS_TX_EMPTY) != 0); |
| 272 | | } |
| 273 | | |
| 274 | | |
| 275 | | |
| 276 | | //------------------------------------------------- |
| 277 | | // device_reset - device-specific reset |
| 278 | | //------------------------------------------------- |
| 279 | | |
| 280 | | void i8251_device::device_reset() |
| 281 | | { |
| 282 | | LOG(("I8251: Reset\n")); |
| 283 | | |
| 284 | | /* what is the default setup when the 8251 has been reset??? */ |
| 285 | | |
| 286 | | /* i8251 datasheet explains the state of tx pin at reset */ |
| 287 | | /* tx is set to 1 */ |
| 288 | | set_out_data_bit(1); |
| 289 | | |
| 290 | | /* assumption, rts is set to 1 */ |
| 291 | | m_connection_state &= ~SERIAL_STATE_RTS; |
| 292 | | serial_connection_out(); |
| 293 | | |
| 294 | | transmit_register_reset(); |
| 295 | | receive_register_reset(); |
| 296 | | /* expecting mode byte */ |
| 297 | | m_flags |= I8251_EXPECTING_MODE; |
| 298 | | /* not expecting a sync byte */ |
| 299 | | m_flags &= ~I8251_EXPECTING_SYNC_BYTE; |
| 300 | | |
| 301 | | /* no character to read by cpu */ |
| 302 | | /* transmitter is ready and is empty */ |
| 303 | | m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 304 | | m_mode_byte = 0; |
| 305 | | m_command = 0; |
| 306 | | |
| 307 | | /* update tx empty pin output */ |
| 308 | | update_tx_empty(); |
| 309 | | /* update rx ready pin output */ |
| 310 | | update_rx_ready(); |
| 311 | | /* update tx ready pin output */ |
| 312 | | update_tx_ready(); |
| 313 | | } |
| 314 | | |
| 315 | | |
| 316 | | |
| 317 | | /*------------------------------------------------- |
| 318 | | control_w |
| 319 | | -------------------------------------------------*/ |
| 320 | | |
| 321 | | WRITE8_MEMBER(i8251_device::control_w) |
| 322 | | { |
| 323 | | if (m_flags & I8251_EXPECTING_MODE) |
| 324 | | { |
| 325 | | if (m_flags & I8251_EXPECTING_SYNC_BYTE) |
| 326 | | { |
| 327 | | LOG(("I8251: Sync byte\n")); |
| 328 | | |
| 329 | | LOG(("Sync byte: %02x\n", data)); |
| 330 | | /* store sync byte written */ |
| 331 | | m_sync_bytes[m_sync_byte_offset] = data; |
| 332 | | m_sync_byte_offset++; |
| 333 | | |
| 334 | | if (m_sync_byte_offset == m_sync_byte_count) |
| 335 | | { |
| 336 | | /* finished transfering sync bytes, now expecting command */ |
| 337 | | m_flags &= ~(I8251_EXPECTING_MODE | I8251_EXPECTING_SYNC_BYTE); |
| 338 | | m_sync_byte_offset = 0; |
| 339 | | // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 340 | | } |
| 341 | | } |
| 342 | | else |
| 343 | | { |
| 344 | | LOG(("I8251: Mode byte\n")); |
| 345 | | |
| 346 | | m_mode_byte = data; |
| 347 | | |
| 348 | | /* Synchronous or Asynchronous? */ |
| 349 | | if ((data & 0x03)!=0) |
| 350 | | { |
| 351 | | /* Asynchronous |
| 352 | | |
| 353 | | bit 7,6: stop bit length |
| 354 | | 0 = inhibit |
| 355 | | 1 = 1 bit |
| 356 | | 2 = 1.5 bits |
| 357 | | 3 = 2 bits |
| 358 | | bit 5: parity type |
| 359 | | 0 = parity odd |
| 360 | | 1 = parity even |
| 361 | | bit 4: parity test enable |
| 362 | | 0 = disable |
| 363 | | 1 = enable |
| 364 | | bit 3,2: character length |
| 365 | | 0 = 5 bits |
| 366 | | 1 = 6 bits |
| 367 | | 2 = 7 bits |
| 368 | | 3 = 8 bits |
| 369 | | bit 1,0: baud rate factor |
| 370 | | 0 = defines command byte for synchronous or asynchronous |
| 371 | | 1 = x1 |
| 372 | | 2 = x16 |
| 373 | | 3 = x64 |
| 374 | | */ |
| 375 | | |
| 376 | | LOG(("I8251: Asynchronous operation\n")); |
| 377 | | |
| 378 | | LOG(("Character length: %d\n", (((data>>2) & 0x03)+5))); |
| 379 | | |
| 380 | | if (data & (1<<4)) |
| 381 | | { |
| 382 | | LOG(("enable parity checking\n")); |
| 383 | | } |
| 384 | | else |
| 385 | | { |
| 386 | | LOG(("parity check disabled\n")); |
| 387 | | } |
| 388 | | |
| 389 | | if (data & (1<<5)) |
| 390 | | { |
| 391 | | LOG(("even parity\n")); |
| 392 | | } |
| 393 | | else |
| 394 | | { |
| 395 | | LOG(("odd parity\n")); |
| 396 | | } |
| 397 | | |
| 398 | | { |
| 399 | | UINT8 stop_bit_length; |
| 400 | | |
| 401 | | stop_bit_length = (data>>6) & 0x03; |
| 402 | | |
| 403 | | switch (stop_bit_length) |
| 404 | | { |
| 405 | | case 0: |
| 406 | | { |
| 407 | | /* inhibit */ |
| 408 | | LOG(("stop bit: inhibit\n")); |
| 409 | | } |
| 410 | | break; |
| 411 | | |
| 412 | | case 1: |
| 413 | | { |
| 414 | | /* 1 */ |
| 415 | | LOG(("stop bit: 1 bit\n")); |
| 416 | | } |
| 417 | | break; |
| 418 | | |
| 419 | | case 2: |
| 420 | | { |
| 421 | | /* 1.5 */ |
| 422 | | LOG(("stop bit: 1.5 bits\n")); |
| 423 | | } |
| 424 | | break; |
| 425 | | |
| 426 | | case 3: |
| 427 | | { |
| 428 | | /* 2 */ |
| 429 | | LOG(("stop bit: 2 bits\n")); |
| 430 | | } |
| 431 | | break; |
| 432 | | } |
| 433 | | } |
| 434 | | |
| 435 | | int word_length = ((data>>2) & 0x03)+5; |
| 436 | | int parity = SERIAL_PARITY_NONE; |
| 437 | | int stop_bit_count = 1; |
| 438 | | switch ((data>>6) & 0x03) |
| 439 | | { |
| 440 | | case 0: |
| 441 | | case 1: |
| 442 | | stop_bit_count = 1; |
| 443 | | break; |
| 444 | | case 2: |
| 445 | | case 3: |
| 446 | | stop_bit_count = 2; |
| 447 | | break; |
| 448 | | } |
| 449 | | set_data_frame(word_length,stop_bit_count,parity); |
| 450 | | |
| 451 | | #if 0 |
| 452 | | /* data bits */ |
| 453 | | m_receive_char_length = (((data>>2) & 0x03)+5); |
| 454 | | |
| 455 | | if (data & (1<<4)) |
| 456 | | { |
| 457 | | /* parity */ |
| 458 | | m_receive_char_length++; |
| 459 | | } |
| 460 | | |
| 461 | | /* stop bits */ |
| 462 | | m_receive_char_length++; |
| 463 | | |
| 464 | | m_receive_flags &=~I8251_TRANSFER_RECEIVE_SYNCHRONISED; |
| 465 | | m_receive_flags |= I8251_TRANSFER_RECEIVE_WAITING_FOR_START_BIT; |
| 466 | | #endif |
| 467 | | /* not expecting mode byte now */ |
| 468 | | m_flags &= ~I8251_EXPECTING_MODE; |
| 469 | | // m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY; |
| 470 | | } |
| 471 | | else |
| 472 | | { |
| 473 | | /* bit 7: Number of sync characters |
| 474 | | 0 = 1 character |
| 475 | | 1 = 2 character |
| 476 | | bit 6: Synchronous mode |
| 477 | | 0 = Internal synchronisation |
| 478 | | 1 = External synchronisation |
| 479 | | bit 5: parity type |
| 480 | | 0 = parity odd |
| 481 | | 1 = parity even |
| 482 | | bit 4: parity test enable |
| 483 | | 0 = disable |
| 484 | | 1 = enable |
| 485 | | bit 3,2: character length |
| 486 | | 0 = 5 bits |
| 487 | | 1 = 6 bits |
| 488 | | 2 = 7 bits |
| 489 | | 3 = 8 bits |
| 490 | | bit 1,0 = 0 |
| 491 | | */ |
| 492 | | LOG(("I8251: Synchronous operation\n")); |
| 493 | | |
| 494 | | /* setup for sync byte(s) */ |
| 495 | | m_flags |= I8251_EXPECTING_SYNC_BYTE; |
| 496 | | m_sync_byte_offset = 0; |
| 497 | | if (data & 0x07) |
| 498 | | { |
| 499 | | m_sync_byte_count = 1; |
| 500 | | } |
| 501 | | else |
| 502 | | { |
| 503 | | m_sync_byte_count = 2; |
| 504 | | } |
| 505 | | |
| 506 | | } |
| 507 | | } |
| 508 | | } |
| 509 | | else |
| 510 | | { |
| 511 | | /* command */ |
| 512 | | LOG(("I8251: Command byte\n")); |
| 513 | | |
| 514 | | m_command = data; |
| 515 | | |
| 516 | | LOG(("Command byte: %02x\n", data)); |
| 517 | | |
| 518 | | if (data & (1<<7)) |
| 519 | | { |
| 520 | | LOG(("hunt mode\n")); |
| 521 | | } |
| 522 | | |
| 523 | | if (data & (1<<5)) |
| 524 | | { |
| 525 | | LOG(("/rts set to 0\n")); |
| 526 | | } |
| 527 | | else |
| 528 | | { |
| 529 | | LOG(("/rts set to 1\n")); |
| 530 | | } |
| 531 | | |
| 532 | | if (data & (1<<2)) |
| 533 | | { |
| 534 | | LOG(("receive enable\n")); |
| 535 | | } |
| 536 | | else |
| 537 | | { |
| 538 | | LOG(("receive disable\n")); |
| 539 | | } |
| 540 | | |
| 541 | | if (data & (1<<1)) |
| 542 | | { |
| 543 | | LOG(("/dtr set to 0\n")); |
| 544 | | } |
| 545 | | else |
| 546 | | { |
| 547 | | LOG(("/dtr set to 1\n")); |
| 548 | | } |
| 549 | | |
| 550 | | if (data & (1<<0)) |
| 551 | | { |
| 552 | | LOG(("transmit enable\n")); |
| 553 | | } |
| 554 | | else |
| 555 | | { |
| 556 | | LOG(("transmit disable\n")); |
| 557 | | } |
| 558 | | |
| 559 | | |
| 560 | | /* bit 7: |
| 561 | | 0 = normal operation |
| 562 | | 1 = hunt mode |
| 563 | | bit 6: |
| 564 | | 0 = normal operation |
| 565 | | 1 = internal reset |
| 566 | | bit 5: |
| 567 | | 0 = /RTS set to 1 |
| 568 | | 1 = /RTS set to 0 |
| 569 | | bit 4: |
| 570 | | 0 = normal operation |
| 571 | | 1 = reset error flag |
| 572 | | bit 3: |
| 573 | | 0 = normal operation |
| 574 | | 1 = send break character |
| 575 | | bit 2: |
| 576 | | 0 = receive disable |
| 577 | | 1 = receive enable |
| 578 | | bit 1: |
| 579 | | 0 = /DTR set to 1 |
| 580 | | 1 = /DTR set to 0 |
| 581 | | bit 0: |
| 582 | | 0 = transmit disable |
| 583 | | 1 = transmit enable |
| 584 | | */ |
| 585 | | |
| 586 | | m_connection_state &=~SERIAL_STATE_RTS; |
| 587 | | if (data & (1<<5)) |
| 588 | | { |
| 589 | | /* rts set to 0 */ |
| 590 | | m_connection_state |= SERIAL_STATE_RTS; |
| 591 | | } |
| 592 | | |
| 593 | | m_connection_state &=~SERIAL_STATE_DTR; |
| 594 | | if (data & (1<<1)) |
| 595 | | { |
| 596 | | m_connection_state |= SERIAL_STATE_DTR; |
| 597 | | } |
| 598 | | |
| 599 | | if ((data & (1<<0))==0) |
| 600 | | { |
| 601 | | /* held in high state when transmit disable */ |
| 602 | | set_out_data_bit(1); |
| 603 | | } |
| 604 | | |
| 605 | | |
| 606 | | /* refresh outputs */ |
| 607 | | serial_connection_out(); |
| 608 | | |
| 609 | | if (data & (1<<4)) |
| 610 | | { |
| 611 | | m_status &= ~(I8251_STATUS_PARITY_ERROR | I8251_STATUS_OVERRUN_ERROR | I8251_STATUS_FRAMING_ERROR); |
| 612 | | } |
| 613 | | |
| 614 | | if (data & (1<<6)) |
| 615 | | { |
| 616 | | reset(); |
| 617 | | } |
| 618 | | |
| 619 | | update_rx_ready(); |
| 620 | | update_tx_ready(); |
| 621 | | |
| 622 | | } |
| 623 | | } |
| 624 | | |
| 625 | | |
| 626 | | |
| 627 | | /*------------------------------------------------- |
| 628 | | status_r |
| 629 | | -------------------------------------------------*/ |
| 630 | | |
| 631 | | READ8_MEMBER(i8251_device::status_r) |
| 632 | | { |
| 633 | | LOG(("status: %02x\n", m_status)); |
| 634 | | return m_status; |
| 635 | | } |
| 636 | | |
| 637 | | |
| 638 | | |
| 639 | | /*------------------------------------------------- |
| 640 | | data_w |
| 641 | | -------------------------------------------------*/ |
| 642 | | |
| 643 | | WRITE8_MEMBER(i8251_device::data_w) |
| 644 | | { |
| 645 | | m_data = data; |
| 646 | | |
| 647 | | logerror("write data: %02x\n",data); |
| 648 | | |
| 649 | | /* writing clears */ |
| 650 | | m_status &=~I8251_STATUS_TX_READY; |
| 651 | | |
| 652 | | /* if transmitter is active, then tx empty will be signalled */ |
| 653 | | |
| 654 | | update_tx_ready(); |
| 655 | | } |
| 656 | | |
| 657 | | |
| 658 | | |
| 659 | | /*------------------------------------------------- |
| 660 | | receive_character - called when last |
| 661 | | bit of data has been received |
| 662 | | -------------------------------------------------*/ |
| 663 | | |
| 664 | | void i8251_device::receive_character(UINT8 ch) |
| 665 | | { |
| 666 | | logerror("i8251 receive char: %02x\n",ch); |
| 667 | | |
| 668 | | m_data = ch; |
| 669 | | |
| 670 | | /* char has not been read and another has arrived! */ |
| 671 | | if (m_status & I8251_STATUS_RX_READY) |
| 672 | | { |
| 673 | | m_status |= I8251_STATUS_OVERRUN_ERROR; |
| 674 | | } |
| 675 | | m_status |= I8251_STATUS_RX_READY; |
| 676 | | |
| 677 | | update_rx_ready(); |
| 678 | | } |
| 679 | | |
| 680 | | |
| 681 | | |
| 682 | | /*------------------------------------------------- |
| 683 | | data_r - read data |
| 684 | | -------------------------------------------------*/ |
| 685 | | |
| 686 | | READ8_MEMBER(i8251_device::data_r) |
| 687 | | { |
| 688 | | logerror("read data: %02x, STATUS=%02x\n",m_data,m_status); |
| 689 | | /* reading clears */ |
| 690 | | m_status &= ~I8251_STATUS_RX_READY; |
| 691 | | |
| 692 | | update_rx_ready(); |
| 693 | | return m_data; |
| 694 | | } |
src/mess/machine/i8251.h
| r12778 | r12779 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | i8251.h |
| 4 | | |
| 5 | | Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code |
| 6 | | |
| 7 | | *********************************************************************/ |
| 8 | | |
| 9 | | #ifndef __I8251_H__ |
| 10 | | #define __I8251_H__ |
| 11 | | |
| 12 | | |
| 13 | | /*************************************************************************** |
| 14 | | CONSTANTS |
| 15 | | ***************************************************************************/ |
| 16 | | |
| 17 | | #define I8251_EXPECTING_MODE 0x01 |
| 18 | | #define I8251_EXPECTING_SYNC_BYTE 0x02 |
| 19 | | |
| 20 | | #define I8251_STATUS_FRAMING_ERROR 0x20 |
| 21 | | #define I8251_STATUS_OVERRUN_ERROR 0x10 |
| 22 | | #define I8251_STATUS_PARITY_ERROR 0x08 |
| 23 | | #define I8251_STATUS_TX_EMPTY 0x04 |
| 24 | | #define I8251_STATUS_RX_READY 0x02 |
| 25 | | #define I8251_STATUS_TX_READY 0x01 |
| 26 | | |
| 27 | | //************************************************************************** |
| 28 | | // INTERFACE CONFIGURATION MACROS |
| 29 | | //************************************************************************** |
| 30 | | |
| 31 | | #define MCFG_I8251_ADD(_tag, _intrf) \ |
| 32 | | MCFG_DEVICE_ADD(_tag, I8251, 0) \ |
| 33 | | MCFG_DEVICE_CONFIG(_intrf) |
| 34 | | |
| 35 | | #define MCFG_I8251_REMOVE(_tag) \ |
| 36 | | MCFG_DEVICE_REMOVE(_tag) |
| 37 | | |
| 38 | | |
| 39 | | /*************************************************************************** |
| 40 | | TYPE DEFINITIONS |
| 41 | | ***************************************************************************/ |
| 42 | | // ======================> i8251_interface |
| 43 | | |
| 44 | | struct i8251_interface |
| 45 | | { |
| 46 | | devcb_read_line m_in_rxd_cb; |
| 47 | | devcb_write_line m_out_txd_cb; |
| 48 | | devcb_read_line m_in_dsr_cb; |
| 49 | | devcb_write_line m_out_dtr_cb; |
| 50 | | devcb_write_line m_out_rts_cb; |
| 51 | | devcb_write_line m_out_rxrdy_cb; |
| 52 | | devcb_write_line m_out_txrdy_cb; |
| 53 | | devcb_write_line m_out_txempty_cb; |
| 54 | | devcb_write_line m_out_syndet_cb; |
| 55 | | }; |
| 56 | | |
| 57 | | // ======================> i8251_device |
| 58 | | |
| 59 | | class i8251_device : public device_t, |
| 60 | | public device_serial_interface, |
| 61 | | public i8251_interface |
| 62 | | { |
| 63 | | public: |
| 64 | | // construction/destruction |
| 65 | | i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 66 | | |
| 67 | | /* read data register */ |
| 68 | | DECLARE_READ8_MEMBER(data_r); |
| 69 | | |
| 70 | | /* read status register */ |
| 71 | | DECLARE_READ8_MEMBER(status_r); |
| 72 | | |
| 73 | | /* write data register */ |
| 74 | | DECLARE_WRITE8_MEMBER(data_w); |
| 75 | | |
| 76 | | /* write control word */ |
| 77 | | DECLARE_WRITE8_MEMBER(control_w); |
| 78 | | |
| 79 | | /* The 8251 has seperate transmit and receive clocks */ |
| 80 | | /* use these two functions to update the i8251 for each clock */ |
| 81 | | /* on NC100 system, the clocks are the same */ |
| 82 | | void transmit_clock(); |
| 83 | | void receive_clock(); |
| 84 | | |
| 85 | | void receive_character(UINT8 ch); |
| 86 | | |
| 87 | | virtual void input_callback(UINT8 state); |
| 88 | | protected: |
| 89 | | // device-level overrides |
| 90 | | virtual void device_start(); |
| 91 | | virtual void device_config_complete(); |
| 92 | | virtual void device_reset(); |
| 93 | | |
| 94 | | void update_rx_ready(); |
| 95 | | void update_tx_ready(); |
| 96 | | void update_tx_empty(); |
| 97 | | private: |
| 98 | | devcb_resolved_read_line m_in_rxd_func; |
| 99 | | devcb_resolved_write_line m_out_txd_func; |
| 100 | | devcb_resolved_read_line m_in_dsr_func; |
| 101 | | devcb_resolved_write_line m_out_dtr_func; |
| 102 | | devcb_resolved_write_line m_out_rts_func; |
| 103 | | devcb_resolved_write_line m_out_rxrdy_func; |
| 104 | | devcb_resolved_write_line m_out_txrdy_func; |
| 105 | | devcb_resolved_write_line m_out_txempty_func; |
| 106 | | devcb_resolved_write_line m_out_syndet_func; |
| 107 | | |
| 108 | | /* flags controlling how i8251_control_w operates */ |
| 109 | | UINT8 m_flags; |
| 110 | | /* offset into sync_bytes used during sync byte transfer */ |
| 111 | | UINT8 m_sync_byte_offset; |
| 112 | | /* number of sync bytes written so far */ |
| 113 | | UINT8 m_sync_byte_count; |
| 114 | | /* the sync bytes written */ |
| 115 | | UINT8 m_sync_bytes[2]; |
| 116 | | /* status of i8251 */ |
| 117 | | UINT8 m_status; |
| 118 | | UINT8 m_command; |
| 119 | | /* mode byte - bit definitions depend on mode - e.g. synchronous, asynchronous */ |
| 120 | | UINT8 m_mode_byte; |
| 121 | | |
| 122 | | /* data being received */ |
| 123 | | UINT8 m_data; |
| 124 | | }; |
| 125 | | |
| 126 | | // device type definition |
| 127 | | extern const device_type I8251; |
| 128 | | |
| 129 | | extern const i8251_interface default_i8251_interface; |
| 130 | | |
| 131 | | #endif /* __I8251_H__ */ |
src/mess/machine/6551.c
| r12778 | r12779 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | 6551.h |
| 4 | | |
| 5 | | MOS Technology 6551 Asynchronous Communications Interface Adapter |
| 6 | | |
| 7 | | A1 A0 Write Read |
| 8 | | 0 0 Transmit Data Register Receiver Data Register |
| 9 | | 0 1 Programmed Reset Status Register |
| 10 | | 1 0 Command Register |
| 11 | | 1 1 Control Register |
| 12 | | |
| 13 | | *********************************************************************/ |
| 14 | | |
| 15 | | #include "emu.h" |
| 16 | | #include "6551.h" |
| 17 | | |
| 18 | | |
| 19 | | //************************************************************************** |
| 20 | | // DEVICE DEFINITIONS |
| 21 | | //************************************************************************** |
| 22 | | |
| 23 | | const device_type ACIA6551 = &device_creator<acia6551_device>; |
| 24 | | |
| 25 | | //------------------------------------------------- |
| 26 | | // acia6551_device - constructor |
| 27 | | //------------------------------------------------- |
| 28 | | |
| 29 | | acia6551_device::acia6551_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 30 | | : device_t(mconfig, ACIA6551, "MOS Technology 6551 ACIA", tag, owner, clock), |
| 31 | | device_serial_interface(mconfig, *this) |
| 32 | | { |
| 33 | | } |
| 34 | | |
| 35 | | /*************************************************************************** |
| 36 | | IMPLEMENTATION |
| 37 | | ***************************************************************************/ |
| 38 | | |
| 39 | | /*------------------------------------------------- |
| 40 | | input_callback - called when other side |
| 41 | | has updated state |
| 42 | | -------------------------------------------------*/ |
| 43 | | void acia6551_device::input_callback(UINT8 state) |
| 44 | | { |
| 45 | | m_input_state = state; |
| 46 | | } |
| 47 | | |
| 48 | | /*------------------------------------------------- |
| 49 | | timer_callback |
| 50 | | -------------------------------------------------*/ |
| 51 | | void acia6551_device::timer_callback() |
| 52 | | { |
| 53 | | /* get bit received from other side and update receive register */ |
| 54 | | receive_register_update_bit(get_in_data_bit()); |
| 55 | | |
| 56 | | if (is_receive_register_full()) |
| 57 | | { |
| 58 | | receive_register_extract(); |
| 59 | | receive_character(get_received_char()); |
| 60 | | } |
| 61 | | |
| 62 | | /* transmit register full? */ |
| 63 | | if ((m_status_register & (1<<4))==0) |
| 64 | | { |
| 65 | | /* if transmit reg is empty */ |
| 66 | | if (is_transmit_register_empty()) |
| 67 | | { |
| 68 | | /* set it up */ |
| 69 | | transmit_register_setup(m_transmit_data_register); |
| 70 | | /* acia transmit reg now empty */ |
| 71 | | m_status_register |=(1<<4); |
| 72 | | /* and refresh ints */ |
| 73 | | refresh_ints(); |
| 74 | | } |
| 75 | | } |
| 76 | | |
| 77 | | /* if transmit is not empty... transmit data */ |
| 78 | | if (!is_transmit_register_empty()) |
| 79 | | { |
| 80 | | // logerror("UART6551\n"); |
| 81 | | transmit_register_send_bit(); |
| 82 | | } |
| 83 | | } |
| 84 | | |
| 85 | | static TIMER_CALLBACK(acia_6551_timer_callback) |
| 86 | | { |
| 87 | | reinterpret_cast<acia6551_device *>(ptr)->timer_callback(); |
| 88 | | } |
| 89 | | |
| 90 | | //------------------------------------------------- |
| 91 | | // device_start - device-specific startup |
| 92 | | //------------------------------------------------- |
| 93 | | |
| 94 | | void acia6551_device::device_start() |
| 95 | | { |
| 96 | | /* transmit data reg is empty */ |
| 97 | | m_status_register |= (1<<4); |
| 98 | | m_timer = machine().scheduler().timer_alloc(FUNC(acia_6551_timer_callback), (void *) this); |
| 99 | | |
| 100 | | transmit_register_reset(); |
| 101 | | receive_register_reset(); |
| 102 | | } |
| 103 | | |
| 104 | | |
| 105 | | |
| 106 | | /*------------------------------------------------- |
| 107 | | refresh_ints - update interrupt output |
| 108 | | -------------------------------------------------*/ |
| 109 | | |
| 110 | | void acia6551_device::refresh_ints() |
| 111 | | { |
| 112 | | int interrupt_state; |
| 113 | | |
| 114 | | interrupt_state = 0; |
| 115 | | |
| 116 | | /* receive interrupts */ |
| 117 | | |
| 118 | | /* receive data register full? */ |
| 119 | | if (m_status_register & (1<<3)) |
| 120 | | { |
| 121 | | /* receiver interrupt enable? */ |
| 122 | | if ((m_command_register & (1<<1))==0) |
| 123 | | { |
| 124 | | /* trigger a interrupt */ |
| 125 | | interrupt_state = 1; |
| 126 | | } |
| 127 | | } |
| 128 | | |
| 129 | | /* set state of irq bit in status register */ |
| 130 | | m_status_register &= ~(1<<7); |
| 131 | | |
| 132 | | if (interrupt_state) |
| 133 | | { |
| 134 | | m_status_register |=(1<<7); |
| 135 | | } |
| 136 | | |
| 137 | | //if (m_irq_callback != NULL) |
| 138 | | //(*m_irq_callback)(interrupt_state); |
| 139 | | } |
| 140 | | |
| 141 | | |
| 142 | | |
| 143 | | /*------------------------------------------------- |
| 144 | | receive_character |
| 145 | | -------------------------------------------------*/ |
| 146 | | |
| 147 | | void acia6551_device::receive_character(UINT8 ch) |
| 148 | | { |
| 149 | | /* receive register full? */ |
| 150 | | if (m_status_register & (1<<3)) |
| 151 | | { |
| 152 | | /* set overrun error */ |
| 153 | | m_status_register |= (1<<2); |
| 154 | | return; |
| 155 | | } |
| 156 | | |
| 157 | | /* set new byte */ |
| 158 | | m_receive_data_register = ch; |
| 159 | | /* receive register is full */ |
| 160 | | m_status_register |= (1<<3); |
| 161 | | /* update ints */ |
| 162 | | refresh_ints(); |
| 163 | | } |
| 164 | | |
| 165 | | |
| 166 | | |
| 167 | | /*------------------------------------------------- |
| 168 | | read |
| 169 | | -------------------------------------------------*/ |
| 170 | | |
| 171 | | READ8_MEMBER(acia6551_device::read) |
| 172 | | { |
| 173 | | unsigned char data; |
| 174 | | |
| 175 | | data = 0x0ff; |
| 176 | | switch (offset & 0x03) |
| 177 | | { |
| 178 | | case 0: |
| 179 | | { |
| 180 | | /* clear parity error, framing error and overrun error */ |
| 181 | | /* when read of data reigster is done */ |
| 182 | | m_status_register &=~((1<<0) | (1<<1) | (1<<2)); |
| 183 | | /* clear receive data register full flag */ |
| 184 | | m_status_register &=~(1<<3); |
| 185 | | /* return data */ |
| 186 | | data = m_receive_data_register; |
| 187 | | } |
| 188 | | break; |
| 189 | | |
| 190 | | /* |
| 191 | | Status cleared by |
| 192 | | b0 Parity error * (1: error) self clearing ** |
| 193 | | b1 Framing error * (1: error) self clearing ** |
| 194 | | b2 Overrun * (1: error) self clearing ** |
| 195 | | b3 Receive Data Register Full (1: full) Read Receive Data Register |
| 196 | | b4 Transmit Data Reg Empty (1: empty) Write Transmit Data Register |
| 197 | | b5 DCD (0: DCD low, 1: DCD high) Not resettable, reflects DCD state |
| 198 | | b6 DSR (0: DSR low, 1: DCD high) Not resettable, reflects DSR state |
| 199 | | b7 IRQ (0: no int., 1: interrupt) Read Status Register |
| 200 | | */ |
| 201 | | case 1: |
| 202 | | { |
| 203 | | data = m_status_register; |
| 204 | | /* clear interrupt */ |
| 205 | | m_status_register &= ~(1<<7); |
| 206 | | } |
| 207 | | break; |
| 208 | | |
| 209 | | case 2: |
| 210 | | data = m_command_register; |
| 211 | | break; |
| 212 | | |
| 213 | | case 3: |
| 214 | | data = m_control_register; |
| 215 | | break; |
| 216 | | |
| 217 | | default: |
| 218 | | break; |
| 219 | | } |
| 220 | | |
| 221 | | logerror("6551 R %04x %02x\n",offset & 0x03,data); |
| 222 | | |
| 223 | | return data; |
| 224 | | } |
| 225 | | |
| 226 | | |
| 227 | | |
| 228 | | /*------------------------------------------------- |
| 229 | | update_data_form |
| 230 | | -------------------------------------------------*/ |
| 231 | | |
| 232 | | void acia6551_device::update_data_form() |
| 233 | | { |
| 234 | | int word_length = 8-((m_control_register>>5) & 0x03); |
| 235 | | int stop_bit_count = (m_control_register>>7)+1; |
| 236 | | int parity = 0; |
| 237 | | if (m_command_register & (1<<5)) |
| 238 | | { |
| 239 | | parity = SERIAL_PARITY_ODD; |
| 240 | | } |
| 241 | | else |
| 242 | | { |
| 243 | | parity = SERIAL_PARITY_NONE; |
| 244 | | } |
| 245 | | |
| 246 | | set_data_frame(word_length, stop_bit_count, parity); |
| 247 | | } |
| 248 | | |
| 249 | | |
| 250 | | |
| 251 | | /*------------------------------------------------- |
| 252 | | write |
| 253 | | -------------------------------------------------*/ |
| 254 | | |
| 255 | | WRITE8_MEMBER(acia6551_device::write) |
| 256 | | { |
| 257 | | logerror("6551 W %04x %02x\n",offset & 0x03, data); |
| 258 | | |
| 259 | | switch (offset & 0x03) |
| 260 | | { |
| 261 | | case 0: |
| 262 | | { |
| 263 | | /* clear transmit data register empty */ |
| 264 | | m_status_register &= ~(1<<4); |
| 265 | | /* store byte */ |
| 266 | | m_transmit_data_register = data; |
| 267 | | |
| 268 | | } |
| 269 | | break; |
| 270 | | |
| 271 | | case 1: |
| 272 | | { |
| 273 | | /* telstrat writes 0x07f! */ |
| 274 | | } |
| 275 | | break; |
| 276 | | |
| 277 | | |
| 278 | | /* |
| 279 | | Command Register: |
| 280 | | |
| 281 | | b0 Data Terminal Ready |
| 282 | | 0 : disable receiver and all interrupts (DTR high) |
| 283 | | 1 : enable receiver and all interrupts (DTR low) |
| 284 | | b1 Receiver Interrupt Enable |
| 285 | | 0 : IRQ interrupt enabled from bit 3 of status register |
| 286 | | 1 : IRQ interrupt disabled |
| 287 | | b3,b2 Transmitter Control |
| 288 | | Transmit Interrupt RTS level Transmitter |
| 289 | | 00 disabled high off |
| 290 | | 01 enabled low on |
| 291 | | 10 disabled low on |
| 292 | | 11 disabled low Transmit BRK |
| 293 | | b4 Normal/Echo Mode for Receiver |
| 294 | | 0 : normal |
| 295 | | 1 : echo (bits 2 and 3 must be 0) |
| 296 | | b5 Parity Enable |
| 297 | | 0 : parity disabled, no parity bit generated or received |
| 298 | | 1 : parity enabled |
| 299 | | b7,b6 Parity |
| 300 | | 00 : odd parity receiver and transmitter |
| 301 | | 01 : even parity receiver and transmitter |
| 302 | | 10 : mark parity bit transmitted, parity check disabled |
| 303 | | 11 : space parity bit transmitted, parity check disabled |
| 304 | | */ |
| 305 | | |
| 306 | | case 2: |
| 307 | | { |
| 308 | | m_command_register = data; |
| 309 | | |
| 310 | | /* update state of dtr */ |
| 311 | | m_connection_state &=~SERIAL_STATE_DTR; |
| 312 | | if (m_command_register & (1<<0)) |
| 313 | | { |
| 314 | | m_connection_state |=SERIAL_STATE_DTR; |
| 315 | | } |
| 316 | | |
| 317 | | /* update state of rts */ |
| 318 | | switch ((m_command_register>>2) & 0x03) |
| 319 | | { |
| 320 | | case 0: |
| 321 | | { |
| 322 | | m_connection_state &=~SERIAL_STATE_RTS; |
| 323 | | } |
| 324 | | break; |
| 325 | | |
| 326 | | case 1: |
| 327 | | case 2: |
| 328 | | case 3: |
| 329 | | { |
| 330 | | m_connection_state |=SERIAL_STATE_RTS; |
| 331 | | } |
| 332 | | break; |
| 333 | | } |
| 334 | | |
| 335 | | serial_connection_out(); |
| 336 | | update_data_form(); |
| 337 | | } |
| 338 | | break; |
| 339 | | |
| 340 | | /* |
| 341 | | Control register: |
| 342 | | |
| 343 | | b3-b0 baud rate generator: |
| 344 | | 0000 : 16x external clock |
| 345 | | 0001 : 50 baud |
| 346 | | 0010 : 75 25 |
| 347 | | 0011 : 110 35 |
| 348 | | 0100 : 134.5 |
| 349 | | 0101 : 150 |
| 350 | | 0110 : 300 150 |
| 351 | | 0111 : 600 300 |
| 352 | | 1000 : 1200 600 |
| 353 | | 1001 : 1800 600 |
| 354 | | 1010 : 2400 600 |
| 355 | | 1011 : 3600 1200 |
| 356 | | 1100 : 4800 1200 |
| 357 | | 1101 : 7200 2400 |
| 358 | | 1110 : 9600 2400 |
| 359 | | 1111 : 19,200 9600 |
| 360 | | b4 receiver clock source |
| 361 | | 0 : external receiver clock |
| 362 | | 1 : baud rate generator |
| 363 | | b6,b5 word length |
| 364 | | 00 : 8 bits |
| 365 | | 01 : 7 |
| 366 | | 10 : 6 |
| 367 | | 11 : 5 |
| 368 | | b7 stop bits |
| 369 | | 0 : 1 stop bit |
| 370 | | 1 : 2 stop bits |
| 371 | | (1 stop bit if parity and word length = 8) |
| 372 | | (1 1/2 stop bits if word length = 5 and no parity) |
| 373 | | */ |
| 374 | | case 3: |
| 375 | | { |
| 376 | | unsigned char previous_control_register; |
| 377 | | |
| 378 | | previous_control_register = m_control_register; |
| 379 | | |
| 380 | | if (((previous_control_register^data) & 0x07)!=0) |
| 381 | | { |
| 382 | | int rate; |
| 383 | | |
| 384 | | rate = data & 0x07; |
| 385 | | |
| 386 | | /* baud rate changed? */ |
| 387 | | m_timer->reset(); |
| 388 | | |
| 389 | | if (rate==0) |
| 390 | | { |
| 391 | | /* 16x external clock */ |
| 392 | | logerror("6551: external clock not supported!\n"); |
| 393 | | } |
| 394 | | else |
| 395 | | { |
| 396 | | int baud_rate; |
| 397 | | |
| 398 | | switch (rate) |
| 399 | | { |
| 400 | | |
| 401 | | default: |
| 402 | | case 1: |
| 403 | | { |
| 404 | | baud_rate = 50; |
| 405 | | } |
| 406 | | break; |
| 407 | | |
| 408 | | case 2: |
| 409 | | { |
| 410 | | baud_rate = 75; |
| 411 | | } |
| 412 | | break; |
| 413 | | |
| 414 | | case 3: |
| 415 | | { |
| 416 | | baud_rate = 110; |
| 417 | | } |
| 418 | | break; |
| 419 | | |
| 420 | | case 4: |
| 421 | | { |
| 422 | | baud_rate = 135; |
| 423 | | } |
| 424 | | break; |
| 425 | | |
| 426 | | case 5: |
| 427 | | { |
| 428 | | baud_rate = 150; |
| 429 | | } |
| 430 | | break; |
| 431 | | |
| 432 | | case 6: |
| 433 | | { |
| 434 | | baud_rate = 300; |
| 435 | | } |
| 436 | | break; |
| 437 | | |
| 438 | | case 7: |
| 439 | | { |
| 440 | | baud_rate = 600; |
| 441 | | } |
| 442 | | break; |
| 443 | | |
| 444 | | case 8: |
| 445 | | { |
| 446 | | baud_rate = 1200; |
| 447 | | } |
| 448 | | break; |
| 449 | | |
| 450 | | case 9: |
| 451 | | { |
| 452 | | baud_rate = 1800; |
| 453 | | } |
| 454 | | break; |
| 455 | | |
| 456 | | case 10: |
| 457 | | { |
| 458 | | baud_rate = 2400; |
| 459 | | } |
| 460 | | break; |
| 461 | | |
| 462 | | case 11: |
| 463 | | { |
| 464 | | baud_rate = 3600; |
| 465 | | } |
| 466 | | break; |
| 467 | | |
| 468 | | case 12: |
| 469 | | { |
| 470 | | baud_rate = 4800; |
| 471 | | } |
| 472 | | break; |
| 473 | | |
| 474 | | case 13: |
| 475 | | { |
| 476 | | baud_rate = 7200; |
| 477 | | } |
| 478 | | break; |
| 479 | | |
| 480 | | case 14: |
| 481 | | { |
| 482 | | baud_rate = 9600; |
| 483 | | } |
| 484 | | break; |
| 485 | | |
| 486 | | case 15: |
| 487 | | { |
| 488 | | baud_rate = 19200; |
| 489 | | } |
| 490 | | break; |
| 491 | | } |
| 492 | | |
| 493 | | m_timer->adjust(attotime::zero, 0, attotime::from_hz(baud_rate)); |
| 494 | | } |
| 495 | | } |
| 496 | | |
| 497 | | m_control_register = data; |
| 498 | | update_data_form(); |
| 499 | | } |
| 500 | | break; |
| 501 | | |
| 502 | | default: |
| 503 | | break; |
| 504 | | } |
| 505 | | |
| 506 | | } |