summaryrefslogtreecommitdiff
path: root/converter/ibm4704_usb
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-10-27 21:39:02 +0900
committerJun Wako <wakojun@gmail.com>2015-04-22 14:18:13 +0900
commitd42aa47809c97a77c49e9396201c2b5c3956bb54 (patch)
tree07331fbb4b67630a5571f31af071021fbc9eb160 /converter/ibm4704_usb
parent5ea50bfb30fa9917f6c1209a7ae7f31b7e7b4095 (diff)
Fix ibm4704 protocol with using interrupt
Diffstat (limited to 'converter/ibm4704_usb')
-rw-r--r--converter/ibm4704_usb/config.h2
-rw-r--r--converter/ibm4704_usb/matrix.c41
2 files changed, 18 insertions, 25 deletions
diff --git a/converter/ibm4704_usb/config.h b/converter/ibm4704_usb/config.h
index 4f82f49ad3..812d95c670 100644
--- a/converter/ibm4704_usb/config.h
+++ b/converter/ibm4704_usb/config.h
@@ -56,7 +56,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* Pin interrupt
*/
-#ifdef IBM4704_USE_INT
#define IBM4704_INT_INIT() do { \
EICRA |= ((1<<ISC11) | \
(0<<ISC10)); \
@@ -68,7 +67,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
EIMSK &= ~(1<<INT1); \
} while (0)
#define IBM4704_INT_VECT INT1_vect
-#endif
#endif
diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c
index 0bfda2b158..857dea0f91 100644
--- a/converter/ibm4704_usb/matrix.c
+++ b/converter/ibm4704_usb/matrix.c
@@ -69,41 +69,34 @@ 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) {
+ // valid scancode: 00-79h
+ for (uint8_t code = 0; code < 0x7A; code++) {
+ while (ibm4704_send(0x80|code)) _delay_ms(1);
+ // get none when ok, get FD when out of bound
+ _delay_ms(5);
+ if ((ret = ibm4704_recv()) != 0xff) {
xprintf("c%02X:r%02X ", code, ret);
}
- _delay_us(1000);
+ _delay_ms(1);
}
_delay_us(1000);
- while (ibm4704_send(0xFF) != 0) { _delay_us(500); } // End
+ while (ibm4704_send(0xFF)) { _delay_ms(1); } // End
print("End\n");
}
void matrix_init(void)
{
- uint8_t ret;
- debug_enable = true;
+ debug_enable = false;
ibm4704_init();
matrix_clear();
- // read keyboard id
- while ((ret = ibm4704_recv()) == 0xFF) {
- ibm4704_send(0xFE);
- _delay_us(100);
- }
+ _delay_ms(2000); // wait for starting up debug console
- _delay_ms(2000); // wait for starting up debug console
print("IBM 4704 converter\n");
- xprintf("Keyboard ID: %02X\n", ret);
+ while (ibm4704_send(0xFE)) _delay_ms(1); // resend
+ _delay_ms(5);
+ xprintf("Keyboard ID: %02X\n", ibm4704_recv());
enable_break();
}
@@ -116,14 +109,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;