]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix USB initilaize on LUFA
authortmk <nobody@nowhere>
Sat, 21 Sep 2013 13:47:03 +0000 (22:47 +0900)
committertmk <nobody@nowhere>
Sat, 21 Sep 2013 13:47:03 +0000 (22:47 +0900)
- Add print messages of USB intialize procesure.
- call out sei() in earlier stage. LUFA API doc of USB_Init() says:
interrupts must be enabled within 500ms ... to ensure that the host does
not time out whilst enumerating the device
- remove matrix_init() from suspend_wakeup_init(). It is not needed in
  fact and if matrix_init() takes long time to initialize it prevents
host emnumerating the device.

common/keyboard.c
common/suspend.c
protocol/lufa/lufa.c

index d1821a099f554db950f912f66755aefac2ae2c7a..601e3abe17b6d06774d76e9e8b79d32c3993e76d 100644 (file)
@@ -54,9 +54,6 @@ static bool has_ghost_in_row(uint8_t row)
 
 void keyboard_init(void)
 {
-    // TODO: configuration of sendchar impl
-    print_set_sendchar(sendchar);
-
     timer_init();
     matrix_init();
 #ifdef PS2_MOUSE_ENABLE
index 146b96d5cc0c5f8ac6e9332dffe98474eca660fd..5b378892f30f5112ec6725f8c22b619e592ec3f6 100644 (file)
@@ -51,8 +51,7 @@ bool suspend_wakeup_condition(void)
 // run immediately after wakeup
 void suspend_wakeup_init(void)
 {
-    // clear matrix and keyboard state
-    matrix_init();
+    // clear keyboard state
     clear_keyboard();
 #ifdef BACKLIGHT_ENABLE
     backlight_init();
index c1617cd05ae26670475883770620987b70db7641..a4e57b227d1298ab1b71155d9e8b6bab286caecc 100644 (file)
@@ -531,19 +531,24 @@ static void SetupHardware(void)
 
     // for Console_Task
     USB_Device_EnableSOFEvents();
+    print_set_sendchar(sendchar);
 }
 
 int main(void)  __attribute__ ((weak));
 int main(void)
 {
     SetupHardware();
+    sei();
+    while (USB_DeviceState != DEVICE_STATE_Configured) ;
+    print("USB configured.\n");
+
     keyboard_init();
     host_set_driver(&lufa_driver);
 #ifdef SLEEP_LED_ENABLE
     sleep_led_init();
 #endif
-    sei();
 
+    print("Keyboard start.\n");
     while (1) {
         while (USB_DeviceState == DEVICE_STATE_Suspended) {
             suspend_power_down();