ibmpc: Revert 2a0471fd on ibmpc_host_send()
Restoring old recv_data can overwrite response data when the response is multi-byte. This can happen when device responds with multiple bytes quickly, for example Logitech MX518(PS/2) sends FA 00 in short period to F2 command while most of devices doesn't send second byte that fast. recv_data is cleared when calling ibmpc_host_send() you will have to retain the data yourself before calling it. Or you have to make sure that recv_data is empty as possible before calling the function. Alternatively, ibmpc_host_send() can be changed to check if recv_data is empty before seding command.
This commit is contained in:
parent
4ed3e40fc0
commit
22b6e87f37
1 changed files with 1 additions and 8 deletions
|
|
@ -153,19 +153,12 @@ RETRY:
|
||||||
WAIT(data_hi, 300, 7);
|
WAIT(data_hi, 300, 7);
|
||||||
WAIT(clock_hi, 300, 8);
|
WAIT(clock_hi, 300, 8);
|
||||||
|
|
||||||
uint16_t d = recv_data;
|
|
||||||
|
|
||||||
// clear buffer to get response correctly
|
// clear buffer to get response correctly
|
||||||
ibmpc_host_isr_clear();
|
ibmpc_host_isr_clear();
|
||||||
|
|
||||||
idle();
|
idle();
|
||||||
IBMPC_INT_ON();
|
IBMPC_INT_ON();
|
||||||
int16_t r = ibmpc_host_recv_response();
|
return ibmpc_host_recv_response();
|
||||||
if (d != 0xFFFF) dprintf("r:%04X ", d);
|
|
||||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
|
||||||
recv_data = d;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
ERROR:
|
ERROR:
|
||||||
// Retry for Z-150 AT start bit error
|
// Retry for Z-150 AT start bit error
|
||||||
if (ibmpc_error == 1 && retry++ < 10) {
|
if (ibmpc_error == 1 && retry++ < 10) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue