From 49b0c7e5ef1683f001c4c9e1c7516da8c5fe592e Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 3 Jun 2015 00:03:08 +0900 Subject: sun_usb: Fix LED status update at startup --- converter/sun_usb/matrix.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'converter/sun_usb/matrix.c') diff --git a/converter/sun_usb/matrix.c b/converter/sun_usb/matrix.c index f333f542bd..71c818f5ab 100644 --- a/converter/sun_usb/matrix.c +++ b/converter/sun_usb/matrix.c @@ -72,6 +72,21 @@ void matrix_init(void) // initialize matrix state: all keys off for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + // wait for keyboard coming up + // otherwise LED status update fails + print("Reseting "); + while (1) { + print("."); + while (serial_recv()); + serial_send(0x01); + _delay_ms(500); + if (serial_recv() == 0xFF) { + _delay_ms(500); + if (serial_recv() == 0x04) + break; + } + } + print(" Done\n"); return; } -- cgit v1.2.3 From a55160887322c5498f6a9b01bcc2e137e5e6cd51 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 3 Jun 2015 00:49:55 +0900 Subject: sun_usb: LED update for hotplug keyboard into converter --- converter/sun_usb/matrix.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'converter/sun_usb/matrix.c') diff --git a/converter/sun_usb/matrix.c b/converter/sun_usb/matrix.c index 71c818f5ab..3126bd33ca 100644 --- a/converter/sun_usb/matrix.c +++ b/converter/sun_usb/matrix.c @@ -101,17 +101,26 @@ uint8_t matrix_scan(void) debug_hex(code); debug(" "); switch (code) { - case 0xFF: // reset success - case 0xFE: // layout - case 0x7E: // reset fail - if (code == 0xFF) print("reset: 0xFF "); - if (code == 0x7E) print("reset fail: 0x7E "); - if (code == 0xFE) print("layout: 0xFE "); - // response byte + case 0xFF: // reset success: FF 04 + print("reset: "); _delay_ms(500); - if (code = serial_recv()) print_hex8(code); - print("\n"); - // FALL THROUGH + code = serial_recv(); + xprintf("%02X\n", code); + if (code == 0x04) { + // LED status + led_set(host_keyboard_leds()); + } + return 0; + case 0xFE: // layout: FE + print("layout: "); + _delay_ms(500); + xprintf("%02X\n", serial_recv()); + return 0; + case 0x7E: // reset fail: 7E 01 + print("reset fail: "); + _delay_ms(500); + xprintf("%02X\n", serial_recv()); + return 0; case 0x7F: // all keys up for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; -- cgit v1.2.3