mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
diserial: Remove defines, cleanup clocks/timers, add sync support [O. Galibert]
This commit is contained in:
parent
8c7bc3bfa7
commit
671ba32470
@ -40,6 +40,8 @@ device_serial_interface::device_serial_interface(const machine_config &mconfig,
|
||||
}
|
||||
m_rcv_clock = NULL;
|
||||
m_tra_clock = NULL;
|
||||
m_rcv_clock_state = false;
|
||||
m_tra_clock_state = false;
|
||||
m_tra_rate = attotime::never;
|
||||
m_rcv_rate = attotime::never;
|
||||
m_tra_flags = 0;
|
||||
@ -54,15 +56,12 @@ device_serial_interface::~device_serial_interface()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// interface_pre_start - work to be done prior to
|
||||
// actually starting a device
|
||||
//-------------------------------------------------
|
||||
|
||||
void device_serial_interface::interface_pre_start()
|
||||
{
|
||||
m_rcv_clock = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_serial_interface::rcv_timer), this));
|
||||
m_tra_clock = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_serial_interface::tra_timer), this));
|
||||
m_rcv_clock = device().timer_alloc(RCV_TIMER_ID);
|
||||
m_tra_clock = device().timer_alloc(TRA_TIMER_ID);
|
||||
m_rcv_clock_state = false;
|
||||
m_tra_clock_state = false;
|
||||
}
|
||||
|
||||
void device_serial_interface::set_rcv_rate(attotime rate)
|
||||
@ -79,7 +78,7 @@ void device_serial_interface::set_tra_rate(attotime rate)
|
||||
m_tra_clock->adjust(attotime::never);
|
||||
}
|
||||
|
||||
void device_serial_interface::tra_clock()
|
||||
void device_serial_interface::tra_edge()
|
||||
{
|
||||
tra_callback();
|
||||
if(is_transmit_register_empty())
|
||||
@ -89,12 +88,7 @@ void device_serial_interface::tra_clock()
|
||||
}
|
||||
}
|
||||
|
||||
void device_serial_interface::tra_timer(void *ptr, int param)
|
||||
{
|
||||
tra_clock();
|
||||
}
|
||||
|
||||
void device_serial_interface::rcv_clock()
|
||||
void device_serial_interface::rcv_edge()
|
||||
{
|
||||
rcv_callback();
|
||||
if(is_receive_register_full())
|
||||
@ -104,20 +98,49 @@ void device_serial_interface::rcv_clock()
|
||||
}
|
||||
}
|
||||
|
||||
void device_serial_interface::rcv_timer(void *ptr, int param)
|
||||
WRITE_LINE_MEMBER(device_serial_interface::tx_clock_w)
|
||||
{
|
||||
rcv_clock();
|
||||
if(state != m_tra_clock_state) {
|
||||
m_tra_clock_state = state;
|
||||
if(m_tra_clock_state)
|
||||
tra_edge();
|
||||
}
|
||||
}
|
||||
|
||||
void device_serial_interface::set_data_frame(int num_data_bits, int stop_bit_count, int parity_code)
|
||||
WRITE_LINE_MEMBER(device_serial_interface::rx_clock_w)
|
||||
{
|
||||
if(state != m_rcv_clock_state) {
|
||||
m_rcv_clock_state = state;
|
||||
if(!m_rcv_clock_state)
|
||||
rcv_edge();
|
||||
}
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER(device_serial_interface::clock_w)
|
||||
{
|
||||
tx_clock_w(state);
|
||||
rx_clock_w(state);
|
||||
}
|
||||
|
||||
void device_serial_interface::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
switch(id) {
|
||||
case TRA_TIMER_ID: tx_clock_w(!m_tra_clock_state); break;
|
||||
case RCV_TIMER_ID: rx_clock_w(!m_rcv_clock_state); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void device_serial_interface::set_data_frame(int num_data_bits, int stop_bit_count, int parity_code, bool synchronous)
|
||||
{
|
||||
m_df_word_length = num_data_bits;
|
||||
m_df_stop_bit_count = stop_bit_count;
|
||||
m_df_parity = parity_code;
|
||||
m_synchronous = synchronous;
|
||||
|
||||
m_rcv_bit_count = m_df_word_length + m_df_stop_bit_count;
|
||||
|
||||
if (m_df_parity != SERIAL_PARITY_NONE)
|
||||
if (m_df_parity != PARITY_NONE)
|
||||
{
|
||||
m_rcv_bit_count++;
|
||||
}
|
||||
@ -127,8 +150,16 @@ void device_serial_interface::receive_register_reset()
|
||||
{
|
||||
m_rcv_bit_count_received = 0;
|
||||
m_rcv_flags &=~RECEIVE_REGISTER_FULL;
|
||||
m_rcv_flags &=~RECEIVE_REGISTER_SYNCHRONISED;
|
||||
m_rcv_flags |= RECEIVE_REGISTER_WAITING_FOR_START_BIT;
|
||||
if (m_synchronous)
|
||||
{
|
||||
m_rcv_flags |= RECEIVE_REGISTER_SYNCHRONISED;
|
||||
m_rcv_flags &=~RECEIVE_REGISTER_WAITING_FOR_START_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rcv_flags &=~RECEIVE_REGISTER_SYNCHRONISED;
|
||||
m_rcv_flags |= RECEIVE_REGISTER_WAITING_FOR_START_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER(device_serial_interface::rx_w)
|
||||
@ -165,7 +196,7 @@ void device_serial_interface::receive_register_update_bit(int bit)
|
||||
/* update bit count received */
|
||||
m_rcv_bit_count_received++;
|
||||
|
||||
/* asyncrhonouse mode */
|
||||
/* asynchronous mode */
|
||||
if (m_rcv_flags & RECEIVE_REGISTER_WAITING_FOR_START_BIT)
|
||||
{
|
||||
/* the previous bit is stored in uart.receive char bit 0 */
|
||||
@ -216,7 +247,7 @@ void device_serial_interface::receive_register_extract()
|
||||
|
||||
m_rcv_byte_received = data;
|
||||
|
||||
if(m_df_parity == SERIAL_PARITY_NONE)
|
||||
if(m_df_parity == PARITY_NONE)
|
||||
return;
|
||||
|
||||
//unsigned char computed_parity;
|
||||
@ -229,13 +260,13 @@ void device_serial_interface::receive_register_extract()
|
||||
switch (m_df_parity)
|
||||
{
|
||||
/* check parity */
|
||||
case SERIAL_PARITY_ODD:
|
||||
case SERIAL_PARITY_EVEN:
|
||||
case PARITY_ODD:
|
||||
case PARITY_EVEN:
|
||||
{
|
||||
/* compute parity for received bits */
|
||||
//computed_parity = serial_helper_get_parity(data);
|
||||
|
||||
if (m_df_parity == SERIAL_PARITY_ODD)
|
||||
if (m_df_parity == PARITY_ODD)
|
||||
{
|
||||
/* odd parity */
|
||||
|
||||
@ -250,8 +281,8 @@ void device_serial_interface::receive_register_extract()
|
||||
|
||||
}
|
||||
break;
|
||||
case SERIAL_PARITY_MARK:
|
||||
case SERIAL_PARITY_SPACE:
|
||||
case PARITY_MARK:
|
||||
case PARITY_SPACE:
|
||||
//computed_parity = parity_received;
|
||||
break;
|
||||
}
|
||||
@ -289,8 +320,9 @@ void device_serial_interface::transmit_register_setup(UINT8 data_byte)
|
||||
m_tra_bit_count = 0;
|
||||
m_tra_flags &=~TRANSMIT_REGISTER_EMPTY;
|
||||
|
||||
/* start bit */
|
||||
transmit_register_add_bit(0);
|
||||
if (!m_synchronous)
|
||||
/* start bit */
|
||||
transmit_register_add_bit(0);
|
||||
|
||||
/* data bits */
|
||||
transmit_data = data_byte;
|
||||
@ -306,24 +338,24 @@ void device_serial_interface::transmit_register_setup(UINT8 data_byte)
|
||||
}
|
||||
|
||||
/* parity */
|
||||
if (m_df_parity!=SERIAL_PARITY_NONE)
|
||||
if (m_df_parity!=PARITY_NONE)
|
||||
{
|
||||
/* odd or even parity */
|
||||
unsigned char parity = 0;
|
||||
switch(m_df_parity)
|
||||
{
|
||||
case SERIAL_PARITY_EVEN:
|
||||
case SERIAL_PARITY_ODD:
|
||||
case PARITY_EVEN:
|
||||
case PARITY_ODD:
|
||||
|
||||
/* get parity */
|
||||
/* if parity = 0, data has even parity - i.e. there is an even number of one bits in the data */
|
||||
/* if parity = 1, data has odd parity - i.e. there is an odd number of one bits in the data */
|
||||
parity = serial_helper_get_parity(data_byte);
|
||||
break;
|
||||
case SERIAL_PARITY_MARK:
|
||||
case PARITY_MARK:
|
||||
parity = 1;
|
||||
break;
|
||||
case SERIAL_PARITY_SPACE:
|
||||
case PARITY_SPACE:
|
||||
parity = 0;
|
||||
break;
|
||||
}
|
||||
@ -362,7 +394,7 @@ UINT8 device_serial_interface::transmit_register_send_bit()
|
||||
UINT8 data = transmit_register_get_data_bit();
|
||||
|
||||
/* set tx data bit */
|
||||
m_connection_state &=~SERIAL_STATE_TX_DATA;
|
||||
m_connection_state &= ~TX;
|
||||
m_connection_state|=(data<<5);
|
||||
|
||||
/* state out through connection */
|
||||
@ -457,6 +489,11 @@ void serial_source_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
void serial_source_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
void serial_source_device::input_callback(UINT8 state)
|
||||
{
|
||||
m_input_state = state;
|
||||
|
@ -7,85 +7,43 @@
|
||||
#ifndef __DISERIAL_H__
|
||||
#define __DISERIAL_H__
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
/* parity selections */
|
||||
/* if all the bits are added in a byte, if the result is:
|
||||
even -> parity is even
|
||||
odd -> parity is odd
|
||||
*/
|
||||
enum
|
||||
{
|
||||
SERIAL_PARITY_NONE, /* no parity. a parity bit will not be in the transmitted/received data */
|
||||
SERIAL_PARITY_ODD, /* odd parity */
|
||||
SERIAL_PARITY_EVEN, /* even parity */
|
||||
SERIAL_PARITY_MARK, /* one parity */
|
||||
SERIAL_PARITY_SPACE /* zero parity */
|
||||
};
|
||||
|
||||
/*
|
||||
CTS = Clear to Send. (INPUT)
|
||||
Other end of connection is ready to accept data
|
||||
|
||||
|
||||
NOTE:
|
||||
|
||||
This output is active low on serial chips (e.g. 0 is CTS is set),
|
||||
but here it is active high!
|
||||
*/
|
||||
#define SERIAL_STATE_CTS 0x0001
|
||||
|
||||
/*
|
||||
RTS = Request to Send. (OUTPUT)
|
||||
This end is ready to send data, and requests if the other
|
||||
end is ready to accept it
|
||||
|
||||
NOTE:
|
||||
|
||||
This output is active low on serial chips (e.g. 0 is RTS is set),
|
||||
but here it is active high!
|
||||
*/
|
||||
#define SERIAL_STATE_RTS 0x0002
|
||||
|
||||
/*
|
||||
DSR = Data Set ready. (INPUT)
|
||||
Other end of connection has data
|
||||
|
||||
|
||||
NOTE:
|
||||
|
||||
This output is active low on serial chips (e.g. 0 is DSR is set),
|
||||
but here it is active high!
|
||||
*/
|
||||
#define SERIAL_STATE_DSR 0x0004
|
||||
|
||||
/*
|
||||
DTR = Data terminal Ready. (OUTPUT)
|
||||
TX contains new data.
|
||||
|
||||
NOTE:
|
||||
|
||||
This output is active low on serial chips (e.g. 0 is DTR is set),
|
||||
but here it is active high!
|
||||
*/
|
||||
#define SERIAL_STATE_DTR 0x0008
|
||||
/* RX = Recieve data. (INPUT) */
|
||||
#define SERIAL_STATE_RX_DATA 0x00010
|
||||
/* TX = Transmit data. (OUTPUT) */
|
||||
#define SERIAL_STATE_TX_DATA 0x00020
|
||||
|
||||
// ======================> device_serial_interface
|
||||
class device_serial_interface : public device_interface
|
||||
{
|
||||
public:
|
||||
/* parity selections */
|
||||
/* if all the bits are added in a byte, if the result is:
|
||||
even -> parity is even
|
||||
odd -> parity is odd
|
||||
*/
|
||||
enum
|
||||
{
|
||||
PARITY_NONE, /* no parity. a parity bit will not be in the transmitted/received data */
|
||||
PARITY_ODD, /* odd parity */
|
||||
PARITY_EVEN, /* even parity */
|
||||
PARITY_MARK, /* one parity */
|
||||
PARITY_SPACE /* zero parity */
|
||||
};
|
||||
|
||||
/* Communication lines. Beware, everything is active high */
|
||||
enum
|
||||
{
|
||||
CTS = 0x0001, /* Clear to Send. (INPUT) Other end of connection is ready to accept data */
|
||||
RTS = 0x0002, /* Request to Send. (OUTPUT) This end is ready to send data, and requests if the other */
|
||||
/* end is ready to accept it */
|
||||
DSR = 0x0004, /* Data Set ready. (INPUT) Other end of connection has data */
|
||||
DTR = 0x0008, /* Data terminal Ready. (OUTPUT) TX contains new data. */
|
||||
RX = 0x0010, /* Recieve data. (INPUT) */
|
||||
TX = 0x0020 /* TX = Transmit data. (OUTPUT) */
|
||||
};
|
||||
|
||||
// construction/destruction
|
||||
device_serial_interface(const machine_config &mconfig, device_t &device);
|
||||
virtual ~device_serial_interface();
|
||||
|
||||
virtual void input_callback(UINT8 state) = 0;
|
||||
|
||||
void set_data_frame(int num_data_bits, int stop_bit_count, int parity_code);
|
||||
void set_data_frame(int num_data_bits, int stop_bit_count, int parity_code, bool synchronous);
|
||||
|
||||
void receive_register_reset();
|
||||
void receive_register_update_bit(int bit);
|
||||
@ -101,8 +59,9 @@ public:
|
||||
void set_rate(UINT32 clock, int div) { set_rcv_rate(clock, div); set_tra_rate(clock, div); }
|
||||
void set_rate(int baud) { set_rcv_rate(baud); set_tra_rate(baud); }
|
||||
|
||||
void tra_clock();
|
||||
void rcv_clock();
|
||||
DECLARE_WRITE_LINE_MEMBER(tx_clock_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(rx_clock_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(clock_w);
|
||||
|
||||
void transmit_register_reset();
|
||||
void transmit_register_add_bit(int bit);
|
||||
@ -112,8 +71,8 @@ public:
|
||||
|
||||
UINT8 serial_helper_get_parity(UINT8 data) { return m_serial_parity_table[data]; }
|
||||
|
||||
UINT8 get_in_data_bit() { return ((m_input_state & SERIAL_STATE_RX_DATA)>>4) & 1; }
|
||||
void set_out_data_bit(UINT8 data) { m_connection_state &=~SERIAL_STATE_TX_DATA; m_connection_state |=(data<<5); }
|
||||
UINT8 get_in_data_bit() { return ((m_input_state & RX)>>4) & 1; }
|
||||
void set_out_data_bit(UINT8 data) { m_connection_state &= ~TX; m_connection_state |=(data<<5); }
|
||||
|
||||
void serial_connection_out();
|
||||
|
||||
@ -136,9 +95,12 @@ protected:
|
||||
|
||||
// interface-level overrides
|
||||
virtual void interface_pre_start();
|
||||
|
||||
// Must be called from device_timer in the underlying device
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
private:
|
||||
void tra_timer(void *ptr, int param);
|
||||
void rcv_timer(void *ptr, int param);
|
||||
enum { TRA_TIMER_ID = 10000, RCV_TIMER_ID };
|
||||
|
||||
UINT8 m_serial_parity_table[256];
|
||||
|
||||
@ -149,6 +111,8 @@ private:
|
||||
UINT8 m_df_parity;
|
||||
// number of stop bits
|
||||
UINT8 m_df_stop_bit_count;
|
||||
// synchronous or not
|
||||
bool m_synchronous;
|
||||
|
||||
// Receive register
|
||||
/* data */
|
||||
@ -178,12 +142,17 @@ private:
|
||||
attotime m_tra_rate;
|
||||
UINT8 m_rcv_line;
|
||||
|
||||
bool m_tra_clock_state, m_rcv_clock_state;
|
||||
|
||||
device_serial_interface *m_other_connection;
|
||||
|
||||
void tra_edge();
|
||||
void rcv_edge();
|
||||
};
|
||||
|
||||
|
||||
class serial_source_device : public device_t,
|
||||
public device_serial_interface
|
||||
public device_serial_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -194,6 +163,7 @@ public:
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
};
|
||||
|
||||
extern const device_type SERIAL_SOURCE;
|
||||
|
@ -46,7 +46,7 @@ void midiin_device::device_reset()
|
||||
// we don't Rx, we Tx at 31250 8-N-1
|
||||
set_rcv_rate(0);
|
||||
set_tra_rate(31250);
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -73,6 +73,11 @@ void midiin_device::device_config_complete(void)
|
||||
|
||||
void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
if (id) {
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 buf[8192*4];
|
||||
int bytesRead;
|
||||
|
||||
|
@ -40,7 +40,12 @@ void midiout_device::device_reset()
|
||||
// we don't Tx, we Rx at 31250 8-N-1
|
||||
set_rcv_rate(31250);
|
||||
set_tra_rate(0);
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
void midiout_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
|
@ -52,6 +52,7 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
virtual void device_config_complete();
|
||||
|
||||
|
@ -51,7 +51,7 @@ void serial_image_device::device_config_complete()
|
||||
m_baud_rate = 2400;
|
||||
m_data_bits = 8;
|
||||
m_stop_bits = 2;
|
||||
m_parity = SERIAL_PARITY_NONE;
|
||||
m_parity = PARITY_NONE;
|
||||
m_transmit_on_start = FALSE;
|
||||
m_tag_connected = NULL;
|
||||
}
|
||||
@ -80,17 +80,17 @@ void serial_image_device::input_callback(UINT8 state)
|
||||
|
||||
void serial_image_device::device_start()
|
||||
{
|
||||
set_data_frame(m_data_bits, m_stop_bits,m_parity);
|
||||
set_data_frame(m_data_bits, m_stop_bits, m_parity, false);
|
||||
|
||||
m_timer = machine().scheduler().timer_alloc(FUNC(serial_device_baud_rate_callback), this);
|
||||
|
||||
/* signal to other end it is clear to send! */
|
||||
/* data is initially high state */
|
||||
/* set /rts */
|
||||
m_connection_state |= SERIAL_STATE_RTS;
|
||||
m_connection_state |= RTS;
|
||||
/* signal to other end data is ready to be accepted */
|
||||
/* set /dtr */
|
||||
m_connection_state |= SERIAL_STATE_DTR;
|
||||
m_connection_state |= DTR;
|
||||
|
||||
set_out_data_bit(1);
|
||||
serial_connection_out();
|
||||
@ -241,7 +241,7 @@ void serial_image_device::timer_callback()
|
||||
}
|
||||
|
||||
/* other side says it is clear to send? */
|
||||
if (m_connection_state & SERIAL_STATE_CTS)
|
||||
if (m_connection_state & CTS)
|
||||
{
|
||||
/* send bit */
|
||||
transmit_register_send_bit();
|
||||
|
@ -40,7 +40,7 @@ void i8251_device::input_callback(UINT8 state)
|
||||
m_input_state = state;
|
||||
|
||||
/* did cts change state? */
|
||||
if (changed & SERIAL_STATE_CTS)
|
||||
if (changed & CTS)
|
||||
{
|
||||
/* yes */
|
||||
/* update tx ready */
|
||||
@ -208,7 +208,7 @@ void i8251_device::transmit_clock()
|
||||
//transmit_register_send_bit();
|
||||
m_out_txd_func(data);
|
||||
|
||||
m_connection_state &=~SERIAL_STATE_TX_DATA;
|
||||
m_connection_state &= ~TX;
|
||||
m_connection_state|=(data<<5);
|
||||
serial_connection_out();
|
||||
}
|
||||
@ -265,7 +265,7 @@ void i8251_device::update_tx_ready()
|
||||
if ((m_command & (1<<0))!=0)
|
||||
{
|
||||
/* other side has rts set (comes in as CTS at this side) */
|
||||
if (m_input_state & SERIAL_STATE_CTS)
|
||||
if (m_input_state & CTS)
|
||||
{
|
||||
if (m_status & I8251_STATUS_TX_EMPTY)
|
||||
{
|
||||
@ -313,7 +313,7 @@ void i8251_device::device_reset()
|
||||
set_out_data_bit(1);
|
||||
|
||||
/* assumption, rts is set to 1 */
|
||||
m_connection_state &= ~SERIAL_STATE_RTS;
|
||||
m_connection_state &= ~RTS;
|
||||
serial_connection_out();
|
||||
|
||||
transmit_register_reset();
|
||||
@ -406,7 +406,7 @@ WRITE8_MEMBER(i8251_device::control_w)
|
||||
|
||||
LOG(("Character length: %d\n", (((data>>2) & 0x03)+5)));
|
||||
|
||||
int parity = SERIAL_PARITY_NONE;
|
||||
int parity = PARITY_NONE;
|
||||
|
||||
if (data & (1<<4))
|
||||
{
|
||||
@ -415,12 +415,12 @@ WRITE8_MEMBER(i8251_device::control_w)
|
||||
if (data & (1<<5))
|
||||
{
|
||||
LOG(("even parity\n"));
|
||||
parity = SERIAL_PARITY_EVEN;
|
||||
parity = PARITY_EVEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(("odd parity\n"));
|
||||
parity = SERIAL_PARITY_ODD;
|
||||
parity = PARITY_ODD;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -478,7 +478,7 @@ WRITE8_MEMBER(i8251_device::control_w)
|
||||
stop_bit_count = 2;
|
||||
break;
|
||||
}
|
||||
set_data_frame(word_length,stop_bit_count,parity);
|
||||
set_data_frame(word_length,stop_bit_count,parity,false);
|
||||
|
||||
switch (data & 0x03)
|
||||
{
|
||||
@ -624,17 +624,17 @@ WRITE8_MEMBER(i8251_device::control_w)
|
||||
1 = transmit enable
|
||||
*/
|
||||
|
||||
m_connection_state &=~SERIAL_STATE_RTS;
|
||||
m_connection_state &= ~RTS;
|
||||
if (data & (1<<5))
|
||||
{
|
||||
/* rts set to 0 */
|
||||
m_connection_state |= SERIAL_STATE_RTS;
|
||||
m_connection_state |= RTS;
|
||||
}
|
||||
|
||||
m_connection_state &=~SERIAL_STATE_DTR;
|
||||
m_connection_state &= ~DTR;
|
||||
if (data & (1<<1))
|
||||
{
|
||||
m_connection_state |= SERIAL_STATE_DTR;
|
||||
m_connection_state |= DTR;
|
||||
}
|
||||
|
||||
if ((data & (1<<0))==0)
|
||||
@ -741,3 +741,9 @@ READ8_MEMBER(i8251_device::data_r)
|
||||
update_rx_ready();
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
void i8251_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ protected:
|
||||
virtual void device_start();
|
||||
virtual void device_config_complete();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
void update_rx_ready();
|
||||
void update_tx_ready();
|
||||
|
@ -182,6 +182,10 @@ void im6402_device::device_reset()
|
||||
set_tre(ASSERT_LINE);
|
||||
}
|
||||
|
||||
void im6402_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// tra_callback -
|
||||
@ -255,7 +259,8 @@ void im6402_device::input_callback(UINT8 state)
|
||||
{
|
||||
m_input_state = state;
|
||||
|
||||
rcv_clock(); // HACK for Wang PC keyboard
|
||||
rx_clock_w(1); // HACK for Wang PC keyboard
|
||||
rx_clock_w(0);
|
||||
}
|
||||
|
||||
|
||||
@ -293,13 +298,8 @@ WRITE_LINE_MEMBER( im6402_device::rrc_w )
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
m_rrc_count++;
|
||||
|
||||
if (m_rrc_count == 16)
|
||||
{
|
||||
rcv_clock();
|
||||
m_rrc_count = 0;
|
||||
}
|
||||
rx_clock_w(m_rrc_count < 8);
|
||||
m_rrc_count = (m_rrc_count + 1) & 15;
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,13 +312,8 @@ WRITE_LINE_MEMBER( im6402_device::trc_w )
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
m_trc_count++;
|
||||
|
||||
if (m_trc_count == 16)
|
||||
{
|
||||
tra_clock();
|
||||
m_trc_count = 0;
|
||||
}
|
||||
tx_clock_w(m_trc_count < 8);
|
||||
m_trc_count = (m_trc_count + 1) & 15;
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,11 +376,11 @@ WRITE_LINE_MEMBER( im6402_device::crl_w )
|
||||
float stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0);
|
||||
int parity_code;
|
||||
|
||||
if (m_pi) parity_code = SERIAL_PARITY_NONE;
|
||||
else if (m_epe) parity_code = SERIAL_PARITY_EVEN;
|
||||
else parity_code = SERIAL_PARITY_ODD;
|
||||
if (m_pi) parity_code = PARITY_NONE;
|
||||
else if (m_epe) parity_code = PARITY_EVEN;
|
||||
else parity_code = PARITY_ODD;
|
||||
|
||||
set_data_frame(word_length, stop_bits, parity_code);
|
||||
set_data_frame(word_length, stop_bits, parity_code, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ protected:
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// device_serial_interface overrides
|
||||
virtual void tra_callback();
|
||||
|
@ -242,23 +242,23 @@ WRITE8_MEMBER( ins8250_uart_device::ins8250_w )
|
||||
switch ((m_regs.lcr>>3) & 7)
|
||||
{
|
||||
case 1:
|
||||
tmp = SERIAL_PARITY_ODD;
|
||||
tmp = PARITY_ODD;
|
||||
break;
|
||||
case 3:
|
||||
tmp = SERIAL_PARITY_EVEN;
|
||||
tmp = PARITY_EVEN;
|
||||
break;
|
||||
case 5:
|
||||
tmp = SERIAL_PARITY_MARK;
|
||||
tmp = PARITY_MARK;
|
||||
break;
|
||||
case 7:
|
||||
tmp = SERIAL_PARITY_SPACE;
|
||||
tmp = PARITY_SPACE;
|
||||
break;
|
||||
default:
|
||||
tmp = SERIAL_PARITY_NONE;
|
||||
tmp = PARITY_NONE;
|
||||
break;
|
||||
}
|
||||
// if 5 data bits and stb = 1, stop bits is supposed to be 1.5
|
||||
set_data_frame((m_regs.lcr & 3) + 5, (m_regs.lcr & 4)?2:1, tmp);
|
||||
set_data_frame((m_regs.lcr & 3) + 5, (m_regs.lcr & 4)?2:1, tmp, false);
|
||||
break;
|
||||
case 4:
|
||||
if ( ( m_regs.mcr & 0x1f ) != ( data & 0x1f ) )
|
||||
@ -539,6 +539,12 @@ void ins8250_uart_device::device_config_complete()
|
||||
}
|
||||
}
|
||||
|
||||
void ns16550_device::device_start()
|
||||
{
|
||||
m_timeout = timer_alloc();
|
||||
ins8250_uart_device::device_start();
|
||||
}
|
||||
|
||||
void ns16550_device::device_reset()
|
||||
{
|
||||
memset(&m_rfifo, '\0', sizeof(m_rfifo));
|
||||
@ -551,8 +557,13 @@ void ns16550_device::device_reset()
|
||||
|
||||
void ns16550_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
trigger_int(COM_INT_PENDING_CHAR_TIMEOUT);
|
||||
m_timeout->adjust(attotime::never);
|
||||
if(id)
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
else
|
||||
{
|
||||
trigger_int(COM_INT_PENDING_CHAR_TIMEOUT);
|
||||
m_timeout->adjust(attotime::never);
|
||||
}
|
||||
}
|
||||
|
||||
void ns16550_device::push_tx(UINT8 data)
|
||||
|
@ -104,7 +104,7 @@ class ns16550_device : public ins8250_uart_device
|
||||
public:
|
||||
ns16550_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
protected:
|
||||
virtual void device_start() { m_timeout = timer_alloc(); ins8250_uart_device::device_start(); }
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void rcv_complete();
|
||||
virtual void tra_complete();
|
||||
|
@ -339,11 +339,11 @@ WRITE8_MEMBER( mc2661_device::write )
|
||||
case STOP_BITS_2: stop_bits = 2; break;
|
||||
}
|
||||
|
||||
if (!MODE_PARITY) parity_code = SERIAL_PARITY_NONE;
|
||||
else if (MODE_PARITY_EVEN) parity_code = SERIAL_PARITY_EVEN;
|
||||
else parity_code = SERIAL_PARITY_ODD;
|
||||
if (!MODE_PARITY) parity_code = PARITY_NONE;
|
||||
else if (MODE_PARITY_EVEN) parity_code = PARITY_EVEN;
|
||||
else parity_code = PARITY_ODD;
|
||||
|
||||
set_data_frame(word_length, stop_bits, parity_code);
|
||||
set_data_frame(word_length, stop_bits, parity_code, false);
|
||||
}
|
||||
|
||||
m_mode_index++;
|
||||
@ -366,27 +366,6 @@ WRITE8_MEMBER( mc2661_device::write )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// rxc_w - receiver clock
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( mc2661_device::rxc_w )
|
||||
{
|
||||
rcv_clock();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// txc_w - transmitter clock
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( mc2661_device::txc_w )
|
||||
{
|
||||
tra_clock();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// dsr_w - data set ready
|
||||
//-------------------------------------------------
|
||||
@ -453,3 +432,9 @@ READ_LINE_MEMBER( mc2661_device::txemt_r )
|
||||
{
|
||||
return (m_sr & STATUS_TXEMT) ? ASSERT_LINE : CLEAR_LINE;
|
||||
}
|
||||
|
||||
|
||||
void mc2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
@ -86,9 +86,6 @@ public:
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( rxc_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( txc_w );
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( dsr_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( dcd_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( cts_w );
|
||||
@ -101,6 +98,7 @@ protected:
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// device_serial_interface overrides
|
||||
virtual void tra_callback();
|
||||
|
@ -800,7 +800,10 @@ void mc68901_device::device_reset()
|
||||
|
||||
void mc68901_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
timer_count(id);
|
||||
if(id >= TIMER_A && id <= TIMER_D)
|
||||
timer_count(id);
|
||||
else
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -1227,7 +1230,7 @@ void mc68901_device::register_w(offs_t offset, UINT8 data)
|
||||
|
||||
case REGISTER_UCR:
|
||||
{
|
||||
int parity_code = SERIAL_PARITY_NONE;
|
||||
int parity_code = PARITY_NONE;
|
||||
|
||||
if (data & UCR_PARITY_ENABLED)
|
||||
{
|
||||
@ -1235,13 +1238,13 @@ void mc68901_device::register_w(offs_t offset, UINT8 data)
|
||||
{
|
||||
if (LOG) logerror("MC68901 '%s' Parity : Even\n", tag());
|
||||
|
||||
parity_code = SERIAL_PARITY_EVEN;
|
||||
parity_code = PARITY_EVEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG) logerror("MC68901 '%s' Parity : Odd\n", tag());
|
||||
|
||||
parity_code = SERIAL_PARITY_ODD;
|
||||
parity_code = PARITY_ODD;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1259,11 +1262,13 @@ void mc68901_device::register_w(offs_t offset, UINT8 data)
|
||||
|
||||
if (LOG) logerror("MC68901 '%s' Word Length : %u bits\n", tag(), m_rxtx_word);
|
||||
|
||||
bool sync = false;
|
||||
switch (data & 0x18)
|
||||
{
|
||||
case UCR_START_STOP_0_0:
|
||||
m_rxtx_start = 0;
|
||||
m_rxtx_stop = 0;
|
||||
sync = true;
|
||||
if (LOG) logerror("MC68901 '%s' Start Bits : 0, Stop Bits : 0, Format : synchronous\n", tag());
|
||||
break;
|
||||
case UCR_START_STOP_1_1:
|
||||
@ -1292,7 +1297,7 @@ void mc68901_device::register_w(offs_t offset, UINT8 data)
|
||||
if (LOG) logerror("MC68901 '%s' Rx/Tx Clock Divisor : 1\n", tag());
|
||||
}
|
||||
|
||||
set_data_frame(m_rxtx_word, m_rxtx_stop, parity_code);
|
||||
set_data_frame(m_rxtx_word, m_rxtx_stop, parity_code, sync);
|
||||
|
||||
m_ucr = data;
|
||||
}
|
||||
@ -1434,21 +1439,3 @@ WRITE_LINE_MEMBER( mc68901_device::tbi_w )
|
||||
{
|
||||
timer_input(TIMER_B, state);
|
||||
}
|
||||
|
||||
|
||||
WRITE_LINE_MEMBER( mc68901_device::rc_w )
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
rcv_clock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WRITE_LINE_MEMBER( mc68901_device::tc_w )
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
tra_clock();
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +122,6 @@ public:
|
||||
DECLARE_WRITE_LINE_MEMBER( tai_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( tbi_w );
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER( rc_w );
|
||||
DECLARE_WRITE_LINE_MEMBER( tc_w );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
|
@ -292,7 +292,7 @@ microtouch_serial_device::microtouch_serial_device(const machine_config &mconfig
|
||||
void microtouch_serial_device::device_start()
|
||||
{
|
||||
microtouch_device::device_start();
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE); //8N1?
|
||||
set_data_frame(8, 1, PARITY_NONE, false); //8N1?
|
||||
set_tra_rate(clock());
|
||||
set_rcv_rate(clock());
|
||||
m_out_stx_func.resolve_safe();
|
||||
@ -302,6 +302,14 @@ void microtouch_serial_device::device_start()
|
||||
save_item(NAME(m_output));
|
||||
}
|
||||
|
||||
void microtouch_serial_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
if(id)
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
else
|
||||
microtouch_device::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
void microtouch_serial_device::tx(UINT8 data)
|
||||
{
|
||||
m_output = data;
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
DECLARE_WRITE_LINE_MEMBER(rx) { device_serial_interface::rx_w(state); }
|
||||
protected:
|
||||
virtual void device_start();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
virtual void tx(UINT8 data);
|
||||
virtual void input_callback(UINT8 state) { m_input_state = state; }
|
||||
virtual void tra_callback();
|
||||
|
@ -114,6 +114,12 @@ void mos6551_device::device_reset()
|
||||
}
|
||||
|
||||
|
||||
void mos6551_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// tra_callback -
|
||||
//-------------------------------------------------
|
||||
@ -223,7 +229,7 @@ void mos6551_device::update_serial()
|
||||
|
||||
int num_data_bits = 8;
|
||||
int stop_bit_count = 1;
|
||||
int parity_code = SERIAL_PARITY_NONE;
|
||||
int parity_code = PARITY_NONE;
|
||||
|
||||
switch (m_ctrl & CTRL_WL_MASK)
|
||||
{
|
||||
@ -233,22 +239,22 @@ void mos6551_device::update_serial()
|
||||
case CTRL_WL_5: num_data_bits = 5; break;
|
||||
}
|
||||
|
||||
set_data_frame(num_data_bits, stop_bit_count, parity_code);
|
||||
set_data_frame(num_data_bits, stop_bit_count, parity_code, false);
|
||||
}
|
||||
|
||||
if (m_cmd & CMD_DTR)
|
||||
m_connection_state |= SERIAL_STATE_DTR;
|
||||
m_connection_state |= DTR;
|
||||
else
|
||||
m_connection_state &= ~SERIAL_STATE_DTR;
|
||||
m_connection_state &= ~DTR;
|
||||
|
||||
m_write_dtr((m_connection_state & SERIAL_STATE_DTR) ? 0 : 1);
|
||||
m_write_dtr((m_connection_state & DTR) ? 0 : 1);
|
||||
|
||||
if ((m_cmd & CMD_TC_MASK) == CMD_TC_RTS_HI)
|
||||
m_connection_state &= ~SERIAL_STATE_RTS;
|
||||
m_connection_state &= ~RTS;
|
||||
else
|
||||
m_connection_state |= SERIAL_STATE_RTS;
|
||||
m_connection_state |= RTS;
|
||||
|
||||
m_write_rts((m_connection_state & SERIAL_STATE_RTS) ? 0 : 1);
|
||||
m_write_rts((m_connection_state & RTS) ? 0 : 1);
|
||||
|
||||
serial_connection_out();
|
||||
}
|
||||
@ -366,8 +372,8 @@ WRITE_LINE_MEMBER( mos6551_device::rxd_w )
|
||||
|
||||
WRITE_LINE_MEMBER( mos6551_device::rxc_w )
|
||||
{
|
||||
rcv_clock();
|
||||
tra_clock();
|
||||
rx_clock_w(state);
|
||||
tx_clock_w(state);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,6 +90,7 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// device_serial_interface overrides
|
||||
virtual void tra_callback();
|
||||
|
@ -533,6 +533,11 @@ void duart68681_channel::device_reset()
|
||||
CSR = 0;
|
||||
}
|
||||
|
||||
void duart68681_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
// serial device virtual overrides
|
||||
void duart68681_channel::rcv_complete()
|
||||
{
|
||||
@ -810,27 +815,27 @@ void duart68681_channel::recalc_framing()
|
||||
case 0: // with parity
|
||||
if (MR1 & 4)
|
||||
{
|
||||
parity = SERIAL_PARITY_ODD;
|
||||
parity = PARITY_ODD;
|
||||
}
|
||||
else
|
||||
{
|
||||
parity = SERIAL_PARITY_EVEN;
|
||||
parity = PARITY_EVEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // force parity
|
||||
if (MR1 & 4)
|
||||
{
|
||||
parity = SERIAL_PARITY_MARK;
|
||||
parity = PARITY_MARK;
|
||||
}
|
||||
else
|
||||
{
|
||||
parity = SERIAL_PARITY_SPACE;
|
||||
parity = PARITY_SPACE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // no parity
|
||||
parity = SERIAL_PARITY_NONE;
|
||||
parity = PARITY_NONE;
|
||||
break;
|
||||
|
||||
case 3: // multidrop mode
|
||||
@ -840,7 +845,7 @@ void duart68681_channel::recalc_framing()
|
||||
|
||||
//printf("ch %d MR1 %02x MR2 %02x => %d bits / char, %d stop bits, parity %d\n", m_ch, MR1, MR2, (MR1 & 3)+5, stopbits, parity);
|
||||
|
||||
set_data_frame((MR1 & 3)+5, stopbits, parity);
|
||||
set_data_frame((MR1 & 3)+5, stopbits, parity, false);
|
||||
}
|
||||
|
||||
void duart68681_channel::write_CR(UINT8 data)
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// device_serial overrides
|
||||
virtual void rcv_complete(); // Rx completed receiving byte
|
||||
|
@ -240,7 +240,6 @@ void z80dart_device::device_reset()
|
||||
m_chanB->reset();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// z80daisy_irq_state - get interrupt status
|
||||
//-------------------------------------------------
|
||||
@ -568,6 +567,11 @@ void z80dart_channel::device_reset()
|
||||
}
|
||||
}
|
||||
|
||||
void z80dart_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// tra_callback -
|
||||
@ -679,7 +683,7 @@ void z80dart_channel::input_callback(UINT8 state)
|
||||
|
||||
m_input_state = state;
|
||||
|
||||
if (changed & SERIAL_STATE_CTS)
|
||||
if (changed & CTS)
|
||||
{
|
||||
cts_w(state);
|
||||
}
|
||||
@ -1221,16 +1225,18 @@ WRITE_LINE_MEMBER( z80dart_channel::sync_w )
|
||||
|
||||
WRITE_LINE_MEMBER( z80dart_channel::rxc_w )
|
||||
{
|
||||
int clocks = get_clock_mode();
|
||||
|
||||
if (!state) return;
|
||||
|
||||
//LOG(("Z80DART \"%s\" Channel %c : Receiver Clock Pulse\n", m_owner->tag(), m_index + 'A'));
|
||||
|
||||
if (++m_rx_clock == clocks)
|
||||
int clocks = get_clock_mode();
|
||||
if (clocks == 1)
|
||||
rx_clock_w(state);
|
||||
else if(state)
|
||||
{
|
||||
m_rx_clock = 0;
|
||||
rcv_clock();
|
||||
rx_clock_w(m_rx_clock < clocks/2);
|
||||
|
||||
m_rx_clock++;
|
||||
if (m_rx_clock == clocks)
|
||||
m_rx_clock = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1241,16 +1247,18 @@ WRITE_LINE_MEMBER( z80dart_channel::rxc_w )
|
||||
|
||||
WRITE_LINE_MEMBER( z80dart_channel::txc_w )
|
||||
{
|
||||
int clocks = get_clock_mode();
|
||||
|
||||
if (!state) return;
|
||||
|
||||
//LOG(("Z80DART \"%s\" Channel %c : Transmitter Clock Pulse\n", m_owner->tag(), m_index + 'A'));
|
||||
|
||||
if (++m_tx_clock == clocks)
|
||||
int clocks = get_clock_mode();
|
||||
if (clocks == 1)
|
||||
tx_clock_w(state);
|
||||
else if(state)
|
||||
{
|
||||
m_tx_clock = 0;
|
||||
tra_clock();
|
||||
tx_clock_w(m_tx_clock < clocks/2);
|
||||
|
||||
m_tx_clock++;
|
||||
if (m_tx_clock == clocks)
|
||||
m_tx_clock = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1275,17 +1283,17 @@ void z80dart_channel::update_serial()
|
||||
|
||||
int num_data_bits = get_rx_word_length();
|
||||
int stop_bit_count = get_stop_bits();
|
||||
int parity_code = SERIAL_PARITY_NONE;
|
||||
int parity_code = PARITY_NONE;
|
||||
|
||||
if (m_wr[1] & WR4_PARITY_ENABLE)
|
||||
{
|
||||
if (m_wr[1] & WR4_PARITY_EVEN)
|
||||
parity_code = SERIAL_PARITY_EVEN;
|
||||
parity_code = PARITY_EVEN;
|
||||
else
|
||||
parity_code = SERIAL_PARITY_ODD;
|
||||
parity_code = PARITY_ODD;
|
||||
}
|
||||
|
||||
set_data_frame(num_data_bits, stop_bit_count, parity_code);
|
||||
set_data_frame(num_data_bits, stop_bit_count, parity_code, false);
|
||||
}
|
||||
|
||||
|
||||
@ -1300,9 +1308,9 @@ void z80dart_channel::set_dtr(int state)
|
||||
m_out_dtr_func(m_dtr);
|
||||
|
||||
if (state)
|
||||
m_connection_state &= ~SERIAL_STATE_DTR;
|
||||
m_connection_state &= ~DTR;
|
||||
else
|
||||
m_connection_state |= SERIAL_STATE_DTR;
|
||||
m_connection_state |= DTR;
|
||||
|
||||
serial_connection_out();
|
||||
}
|
||||
@ -1317,9 +1325,9 @@ void z80dart_channel::set_rts(int state)
|
||||
m_out_rts_func(state);
|
||||
|
||||
if (state)
|
||||
m_connection_state &= ~SERIAL_STATE_RTS;
|
||||
m_connection_state &= ~RTS;
|
||||
else
|
||||
m_connection_state |= SERIAL_STATE_RTS;
|
||||
m_connection_state |= RTS;
|
||||
|
||||
serial_connection_out();
|
||||
}
|
||||
|
@ -255,6 +255,7 @@ public:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// device_serial_interface overrides
|
||||
virtual void tra_callback();
|
||||
|
@ -742,7 +742,7 @@ WRITE_LINE_MEMBER( z80sti_device::i7_w ) { gpip_input(7, state); }
|
||||
|
||||
WRITE_LINE_MEMBER( z80sti_device::rc_w )
|
||||
{
|
||||
rcv_clock();
|
||||
rx_clock_w(state);
|
||||
}
|
||||
|
||||
|
||||
@ -752,5 +752,5 @@ WRITE_LINE_MEMBER( z80sti_device::rc_w )
|
||||
|
||||
WRITE_LINE_MEMBER( z80sti_device::tc_w )
|
||||
{
|
||||
tra_clock();
|
||||
tx_clock_w(state);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void midi_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, in
|
||||
|
||||
void midi_keyboard_device::device_start()
|
||||
{
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE); //8N1?
|
||||
set_data_frame(8, 1, PARITY_NONE, false); //8N1?
|
||||
set_tra_rate(clock());
|
||||
m_out_tx_func.resolve_safe();
|
||||
m_head = m_tail = 0;
|
||||
|
@ -1955,8 +1955,7 @@ READ8_MEMBER( st_state::mfp_gpio_r )
|
||||
|
||||
WRITE_LINE_MEMBER( st_state::mfp_tdo_w )
|
||||
{
|
||||
m_mfp->rc_w(state);
|
||||
m_mfp->tc_w(state);
|
||||
m_mfp->clock_w(state);
|
||||
}
|
||||
|
||||
static MC68901_INTERFACE( mfp_intf )
|
||||
|
@ -1378,7 +1378,7 @@ static const cassette_interface mc1502_cassette_interface =
|
||||
|
||||
static const serial_image_interface mc1502_serial =
|
||||
{
|
||||
9600, 8, 1, SERIAL_PARITY_NONE, 1, "upd8251"
|
||||
9600, 8, 1, device_serial_interface::PARITY_NONE, 1, "upd8251"
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_START( ibmpcjr, tandy_pc_state )
|
||||
|
@ -428,7 +428,7 @@ void rainbow_state::machine_reset()
|
||||
m_z80_halted = true;
|
||||
m_kbd_tx_ready = m_kbd_rx_ready = false;
|
||||
|
||||
m_kbd8251->input_callback(SERIAL_STATE_CTS); // raise clear to send
|
||||
m_kbd8251->input_callback(device_serial_interface::CTS); // raise clear to send
|
||||
|
||||
m_KBD = 0;
|
||||
|
||||
|
@ -604,17 +604,17 @@ const cassette_interface mo5_cassette_interface =
|
||||
|
||||
const serial_image_interface to7_cc90232_config =
|
||||
{
|
||||
2400, 7, 2, SERIAL_PARITY_NONE, 1, "to7_io"
|
||||
2400, 7, 2, device_serial_interface::PARITY_NONE, 1, "to7_io"
|
||||
};
|
||||
|
||||
const serial_image_interface to7_rf57932_config =
|
||||
{
|
||||
2400, 7, 2, SERIAL_PARITY_NONE, 1, "acia"
|
||||
2400, 7, 2, device_serial_interface::PARITY_NONE, 1, "acia"
|
||||
};
|
||||
|
||||
const serial_image_interface to7_modem_config =
|
||||
{
|
||||
2400, 7, 2, SERIAL_PARITY_NONE, 1, NULL
|
||||
2400, 7, 2, device_serial_interface::PARITY_NONE, 1, NULL
|
||||
};
|
||||
|
||||
/* ------------ driver ------------ */
|
||||
|
@ -2051,8 +2051,7 @@ ADDRESS_MAP_END
|
||||
|
||||
WRITE_LINE_MEMBER( x68k_state::mfp_tdo_w )
|
||||
{
|
||||
m_mfpdev->tc_w(state);
|
||||
m_mfpdev->rc_w(state);
|
||||
m_mfpdev->clock_w(state);
|
||||
}
|
||||
|
||||
static MC68901_INTERFACE( mfp_interface )
|
||||
|
@ -66,7 +66,7 @@ void esqpanel_device::device_reset()
|
||||
// panel comms is at 62500 baud (double the MIDI rate), 8N2
|
||||
set_rcv_rate(62500);
|
||||
set_tra_rate(62500);
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 2, PARITY_NONE, false);
|
||||
|
||||
m_tx_busy = false;
|
||||
m_xmit_read = m_xmit_write = 0;
|
||||
@ -74,6 +74,11 @@ void esqpanel_device::device_reset()
|
||||
m_bButtonLightSecondByte = false;
|
||||
}
|
||||
|
||||
void esqpanel_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
void esqpanel_device::rcv_complete() // Rx completed receiving byte
|
||||
{
|
||||
receive_register_extract();
|
||||
|
@ -71,6 +71,7 @@ protected:
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_config_complete();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
// serial overrides
|
||||
virtual void rcv_complete(); // Rx completed receiving byte
|
||||
|
@ -1284,9 +1284,8 @@ void sb_device::device_reset()
|
||||
m_rx_waiting = m_tx_waiting = 0;
|
||||
|
||||
// MIDI is 31250 baud, 8-N-1
|
||||
set_rcv_rate(31250);
|
||||
set_tra_rate(31250);
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_rate(31250);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
UINT8 sb_device::dack_r(int line)
|
||||
@ -1423,6 +1422,11 @@ void sb_device::dack_w(int line, UINT8 data)
|
||||
void sb_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
|
||||
{
|
||||
// printf("DMA timer expire\n");
|
||||
if (tid)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, tid, param, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT16 lsample, rsample;
|
||||
switch (m_dsp.flags) {
|
||||
|
@ -436,7 +436,7 @@ void serial_keyboard_device::device_start()
|
||||
m_slot = m_owner && 1;
|
||||
m_timer = timer_alloc();
|
||||
set_tra_rate(baud);
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
|
||||
@ -459,21 +459,29 @@ void serial_keyboard_device::device_reset()
|
||||
switch(val & 0x30)
|
||||
{
|
||||
case 0x10:
|
||||
set_data_frame(7, 1, SERIAL_PARITY_EVEN);
|
||||
set_data_frame(7, 1, PARITY_EVEN, false);
|
||||
break;
|
||||
case 0x00:
|
||||
default:
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
break;
|
||||
case 0x20:
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 2, PARITY_NONE, false);
|
||||
break;
|
||||
case 0x30:
|
||||
set_data_frame(8, 1, SERIAL_PARITY_EVEN);
|
||||
set_data_frame(8, 1, PARITY_EVEN, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void serial_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
if (id)
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
else
|
||||
generic_keyboard_device::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
|
||||
void serial_keyboard_device::send_key(UINT8 code)
|
||||
{
|
||||
if(is_transmit_register_empty())
|
||||
|
@ -94,6 +94,7 @@ protected:
|
||||
virtual void device_start();
|
||||
virtual void device_config_complete();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
virtual void tra_callback();
|
||||
virtual void tra_complete();
|
||||
virtual void input_callback(UINT8 state) { m_input_state = state; }
|
||||
|
@ -72,6 +72,12 @@ void serial_mouse_device::tra_callback()
|
||||
**************************************************************************/
|
||||
void serial_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
if (id)
|
||||
{
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
static int ox = 0, oy = 0;
|
||||
int nx,ny;
|
||||
int dx, dy, nb;
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
virtual void dtr_w(UINT8 state) { m_dtr = state; check_state(); }
|
||||
virtual void rts_w(UINT8 state) { m_rts = state; check_state(); m_old_rts = state; }
|
||||
protected:
|
||||
virtual void set_frame() { set_data_frame(7, 2, SERIAL_PARITY_NONE); }
|
||||
virtual void set_frame() { set_data_frame(7, 2, PARITY_NONE, false); }
|
||||
virtual void mouse_trans(int dx, int dy, int nb, int mbc);
|
||||
virtual void device_reset() {m_old_rts = 0; serial_mouse_device::device_reset();}
|
||||
private:
|
||||
@ -68,7 +68,7 @@ public:
|
||||
virtual void dtr_w(UINT8 state) { m_dtr = state; check_state(); }
|
||||
virtual void rts_w(UINT8 state) { m_rts = state; check_state(); }
|
||||
protected:
|
||||
virtual void set_frame() { set_data_frame(8, 2, SERIAL_PARITY_NONE); }
|
||||
virtual void set_frame() { set_data_frame(8, 2, PARITY_NONE, false); }
|
||||
virtual void mouse_trans(int dx, int dy, int nb, int mbc);
|
||||
private:
|
||||
void check_state() { set_mouse_enable((m_dtr && m_rts)?true:false); }
|
||||
|
@ -481,7 +481,7 @@ void serial_terminal_device::device_start()
|
||||
m_timer = timer_alloc();
|
||||
set_rcv_rate(baud);
|
||||
set_tra_rate(baud);
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
INPUT_CHANGED_MEMBER(serial_terminal_device::update_frame)
|
||||
@ -505,17 +505,17 @@ void serial_terminal_device::device_reset()
|
||||
switch(val & 0x30)
|
||||
{
|
||||
case 0x10:
|
||||
set_data_frame(7, 1, SERIAL_PARITY_EVEN);
|
||||
set_data_frame(7, 1, PARITY_EVEN, false);
|
||||
break;
|
||||
case 0x00:
|
||||
default:
|
||||
set_data_frame(8, 1, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 1, PARITY_NONE, false);
|
||||
break;
|
||||
case 0x20:
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 2, PARITY_NONE, false);
|
||||
break;
|
||||
case 0x30:
|
||||
set_data_frame(8, 1, SERIAL_PARITY_EVEN);
|
||||
set_data_frame(8, 1, PARITY_EVEN, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -686,9 +686,9 @@ WRITE8_MEMBER( to7_io_line_device::porta_out )
|
||||
|
||||
LOG_IO(( "%s %f to7_io_porta_out: tx=%i, dtr=%i\n", machine().describe_context(), machine().time().as_double(), tx, dtr ));
|
||||
if ( dtr )
|
||||
m_connection_state |= SERIAL_STATE_DTR;
|
||||
m_connection_state |= device_serial_interface::DTR;
|
||||
else
|
||||
m_connection_state &= ~SERIAL_STATE_DTR;
|
||||
m_connection_state &= ~device_serial_interface::DTR;
|
||||
|
||||
set_out_data_bit(tx);
|
||||
serial_connection_out();
|
||||
@ -700,11 +700,11 @@ READ8_MEMBER( to7_io_line_device::porta_in )
|
||||
{
|
||||
centronics_device *printer = machine().device<centronics_device>("centronics");
|
||||
int cts = 1;
|
||||
int dsr = ( m_input_state & SERIAL_STATE_DSR ) ? 0 : 1;
|
||||
int dsr = ( m_input_state & device_serial_interface::DSR ) ? 0 : 1;
|
||||
int rd = get_in_data_bit();
|
||||
|
||||
if ( machine().driver_data<thomson_state>()->to7_io_mode() == TO7_IO_RS232 )
|
||||
cts = m_input_state & SERIAL_STATE_CTS ? 0 : 1;
|
||||
cts = m_input_state & device_serial_interface::CTS ? 0 : 1;
|
||||
else
|
||||
cts = !printer->busy_r();
|
||||
|
||||
@ -738,7 +738,7 @@ void to7_io_line_device::input_callback(UINT8 state)
|
||||
{
|
||||
m_input_state = state;
|
||||
|
||||
LOG_IO(( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", machine().time().as_double(), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit() ));
|
||||
LOG_IO(( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", machine().time().as_double(), (state & device_serial_interface::CTS) ? 1 : 0, (state & device_serial_interface::DSR) ? 1 : 0, (int)get_in_data_bit() ));
|
||||
}
|
||||
|
||||
|
||||
@ -775,9 +775,9 @@ void to7_io_line_device::device_reset()
|
||||
LOG (( "to7_io_reset called\n" ));
|
||||
|
||||
if (io_pia) io_pia->set_port_a_z_mask(0x03 );
|
||||
m_input_state = SERIAL_STATE_CTS;
|
||||
m_connection_state &= ~SERIAL_STATE_DTR;
|
||||
m_connection_state |= SERIAL_STATE_RTS; /* always ready to send */
|
||||
m_input_state = device_serial_interface::CTS;
|
||||
m_connection_state &= ~device_serial_interface::DTR;
|
||||
m_connection_state |= device_serial_interface::RTS; /* always ready to send */
|
||||
set_out_data_bit(1);
|
||||
serial_connection_out();
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ void wangpc_keyboard_device::device_start()
|
||||
// set serial callbacks
|
||||
m_maincpu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(wangpc_keyboard_device, mcs51_tx_callback));
|
||||
m_maincpu->i8051_set_serial_rx_callback(READ8_DELEGATE(wangpc_keyboard_device, mcs51_rx_callback));
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 2, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
|
||||
@ -441,7 +441,7 @@ void wangpc_keyboard_device::device_reset()
|
||||
|
||||
void wangpc_keyboard_device::input_callback(UINT8 state)
|
||||
{
|
||||
int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
|
||||
int bit = (state & RX) ? 1 : 0;
|
||||
|
||||
receive_register_update_bit(bit);
|
||||
|
||||
|
@ -270,6 +270,10 @@ void zx8302_device::device_timer(emu_timer &timer, device_timer_id id, int param
|
||||
|
||||
transmit_ipc_data();
|
||||
break;
|
||||
|
||||
default:
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +406,7 @@ WRITE8_MEMBER( zx8302_device::control_w )
|
||||
m_baudx4_timer->adjust(attotime::zero, 0, attotime::from_hz(baudx4));
|
||||
|
||||
set_tra_rate(baud);
|
||||
set_data_frame(8, 2, SERIAL_PARITY_NONE);
|
||||
set_data_frame(8, 2, PARITY_NONE, false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user