summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/rs232/rs232_sync_io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/rs232/rs232_sync_io.cpp')
-rw-r--r--src/devices/bus/rs232/rs232_sync_io.cpp110
1 files changed, 49 insertions, 61 deletions
diff --git a/src/devices/bus/rs232/rs232_sync_io.cpp b/src/devices/bus/rs232/rs232_sync_io.cpp
index 8977ece64b6..9812087b363 100644
--- a/src/devices/bus/rs232/rs232_sync_io.cpp
+++ b/src/devices/bus/rs232/rs232_sync_io.cpp
@@ -55,11 +55,6 @@ namespace {
}
}
-// Timers
-enum {
- TMR_ID_CLK
-};
-
rs232_sync_io_device::rs232_sync_io_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig , RS232_SYNC_IO , tag , owner , clock)
, device_rs232_port_interface(mconfig , *this)
@@ -75,13 +70,13 @@ rs232_sync_io_device:: ~rs232_sync_io_device()
{
}
-WRITE_LINE_MEMBER(rs232_sync_io_device::input_txd)
+void rs232_sync_io_device::input_txd(int state)
{
m_txd = state;
LOG("TxD %d %u\n" , state , m_tx_counter);
}
-WRITE_LINE_MEMBER(rs232_sync_io_device::input_rts)
+void rs232_sync_io_device::input_rts(int state)
{
m_rts = state;
}
@@ -118,7 +113,7 @@ void rs232_sync_io_device::device_add_mconfig(machine_config &config)
void rs232_sync_io_device::device_start()
{
- m_clk_timer = timer_alloc(TMR_ID_CLK);
+ m_clk_timer = timer_alloc(FUNC(rs232_sync_io_device::clock_tick), this);
}
void rs232_sync_io_device::device_reset()
@@ -141,73 +136,66 @@ void rs232_sync_io_device::device_reset()
output_rxc(1);
}
-void rs232_sync_io_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(rs232_sync_io_device::clock_tick)
{
- switch (id) {
- case TMR_ID_CLK:
- m_clk = !m_clk;
- if (m_clk) {
- output_txc(1);
- output_rxc(1);
- if (m_tx_enabled) {
- // Rising edge: capture TxD
- m_tx_byte = (m_tx_byte >> 1) & 0x7f;
- if (m_txd) {
- BIT_SET(m_tx_byte , 7);
- }
- if (++m_tx_counter >= 8) {
- LOG("Tx %02x @%s\n" , m_tx_byte , machine().time().to_string());
- m_tx_counter = 0;
- m_stream->output(m_tx_byte);
- m_tx_enabled = false;
- }
- }
- } else {
- if (!m_tx_enabled) {
- m_tx_enabled = !m_rts || !m_rts_duplex->read();
- output_cts(!m_tx_enabled);
+ m_clk = !m_clk;
+ if (m_clk) {
+ output_txc(1);
+ output_rxc(1);
+ if (m_tx_enabled) {
+ // Rising edge: capture TxD
+ m_tx_byte = (m_tx_byte >> 1) & 0x7f;
+ if (m_txd) {
+ BIT_SET(m_tx_byte , 7);
}
- if (m_tx_enabled || m_txc_setting->read() == 0) {
- output_txc(0);
+ if (++m_tx_counter >= 8) {
+ LOG("Tx %02x @%s\n" , m_tx_byte , machine().time().to_string());
+ m_tx_counter = 0;
+ m_stream->output(m_tx_byte);
+ m_tx_enabled = false;
}
- if (!m_rx_enabled) {
- m_rx_enabled = m_rts || !m_rts_duplex->read();
- if (m_rx_enabled) {
- if (m_stream->input(&m_rx_byte , 1) == 0) {
- m_rx_byte = ~0;
- if (m_rxc_setting->read() == 2) {
- m_rx_enabled = false;
- }
- } else {
- LOG("Rx %02x @%s\n" , m_rx_byte , machine().time().to_string());
+ }
+ } else {
+ if (!m_tx_enabled) {
+ m_tx_enabled = !m_rts || !m_rts_duplex->read();
+ output_cts(!m_tx_enabled);
+ }
+ if (m_tx_enabled || m_txc_setting->read() == 0) {
+ output_txc(0);
+ }
+ if (!m_rx_enabled) {
+ m_rx_enabled = m_rts || !m_rts_duplex->read();
+ if (m_rx_enabled) {
+ if (m_stream->input(&m_rx_byte , 1) == 0) {
+ m_rx_byte = ~0;
+ if (m_rxc_setting->read() == 2) {
+ m_rx_enabled = false;
}
+ } else {
+ LOG("Rx %02x @%s\n" , m_rx_byte , machine().time().to_string());
}
}
- if (m_rx_enabled || m_rxc_setting->read() == 0) {
- output_rxc(0);
- }
- if (m_rx_enabled) {
- // Falling edge: update RxD
- output_rxd(BIT(m_rx_byte , 0));
- m_rx_byte >>= 1;
- if (++m_rx_counter >= 8) {
- m_rx_counter = 0;
- m_rx_enabled = false;
- }
+ }
+ if (m_rx_enabled || m_rxc_setting->read() == 0) {
+ output_rxc(0);
+ }
+ if (m_rx_enabled) {
+ // Falling edge: update RxD
+ output_rxd(BIT(m_rx_byte , 0));
+ m_rx_byte >>= 1;
+ if (++m_rx_counter >= 8) {
+ m_rx_counter = 0;
+ m_rx_enabled = false;
}
}
- break;
-
- default:
- break;
}
}
-WRITE_LINE_MEMBER(rs232_sync_io_device::update_serial)
+void rs232_sync_io_device::update_serial(int state)
{
auto baud_rate = convert_baud(m_rs232_baud->read());
auto period = attotime::from_hz(baud_rate * 2);
m_clk_timer->adjust(period , 0 , period);
}
-DEFINE_DEVICE_TYPE(RS232_SYNC_IO, rs232_sync_io_device, "rs232_sync_io", "RS232 Synchronous I/O")
+DEFINE_DEVICE_TYPE(RS232_SYNC_IO, rs232_sync_io_device, "rs232_sync_io", "RS-232 Synchronous I/O")