diff options
Diffstat (limited to 'src/devices/bus/rs232/null_modem.cpp')
-rw-r--r-- | src/devices/bus/rs232/null_modem.cpp | 92 |
1 files changed, 53 insertions, 39 deletions
diff --git a/src/devices/bus/rs232/null_modem.cpp b/src/devices/bus/rs232/null_modem.cpp index 5cff5d8cf89..083fcb0d516 100644 --- a/src/devices/bus/rs232/null_modem.cpp +++ b/src/devices/bus/rs232/null_modem.cpp @@ -3,14 +3,13 @@ #include "emu.h" #include "null_modem.h" -null_modem_device::null_modem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, NULL_MODEM, tag, owner, clock), +null_modem_device::null_modem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, NULL_MODEM, tag, owner, clock), device_serial_interface(mconfig, *this), device_rs232_port_interface(mconfig, *this), m_stream(*this, "stream"), m_rs232_txbaud(*this, "RS232_TXBAUD"), m_rs232_rxbaud(*this, "RS232_RXBAUD"), - m_rs232_startbits(*this, "RS232_STARTBITS"), m_rs232_databits(*this, "RS232_DATABITS"), m_rs232_parity(*this, "RS232_PARITY"), m_rs232_stopbits(*this, "RS232_STOPBITS"), @@ -18,7 +17,9 @@ null_modem_device::null_modem_device(const machine_config &mconfig, const char * m_input_count(0), m_input_index(0), m_timer_poll(nullptr), - m_rts(0) + m_rts(0), + m_dtr(0), + m_xoff(0) { } @@ -30,15 +31,16 @@ void null_modem_device::device_add_mconfig(machine_config &config) static INPUT_PORTS_START(null_modem) PORT_RS232_BAUD("RS232_TXBAUD", RS232_BAUD_9600, "TX Baud", null_modem_device, update_serial) PORT_RS232_BAUD("RS232_RXBAUD", RS232_BAUD_9600, "RX Baud", null_modem_device, update_serial) - PORT_RS232_STARTBITS("RS232_STARTBITS", RS232_STARTBITS_1, "Start Bits", null_modem_device, update_serial) PORT_RS232_DATABITS("RS232_DATABITS", RS232_DATABITS_8, "Data Bits", null_modem_device, update_serial) PORT_RS232_PARITY("RS232_PARITY", RS232_PARITY_NONE, "Parity", null_modem_device, update_serial) PORT_RS232_STOPBITS("RS232_STOPBITS", RS232_STOPBITS_1, "Stop Bits", null_modem_device, update_serial) PORT_START("FLOW_CONTROL") - PORT_CONFNAME(0x01, 0x00, "Flow Control") - PORT_CONFSETTING(0x00, "Off") - PORT_CONFSETTING(0x01, "On") + PORT_CONFNAME(0x07, 0x00, "Flow Control") + PORT_CONFSETTING( 0x00, DEF_STR(Off)) + PORT_CONFSETTING( 0x01, "RTS") + PORT_CONFSETTING( 0x02, "DTR") + PORT_CONFSETTING( 0x04, "XON/XOFF") INPUT_PORTS_END ioport_constructor null_modem_device::device_input_ports() const @@ -48,12 +50,12 @@ ioport_constructor null_modem_device::device_input_ports() const void null_modem_device::device_start() { - m_timer_poll = timer_alloc(TIMER_POLL); + m_timer_poll = timer_alloc(FUNC(null_modem_device::update_queue), this); } -WRITE_LINE_MEMBER(null_modem_device::update_serial) +void null_modem_device::update_serial(int state) { - int startbits = convert_startbits(m_rs232_startbits->read()); + int startbits = 1; int databits = convert_databits(m_rs232_databits->read()); parity_t parity = convert_parity(m_rs232_parity->read()); stop_bits_t stopbits = convert_stopbits(m_rs232_stopbits->read()); @@ -73,29 +75,16 @@ WRITE_LINE_MEMBER(null_modem_device::update_serial) output_dsr(0); output_cts(0); - m_rts = 0; + m_xoff = 0; } void null_modem_device::device_reset() { update_serial(0); - queue(); + update_queue(0); } -void null_modem_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case TIMER_POLL: - queue(); - break; - - default: - break; - } -} - -void null_modem_device::queue() +TIMER_CALLBACK_MEMBER(null_modem_device::update_queue) { if (is_transmit_register_empty()) { @@ -105,17 +94,20 @@ void null_modem_device::queue() m_input_count = m_stream->input(m_input_buffer, sizeof(m_input_buffer)); } - if (m_input_count != 0 && (m_rts == 0 || !m_flow->read())) + if (m_input_count != 0) { - transmit_register_setup(m_input_buffer[m_input_index++]); - - m_timer_poll->adjust(attotime::never); - } - else - { - int txbaud = convert_baud(m_rs232_txbaud->read()); - m_timer_poll->adjust(attotime::from_hz(txbaud)); + uint8_t const fc = m_flow->read(); + + if (fc == 0 || (fc == 1 && m_rts == 0) || (fc == 2 && m_dtr == 0) || (fc == 4 && m_xoff == 0)) + { + transmit_register_setup(m_input_buffer[m_input_index++]); + m_timer_poll->adjust(attotime::never); + return; + } } + + int const txbaud = convert_baud(m_rs232_txbaud->read()); + m_timer_poll->adjust(attotime::from_hz(txbaud)); } } @@ -126,13 +118,35 @@ void null_modem_device::tra_callback() void null_modem_device::tra_complete() { - queue(); + update_queue(0); } void null_modem_device::rcv_complete() { receive_register_extract(); - m_stream->output(get_received_char()); + + uint8_t const data = get_received_char(); + if (m_flow->read() != 4) + { + m_stream->output(data); + } + else + { + switch (data) + { + case 0x13: // XOFF + m_xoff = 1; + return; + + case 0x11: // XON + m_xoff = 0; + return; + + default: + break; + } + m_stream->output(data); + } } -DEFINE_DEVICE_TYPE(NULL_MODEM, null_modem_device, "null_modem", "RS232 Null Modem") +DEFINE_DEVICE_TYPE(NULL_MODEM, null_modem_device, "null_modem", "RS-232 Null Modem") |