ibmpc: Retry for start bit error of Z-150 AT #661

This is fix for Zenith Z-150 AT. Root cause is still
not clear but retrying works well somehow.
https://github.com/tmk/tmk_keyboard/issues/661#issuecomment-772298392

Add checking isr_state and line state before sending data
This commit is contained in:
tmk 2021-05-09 23:33:07 +09:00
parent 0a1dcacbfd
commit 67d37ef7b3

View file

@ -98,18 +98,30 @@ int16_t ibmpc_host_send(uint8_t data)
{
bool parity = true;
ibmpc_error = IBMPC_ERR_NONE;
uint8_t retry = 0;
dprintf("w%02X ", data);
// Not receiving data
if (isr_state != 0x8000) dprintf("isr:%04X ", isr_state);
while (isr_state != 0x8000) ;
// Not clock Lo
if (!clock_in()) dprintf("c:%u ", wait_clock_hi(1000));
// Not data Lo
if (!data_in()) dprintf("d:%u ", wait_data_hi(1000));
IBMPC_INT_OFF();
RETRY:
/* terminate a transmission if we have */
inhibit();
wait_us(100); // [5]p.54
wait_us(200); // [5]p.54
/* 'Request to Send' and Start bit */
data_lo();
wait_us(100);
wait_us(200);
clock_hi(); // [5]p.54 [clock low]>100us [5]p.50
WAIT(clock_lo, 10000, 1); // [5]p.53, -10ms [5]p.50
@ -149,6 +161,13 @@ int16_t ibmpc_host_send(uint8_t data)
IBMPC_INT_ON();
return ibmpc_host_recv_response();
ERROR:
// Retry for Z-150 AT start bit error
if (ibmpc_error == 1 && retry++ < 10) {
ibmpc_error = IBMPC_ERR_NONE;
dprintf("R ");
goto RETRY;
}
ibmpc_error |= IBMPC_ERR_SEND;
inhibit();
wait_ms(2);