From 0481aa08e5a22173f1e4a5a5f8ba01756085b9d3 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 2 Mar 2020 01:48:11 +0900 Subject: [PATCH] ibmpc: Check buffer full and error code FF --- tmk_core/protocol/ibmpc.c | 22 ++++++++++++++-------- tmk_core/protocol/ibmpc.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c index 9553e7ee..8e195e94 100644 --- a/tmk_core/protocol/ibmpc.c +++ b/tmk_core/protocol/ibmpc.c @@ -268,8 +268,7 @@ ISR(IBMPC_INT_VECT) break; case 0b11000000: // XT_Clone-done - recv_data = recv_data<<8; - recv_data |= (isr_state>>8) & 0xFF; + isr_state = isr_state>>8; goto DONE; break; case 0b10100000: // ^2 @@ -284,8 +283,7 @@ ISR(IBMPC_INT_VECT) goto NEXT; } else { // no stop bit: XT_IBM-done - recv_data = recv_data<<8; - recv_data |= (isr_state>>8) & 0xFF; + isr_state = isr_state>>8; goto DONE; } } @@ -294,10 +292,9 @@ ISR(IBMPC_INT_VECT) case 0b10010000: case 0b01010000: case 0b11010000: - // TODO: parity check? // AT-done - recv_data = recv_data<<8; - recv_data |= (isr_state>>6) & 0xFF; + // TODO: parity check? + isr_state = isr_state>>6; goto DONE; break; case 0b01100000: @@ -318,7 +315,16 @@ ERROR: recv_data = 0xFF00; // clear data and scancode of error 0x00 return; DONE: - // TODO: process error code: 0x00(AT), 0xFF(XT) in particular + if ((isr_state & 0x00FF) == 0x00FF) { + // receive error code 0xFF + ibmpc_error = IBMPC_ERR_FF; + } + if ((recv_data & 0xFF00) != 0xFF00) { + // buffer full and overwritten + ibmpc_error = IBMPC_ERR_FULL; + } + recv_data = recv_data<<8; + recv_data |= isr_state & 0xFF; isr_state = 0x8000; // clear to next data NEXT: return; diff --git a/tmk_core/protocol/ibmpc.h b/tmk_core/protocol/ibmpc.h index 18da8f4c..602a43f3 100644 --- a/tmk_core/protocol/ibmpc.h +++ b/tmk_core/protocol/ibmpc.h @@ -80,6 +80,7 @@ POSSIBILITY OF SUCH DAMAGE. #define IBMPC_ERR_TIMEOUT 0x20 #define IBMPC_ERR_FULL 0x40 #define IBMPC_ERR_ILLEGAL 0x80 +#define IBMPC_ERR_FF 0xFF #define IBMPC_LED_SCROLL_LOCK 0 #define IBMPC_LED_NUM_LOCK 1 -- 2.46.2