diserial: Actually check parity of received bytes in modes other than PARITY_NONE; fix transmission of parity bit in PARITY_EVEN mode

i8251: Flag parity and framing errors in status register
This commit is contained in:
AJR 2018-12-28 13:16:03 -05:00
parent 0d6f9037fd
commit 65bfb2654f
2 changed files with 29 additions and 33 deletions

View File

@ -145,6 +145,10 @@ void i8251_device::receive_clock()
if (is_receive_register_full())
{
receive_register_extract();
if (is_receive_parity_error())
m_status |= I8251_STATUS_PARITY_ERROR;
if (is_receive_framing_error())
m_status |= I8251_STATUS_FRAMING_ERROR;
receive_character(get_received_char());
}
}

View File

@ -308,40 +308,30 @@ void device_serial_interface::receive_register_extract()
if(m_df_parity == PARITY_NONE)
return;
//unsigned char computed_parity;
//unsigned char parity_received;
/* get state of parity bit received */
//parity_received = (m_rcv_register_data>>m_df_word length) & 0x01;
u8 parity_received = (m_rcv_register_data >> (16 - m_rcv_bit_count + m_df_word_length)) & 0x01;
/* parity enable? */
switch (m_df_parity)
{
/* check parity */
case PARITY_ODD:
case PARITY_EVEN:
{
/* compute parity for received bits */
//computed_parity = serial_helper_get_parity(data);
if (m_df_parity == PARITY_ODD)
{
/* odd parity */
}
else
{
/* even parity */
}
}
if (parity_received != serial_helper_get_parity(data))
m_rcv_parity_error = true;
break;
case PARITY_EVEN:
if (parity_received == serial_helper_get_parity(data))
m_rcv_parity_error = true;
break;
case PARITY_MARK:
if (!parity_received)
m_rcv_parity_error = true;
break;
case PARITY_SPACE:
//computed_parity = parity_received;
if (parity_received)
m_rcv_parity_error = true;
break;
}
}
@ -369,7 +359,7 @@ void device_serial_interface::transmit_register_add_bit(int bit)
void device_serial_interface::transmit_register_setup(u8 data_byte)
{
int i;
unsigned char transmit_data;
u8 transmit_data;
if(m_tra_clock && !m_tra_rate.is_never())
m_tra_clock->adjust(m_tra_rate, 0, m_tra_rate);
@ -401,10 +391,9 @@ void device_serial_interface::transmit_register_setup(u8 data_byte)
if (m_df_parity!=PARITY_NONE)
{
/* odd or even parity */
unsigned char parity = 0;
switch(m_df_parity)
u8 parity = 0;
switch (m_df_parity)
{
case PARITY_EVEN:
case PARITY_ODD:
/* get parity */
@ -412,6 +401,9 @@ void device_serial_interface::transmit_register_setup(u8 data_byte)
/* 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 PARITY_EVEN:
parity = serial_helper_get_parity(data_byte) ^ 1;
break;
case PARITY_MARK:
parity = 1;
break;