mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
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:
parent
0d6f9037fd
commit
65bfb2654f
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -308,41 +308,31 @@ 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 */
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
case PARITY_ODD:
|
||||
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:
|
||||
if (parity_received)
|
||||
m_rcv_parity_error = true;
|
||||
break;
|
||||
case PARITY_MARK:
|
||||
case PARITY_SPACE:
|
||||
//computed_parity = parity_received;
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user