]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
ibmpc: Check buffer full and error code FF
authortmk <hasu@tmk-kbd.com>
Sun, 1 Mar 2020 16:48:11 +0000 (01:48 +0900)
committertmk <hasu@tmk-kbd.com>
Sun, 1 Mar 2020 16:48:11 +0000 (01:48 +0900)
tmk_core/protocol/ibmpc.c
tmk_core/protocol/ibmpc.h

index 9553e7ee1cfee3ae385bfad463bddafe99c4c362..8e195e9484b7bd916fdd98c7d80a2bda2d02e59d 100644 (file)
@@ -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;
index 18da8f4cbd1ea3fed6387487ffd7a52247c22e33..602a43f359dba842b6d1f531cdb969fb7b5bfcf3 100644 (file)
@@ -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