From: tmk Date: Tue, 12 May 2020 09:28:07 +0000 (+0900) Subject: ibmpc: Fix buffer full check X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=77c5017cb2bd0f5c8b9e5f2ca9748739ee1537cc;p=max%2Ftmk_keyboard.git ibmpc: Fix buffer full check recv_data should appear to as 'sstt' when it is full with two data. Both upper and lower byte should be checked. --- diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c index cb612eb1..282a4f82 100644 --- a/tmk_core/protocol/ibmpc.c +++ b/tmk_core/protocol/ibmpc.c @@ -229,6 +229,8 @@ void ibmpc_host_isr_clear(void) recv_data = 0xFFFF; } +#define LO8(w) (*((uint8_t *)&(w))) +#define HI8(w) (*(((uint8_t *)&(w))+1)) // NOTE: With this ISR data line can be read within 2us after clock falling edge. // To read data line early as possible: // write naked ISR with asembly code to read the line and call C func to do other job? @@ -379,7 +381,7 @@ DONE: ibmpc_error = IBMPC_ERR_FF; goto ERROR; } - if ((recv_data & 0xFF00) != 0xFF00) { + if (HI8(recv_data) != 0xFF && LO8(recv_data) != 0xFF) { // buffer full ibmpc_error = IBMPC_ERR_FULL; goto ERROR;