From 0a1dcacbfded8ab5f0468d6eeed40b334e09d656 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 5 Feb 2021 23:46:18 +0900 Subject: [PATCH] ibmpc: Fix ACK check in host_send() for Z-150 AT #661 Zenith Z-150 AT doesn't seems to place ACK signaling normally. https://github.com/tmk/tmk_keyboard/issues/661#issue-743168434 https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#zenith-z-150-beige IBM genuine PC host checks data line only, not clock on ACK. In this case Z-150 AT ACK signaling can be handled. http://www.halicery.com/Hardware/Intel%208042%20and%208048/8042_PS2_INTERN.TEXT (026C:) http://halicery.com/8042/8042_1503033.TXT (0274:) Place 'inhibit' on lines for long enough to cancel current state and recovery from ERROR but not sure this really helps. --- tmk_core/protocol/ibmpc.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c index 0e94e301..73439c62 100644 --- a/tmk_core/protocol/ibmpc.c +++ b/tmk_core/protocol/ibmpc.c @@ -135,18 +135,12 @@ int16_t ibmpc_host_send(uint8_t data) /* Stop bit */ wait_us(15); data_hi(); - WAIT(clock_hi, 50, 6); - if (ibmpc_protocol == IBMPC_PROTOCOL_AT_Z150) { goto RECV; } - WAIT(clock_lo, 50, 7); /* Ack */ - WAIT(data_lo, 50, 8); + WAIT(data_lo, 300, 6); + WAIT(data_hi, 300, 7); + WAIT(clock_hi, 300, 8); - /* wait for idle state */ - WAIT(clock_hi, 50, 9); - WAIT(data_hi, 50, 10); - -RECV: // clear buffer to get response correctly recv_data = 0xFFFF; ibmpc_host_isr_clear(); @@ -156,6 +150,8 @@ RECV: return ibmpc_host_recv_response(); ERROR: ibmpc_error |= IBMPC_ERR_SEND; + inhibit(); + wait_ms(2); idle(); IBMPC_INT_ON(); return -1;