Skip to content

Commit 67d37ef

Browse files
committed
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. #661 (comment) Add checking isr_state and line state before sending data
1 parent 0a1dcac commit 67d37ef

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tmk_core/protocol/ibmpc.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,30 @@ int16_t ibmpc_host_send(uint8_t data)
9898
{
9999
bool parity = true;
100100
ibmpc_error = IBMPC_ERR_NONE;
101+
uint8_t retry = 0;
101102

102103
dprintf("w%02X ", data);
103104

105+
// Not receiving data
106+
if (isr_state != 0x8000) dprintf("isr:%04X ", isr_state);
107+
while (isr_state != 0x8000) ;
108+
109+
// Not clock Lo
110+
if (!clock_in()) dprintf("c:%u ", wait_clock_hi(1000));
111+
112+
// Not data Lo
113+
if (!data_in()) dprintf("d:%u ", wait_data_hi(1000));
114+
104115
IBMPC_INT_OFF();
105116

117+
RETRY:
106118
/* terminate a transmission if we have */
107119
inhibit();
108-
wait_us(100); // [5]p.54
120+
wait_us(200); // [5]p.54
109121

110122
/* 'Request to Send' and Start bit */
111123
data_lo();
112-
wait_us(100);
124+
wait_us(200);
113125
clock_hi(); // [5]p.54 [clock low]>100us [5]p.50
114126
WAIT(clock_lo, 10000, 1); // [5]p.53, -10ms [5]p.50
115127

@@ -149,6 +161,13 @@ int16_t ibmpc_host_send(uint8_t data)
149161
IBMPC_INT_ON();
150162
return ibmpc_host_recv_response();
151163
ERROR:
164+
// Retry for Z-150 AT start bit error
165+
if (ibmpc_error == 1 && retry++ < 10) {
166+
ibmpc_error = IBMPC_ERR_NONE;
167+
dprintf("R ");
168+
goto RETRY;
169+
}
170+
152171
ibmpc_error |= IBMPC_ERR_SEND;
153172
inhibit();
154173
wait_ms(2);

0 commit comments

Comments
 (0)