From: tmk Date: Sun, 1 Mar 2020 15:14:09 +0000 (+0900) Subject: ibmpc: Add timeout check X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=b7412f62288177a9f64871b1af71921c133b3f5d;p=max%2Ftmk_keyboard.git ibmpc: Add timeout check --- diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c index 65c44ab7..3606022d 100644 --- a/tmk_core/protocol/ibmpc.c +++ b/tmk_core/protocol/ibmpc.c @@ -69,6 +69,7 @@ volatile uint8_t ibmpc_error = IBMPC_ERR_NONE; static volatile uint16_t recv_data = 0xFFFF; /* internal state of receiving data */ static volatile uint16_t isr_state = 0x8000; +static uint8_t timer_start = 0; void ibmpc_host_init(void) { @@ -205,6 +206,25 @@ ISR(IBMPC_INT_VECT) { uint8_t dbit; dbit = IBMPC_DATA_PIN&(1<>1; if (dbit) isr_state |= 0x8000; @@ -270,6 +290,7 @@ 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; @@ -283,6 +304,7 @@ ISR(IBMPC_INT_VECT) case 0b11110000: default: // xxxx_oooo(any 1 in low nibble) // Illegal + ibmpc_error = IBMPC_ERR_ILLEGAL; goto ERROR; break; } @@ -290,7 +312,6 @@ ISR(IBMPC_INT_VECT) ERROR: isr_state = 0x8000; recv_data = 0xFF00; // clear data and scancode of error 0x00 - ibmpc_error = 0xFF; return; DONE: // TODO: process error code: 0x00(AT), 0xFF(XT) in particular diff --git a/tmk_core/protocol/ibmpc.h b/tmk_core/protocol/ibmpc.h index fc117f23..18da8f4c 100644 --- a/tmk_core/protocol/ibmpc.h +++ b/tmk_core/protocol/ibmpc.h @@ -79,6 +79,7 @@ POSSIBILITY OF SUCH DAMAGE. #define IBMPC_ERR_SEND 0x10 #define IBMPC_ERR_TIMEOUT 0x20 #define IBMPC_ERR_FULL 0x40 +#define IBMPC_ERR_ILLEGAL 0x80 #define IBMPC_LED_SCROLL_LOCK 0 #define IBMPC_LED_NUM_LOCK 1