diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 14:52:18 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 14:52:18 -0400 |
commit | d311fd8d1a0af3b767d26b520d399bf0db22f058 (patch) | |
tree | b9de5704143ac205b4e26222f9d7551e9b161924 /converter/ibm4704_usb/matrix.c | |
parent | a766918d5c48204375f4c207b30bbbf1389df14f (diff) | |
parent | 6f3141965e88c4ee0ebf7c18a243e4c2d9c5021b (diff) |
Merge pull request #34 from jackhumbert/tmk-master
merging from tmk, new_project script and template
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; |