diff options
Diffstat (limited to 'src/devices/machine/ay31015.cpp')
-rw-r--r-- | src/devices/machine/ay31015.cpp | 101 |
1 files changed, 38 insertions, 63 deletions
diff --git a/src/devices/machine/ay31015.cpp b/src/devices/machine/ay31015.cpp index 6ab1103b28a..732470d1b9f 100644 --- a/src/devices/machine/ay31015.cpp +++ b/src/devices/machine/ay31015.cpp @@ -104,8 +104,8 @@ Start bit (low), Bit 0, Bit 1... highest bit, Parity bit (if enabled), 1-2 stop DEFINE_DEVICE_TYPE(AY31015, ay31015_device, "ay31015", "AY-3-1015 UART") DEFINE_DEVICE_TYPE(AY51013, ay51013_device, "ay51013", "AY-5-1013 UART") -ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), +ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, type, tag, owner, clock), m_control_reg(0), m_status_reg(0), m_second_stop_bit(0), @@ -120,7 +120,7 @@ ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, m_tx_buffer(0), m_tx_parity(0), m_tx_pulses(0), - m_read_si_cb(*this), + m_read_si_cb(*this, 0), m_write_so_cb(*this), m_write_pe_cb(*this), m_write_fe_cb(*this), @@ -145,25 +145,6 @@ ay51013_device::ay51013_device(const machine_config &mconfig, const char *tag, d } //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void ay31015_device::device_resolve_objects() -{ - m_read_si_cb.resolve(); - m_write_so_cb.resolve(); - - m_write_tbmt_cb.resolve(); - m_write_dav_cb.resolve(); - m_write_or_cb.resolve(); - m_write_fe_cb.resolve(); - m_write_pe_cb.resolve(); - m_write_eoc_cb.resolve(); -} - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -208,7 +189,7 @@ void ay31015_device::device_reset() inline uint8_t ay31015_device::get_si() { - if (!m_read_si_cb.isnull()) + if (!m_read_si_cb.isunset()) m_pins[SI] = m_read_si_cb(); return m_pins[SI]; @@ -218,9 +199,7 @@ inline uint8_t ay31015_device::get_si() inline void ay31015_device::set_so( int data ) { m_pins[SO] = data ? 1 : 0; - - if (!m_write_so_cb.isnull()) - m_write_so_cb(m_pins[SO]); + m_write_so_cb(m_pins[SO]); } @@ -231,14 +210,13 @@ inline void ay31015_device::update_status_pin(uint8_t reg_bit, ay31015_device::o if (new_value != m_pins[pin]) { m_pins[pin] = new_value; - if (!write_cb.isnull()) - write_cb(new_value); + write_cb(new_value); } } /*------------------------------------------------- - ay31015_update_status_pins - Update the status pins + update_status_pins - Update the status pins -------------------------------------------------*/ void ay31015_device::update_status_pins() @@ -260,7 +238,7 @@ void ay31015_device::update_status_pins() /*------------------------------------------------- - ay31015_rx_process - convert serial to parallel + rx_process - convert serial to parallel -------------------------------------------------*/ void ay31015_device::rx_process() @@ -336,7 +314,9 @@ void ay31015_device::rx_process() if (m_rx_pulses == 8) // sample input stream { - m_rx_parity ^= get_si(); // calculate cumulative parity + m_internal_sample = get_si(); + m_rx_parity ^= m_internal_sample; // calculate cumulative parity + LOG("Receive parity bit: %d\n", m_internal_sample); } else if (!m_rx_pulses) // end of a byte @@ -350,7 +330,10 @@ void ay31015_device::rx_process() if ((m_control_reg & CONTROL_EPS) && (!m_rx_parity)) m_rx_parity = 0; // even parity, ok else + { m_rx_parity = 1; // parity error + LOG("Parity error\n"); + } } return; @@ -423,7 +406,7 @@ void ay31015_device::rx_process() /*------------------------------------------------- - ay31015_tx_process - convert parallel to serial + tx_process - convert parallel to serial -------------------------------------------------*/ void ay31015_device::tx_process() @@ -478,7 +461,7 @@ void ay31015_device::tx_process() } else set_so(0); - LOG("Transmit data bit #%d: %d\n", 9 - (m_tx_pulses >> 4), m_tx_data & 1); + LOG("Transmit data bit #%d: %d\n", 1 + ((m_total_pulses - m_tx_pulses) >> 4), m_tx_data & 1); m_tx_data >>= 1; // adjust the shift register } @@ -524,25 +507,26 @@ void ay31015_device::tx_process() m_tx_pulses--; if (!m_tx_pulses) { - m_status_reg |= STATUS_EOC; // character is completely sent if (m_second_stop_bit) { m_tx_state = SECOND_STOP_BIT; m_tx_pulses = m_second_stop_bit; - LOG("Transmit second stop bit\n"); - } - else - if (m_status_reg & STATUS_TBMT) - { - m_tx_state = IDLE; // if nothing to send, go idle - LOG("Transmitter idle\n"); } else { - m_tx_pulses = 16; - m_tx_state = START_BIT; // otherwise immediately start next byte + m_status_reg |= STATUS_EOC; // character is completely sent + if (m_status_reg & STATUS_TBMT) + { + m_tx_state = IDLE; // if nothing to send, go idle + LOG("Transmitter idle\n"); + } + else + { + m_tx_pulses = 16; + m_tx_state = START_BIT; // otherwise immediately start next byte + } + update_status_pins(); } - update_status_pins(); } return; @@ -552,6 +536,7 @@ void ay31015_device::tx_process() m_tx_pulses--; if (!m_tx_pulses) { + m_status_reg |= STATUS_EOC; // character is completely sent if (m_status_reg & STATUS_TBMT) { m_tx_state = IDLE; // if nothing to send, go idle @@ -562,6 +547,7 @@ void ay31015_device::tx_process() m_tx_pulses = 16; m_tx_state = START_BIT; // otherwise immediately start next byte } + update_status_pins(); } return; @@ -570,7 +556,7 @@ void ay31015_device::tx_process() /*------------------------------------------------- - ay31015_reset - reset internal state + internal_reset - reset internal state -------------------------------------------------*/ void ay31015_device::internal_reset() @@ -626,7 +612,7 @@ void ay51013_device::internal_reset() } /*------------------------------------------------- - ay31015_transfer_control_pins - transfers contents of controls pins to the control register + transfer_control_pins - transfers contents of controls pins to the control register -------------------------------------------------*/ void ay31015_device::transfer_control_pins() @@ -648,7 +634,7 @@ void ay31015_device::transfer_control_pins() /*------------------------------------------------- - ay31015_set_input_pin - set an input pin + set_input_pin - set an input pin -------------------------------------------------*/ void ay31015_device::set_input_pin( ay31015_device::input_pin pin, int data ) { @@ -701,7 +687,7 @@ void ay31015_device::set_input_pin( ay31015_device::input_pin pin, int data ) /*------------------------------------------------- - ay31015_get_output_pin - get the status of an output pin + get_output_pin - get the status of an output pin -------------------------------------------------*/ int ay31015_device::get_output_pin( ay31015_device::output_pin pin ) @@ -711,10 +697,10 @@ int ay31015_device::get_output_pin( ay31015_device::output_pin pin ) /*------------------------------------------------- - ay31015_get_received_data - return a byte to the computer + received - return a byte to the computer -------------------------------------------------*/ -uint8_t ay31015_device::get_received_data() +uint8_t ay31015_device::receive() { if (m_auto_rdav && !machine().side_effects_disabled()) { @@ -725,16 +711,10 @@ uint8_t ay31015_device::get_received_data() return m_rx_buffer; } -READ8_MEMBER(ay31015_device::receive) -{ - return get_received_data(); -} - - /*------------------------------------------------- - ay31015_set_transmit_data - accept a byte to transmit, if able + transmit - accept a byte to transmit, if able -------------------------------------------------*/ -void ay31015_device::set_transmit_data( uint8_t data ) +void ay31015_device::transmit( uint8_t data ) { if (m_status_reg & STATUS_TBMT) { @@ -743,8 +723,3 @@ void ay31015_device::set_transmit_data( uint8_t data ) update_status_pins(); } } - -WRITE8_MEMBER(ay31015_device::transmit) -{ - set_transmit_data(data); -} |