diserial: Added framing error detection. [Curt Coder]

(MESS) compclr2: Floppy WIP. (nw)
This commit is contained in:
Curt Coder 2014-01-16 21:36:35 +00:00
parent 7b36dde8de
commit 6cb839c2c5
6 changed files with 71 additions and 34 deletions

View File

@ -19,6 +19,8 @@ device_serial_interface::device_serial_interface(const machine_config &mconfig,
m_rcv_register_data(0x8000),
m_rcv_flags(0),
m_rcv_bit_count(0),
m_rcv_framing_error(false),
m_rcv_parity_error(false),
m_tra_flags(TRANSMIT_REGISTER_EMPTY),
m_rcv_clock(NULL),
m_tra_clock(NULL),
@ -234,6 +236,8 @@ void device_serial_interface::receive_register_update_bit(int bit)
m_rcv_flags |=RECEIVE_REGISTER_SYNCHRONISED;
/* reset bit count received */
m_rcv_bit_count_received = 0;
m_rcv_framing_error = false;
m_rcv_parity_error = false;
}
}
}
@ -242,6 +246,11 @@ void device_serial_interface::receive_register_update_bit(int bit)
{
m_rcv_bit_count_received++;
if (!bit && (m_rcv_bit_count_received > (m_rcv_bit_count - m_df_stop_bit_count)))
{
m_rcv_framing_error = true;
}
/* received all bits? */
if (m_rcv_bit_count_received==m_rcv_bit_count)
{

View File

@ -116,6 +116,8 @@ protected:
bool is_transmit_register_empty();
bool is_receive_register_synchronized() { return m_rcv_flags & RECEIVE_REGISTER_SYNCHRONISED; }
bool is_receive_register_shifting() { return m_rcv_bit_count_received > 0; }
bool is_receive_framing_error() { return m_rcv_framing_error; }
bool is_receive_parity_error() { return m_rcv_parity_error; }
UINT8 get_received_char() { return m_rcv_byte_received; }
@ -167,6 +169,9 @@ private:
UINT8 m_rcv_bit_count;
/* the byte of data received */
UINT8 m_rcv_byte_received;
bool m_rcv_framing_error;
bool m_rcv_parity_error;
// Transmit register
/* data */

View File

@ -70,6 +70,7 @@ tms5501_device::tms5501_device(const machine_config &mconfig, const char *tag, d
m_rr(0),
m_tb(0),
m_mr(0),
m_rcv(1),
m_sens(0),
m_xi7(0)
{
@ -210,12 +211,21 @@ void tms5501_device::rcv_complete()
receive_register_extract();
m_rb = get_received_char();
if (is_receive_framing_error())
{
m_sta |= STA_FE;
}
else
{
m_sta &= ~STA_FE;
}
if (m_sta & STA_RBL)
{
m_sta |= STA_OE;
}
m_sta |= STA_RBL;
m_sta |= (STA_RBL | STA_SR);
m_sta &= ~(STA_SBD | STA_FBD);
set_interrupt(IRQ_RB);
@ -239,6 +249,9 @@ void tms5501_device::input_callback(UINT8 state)
READ8_MEMBER( tms5501_device::rb_r )
{
m_sta &= ~STA_RBL;
m_irq &= ~IRQ_RB;
check_interrupt();
return m_rb;
}
@ -277,7 +290,11 @@ READ8_MEMBER( tms5501_device::rst_r )
READ8_MEMBER( tms5501_device::sta_r )
{
return m_sta;
UINT8 data = m_sta;
m_sta &= ~STA_OE;
return data;
}
@ -404,6 +421,8 @@ WRITE8_MEMBER( tms5501_device::mr_w )
if (LOG) logerror("TMS5501 '%s' Mask Register %02x\n", tag(), data);
m_mr = data;
check_interrupt();
}
@ -429,24 +448,17 @@ WRITE_LINE_MEMBER( tms5501_device::rcv_w )
device_serial_interface::rx_w(state);
if (m_rcv)
{
m_sta |= STA_SR;
}
else
{
m_sta &= ~STA_SR;
}
if (is_receive_register_synchronized())
{
m_sta |= STA_SBD;
m_sta &= ~STA_SR;
}
if (is_receive_register_shifting())
{
m_sta |= STA_FBD;
}
//logerror("RCV %u SR %u SBD %u FBD %u FE %u OE %u\n",state,m_sta&STA_SR?1:0,m_sta&STA_SBD?1:0,m_sta&STA_FBD?1:0,m_sta&STA_FE?1:0,m_sta&STA_OE?1:0);
}

View File

@ -47,7 +47,7 @@ const char *ccvf_format::extensions() const
const ccvf_format::format ccvf_format::file_formats[] = {
{
floppy_image::FF_35, floppy_image::SSSD,
(1./(9600*8))*1000000000, 10, 41, 1, 128, {}, 0, {/* 0,5,1,6,2,7,3,8,4,9*/ }
(1./(9600*8))*1000000000, 10, 41, 1, 128, {}, 0, { 0,5,1,6,2,7,3,8,4,9 }
},
{}
};

View File

@ -225,7 +225,7 @@ static INPUT_PORTS_START( compucolor2 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("e E BSC RST") PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("u U INS LINE") PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("F5 Y BAR X")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("AUTO")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("AUTO") PORT_CODE(KEYCODE_PGDN)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("PRINT")
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
@ -336,29 +336,37 @@ READ8_MEMBER( compucolor2_state::xi_r )
{
UINT8 data = 0xff;
switch (m_xo & 0x0f)
switch ((m_xo >> 4) & 0x03)
{
case 0: data &= m_y0->read(); break;
case 1: data &= m_y1->read(); break;
case 2: data &= m_y2->read(); break;
case 3: data &= m_y3->read(); break;
case 4: data &= m_y4->read(); break;
case 5: data &= m_y5->read(); break;
case 6: data &= m_y6->read(); break;
case 7: data &= m_y7->read(); break;
case 8: data &= m_y8->read(); break;
case 9: data &= m_y9->read(); break;
case 10: data &= m_y10->read(); break;
case 11: data &= m_y11->read(); break;
case 12: data &= m_y12->read(); break;
case 13: data &= m_y13->read(); break;
case 14: data &= m_y14->read(); break;
case 15: data &= m_y15->read(); break;
}
case 0:
switch (m_xo & 0x0f)
{
case 0: data &= m_y0->read(); break;
case 1: data &= m_y1->read(); break;
case 2: data &= m_y2->read(); break;
case 3: data &= m_y3->read(); break;
case 4: data &= m_y4->read(); break;
case 5: data &= m_y5->read(); break;
case 6: data &= m_y6->read(); break;
case 7: data &= m_y7->read(); break;
case 8: data &= m_y8->read(); break;
case 9: data &= m_y9->read(); break;
case 10: data &= m_y10->read(); break;
case 11: data &= m_y11->read(); break;
case 12: data &= m_y12->read(); break;
case 13: data &= m_y13->read(); break;
case 14: data &= m_y14->read(); break;
case 15: data &= m_y15->read(); break;
}
if (BIT(m_xo, 7))
{
data = (m_y128->read() & 0xf0) | (data & 0x0f);
if (BIT(m_xo, 7))
{
data = (m_y128->read() & 0xf0) | (data & 0x0f);
}
break;
default:
data = 0;
}
return data;

View File

@ -101,6 +101,9 @@ compucolor_floppy_device::compucolor_floppy_device(const machine_config &mconfig
: device_t(mconfig, COMPUCOLOR_FLOPPY, "Compucolor floppy", tag, owner, clock, "compclr_flp", __FILE__),
device_compucolor_floppy_port_interface(mconfig, *this),
m_floppy(*this, "floppy:525sssd"),
m_rw(1),
m_stp(0),
m_sel(1),
m_period(attotime::from_hz(9600*8))
{
m_owner = dynamic_cast<compucolor_floppy_port_device *>(this->owner());