diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 12:42:30 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 12:42:30 -0400 |
commit | 547da78335298df6666200c6063ac6f1aba312fd (patch) | |
tree | 47df0252ee24b1ecc27b9dd0458c51f20bf088c3 /converter/ibm4704_usb/matrix.c | |
parent | a766918d5c48204375f4c207b30bbbf1389df14f (diff) | |
parent | fa33719adab1393753312d298b8c365e04e844b9 (diff) | |
download | qmk_firmware-547da78335298df6666200c6063ac6f1aba312fd.tar.gz qmk_firmware-547da78335298df6666200c6063ac6f1aba312fd.zip |
merging tmk
Diffstat (limited to 'converter/ibm4704_usb/matrix.c')
-rw-r--r-- | converter/ibm4704_usb/matrix.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c index 0bfda2b158..5b91d49f81 100644 --- a/converter/ibm4704_usb/matrix.c +++ b/converter/ibm4704_usb/matrix.c @@ -67,43 +67,33 @@ uint8_t matrix_cols(void) static void enable_break(void) { - uint8_t ret; print("Enable break: "); - // valid scancode: 00-77h - for (uint8_t code = 0; code < 0x78; code++) { - while (ibm4704_send(0x80|code) != 0) { - print("z"); - _delay_us(500); - } - _delay_us(2000); - ret = ibm4704_recv(); - if (ret != 0xff) { - xprintf("c%02X:r%02X ", code, ret); - } - _delay_us(1000); + while (ibm4704_send(0xFC)) { _delay_ms(10); } + // valid scancode: 00-79h + for (uint8_t code = 0; code < 0x7F; code++) { + while (ibm4704_send(0x80|code)) _delay_ms(10); + _delay_ms(5); // wait for response + // No response(FF) when ok, FD when out of bound + xprintf("s%02X:r%02X ", code, ibm4704_recv()); } - _delay_us(1000); - while (ibm4704_send(0xFF) != 0) { _delay_us(500); } // End + while (ibm4704_send(0xFF)) { _delay_ms(10); } // End print("End\n"); } -void matrix_init(void) -{ - uint8_t ret; - debug_enable = true; +void matrix_setup(void) +{ ibm4704_init(); - matrix_clear(); +} - // read keyboard id - while ((ret = ibm4704_recv()) == 0xFF) { - ibm4704_send(0xFE); - _delay_us(100); - } +void matrix_init(void) +{ + debug_enable = true; - _delay_ms(2000); // wait for starting up debug console print("IBM 4704 converter\n"); - xprintf("Keyboard ID: %02X\n", ret); + matrix_clear(); + _delay_ms(2000); // wait for keyboard starting up + xprintf("Keyboard ID: %02X\n", ibm4704_recv()); enable_break(); } @@ -116,14 +106,16 @@ uint8_t matrix_scan(void) if (code==0xFF) { // Not receivd return 0; - } else if ((code&0x78)==0x78) { - // 0xFF-F8 and 0x7F-78 is not scancode - xprintf("Error: %0X\n", code); + } else if ((code&0x7F) >= 0x7A) { + // 0xFF-FA and 0x7F-7A is not scancode + xprintf("Error: %02X\n", code); matrix_clear(); return 0; } else if (code&0x80) { + dprintf("%02X\n", code); matrix_make(code); } else { + dprintf("%02X\n", code); matrix_break(code); } return 1; |