diff options
| author | tmk <nobody@nowhere> | 2013-09-21 22:47:03 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-09-21 22:47:03 +0900 |
| commit | 7d692c492ca999edd827477b914ae38ce43bf519 (patch) | |
| tree | 60c42dc9460c9f924c2274ccb7d2252bcea6e399 | |
| parent | 6ccea742deb84451a5815e40ccfc3aaa74feb622 (diff) | |
| download | qmk_firmware-7d692c492ca999edd827477b914ae38ce43bf519.tar.gz qmk_firmware-7d692c492ca999edd827477b914ae38ce43bf519.zip | |
Fix USB initilaize on LUFA
- 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.
| -rw-r--r-- | common/keyboard.c | 3 | ||||
| -rw-r--r-- | common/suspend.c | 3 | ||||
| -rw-r--r-- | protocol/lufa/lufa.c | 7 |
3 files changed, 7 insertions, 6 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index d1821a099..601e3abe1 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -54,9 +54,6 @@ static bool has_ghost_in_row(uint8_t row) | |||
| 54 | 54 | ||
| 55 | void keyboard_init(void) | 55 | void keyboard_init(void) |
| 56 | { | 56 | { |
| 57 | // TODO: configuration of sendchar impl | ||
| 58 | print_set_sendchar(sendchar); | ||
| 59 | |||
| 60 | timer_init(); | 57 | timer_init(); |
| 61 | matrix_init(); | 58 | matrix_init(); |
| 62 | #ifdef PS2_MOUSE_ENABLE | 59 | #ifdef PS2_MOUSE_ENABLE |
diff --git a/common/suspend.c b/common/suspend.c index 146b96d5c..5b378892f 100644 --- a/common/suspend.c +++ b/common/suspend.c | |||
| @@ -51,8 +51,7 @@ bool suspend_wakeup_condition(void) | |||
| 51 | // run immediately after wakeup | 51 | // run immediately after wakeup |
| 52 | void suspend_wakeup_init(void) | 52 | void suspend_wakeup_init(void) |
| 53 | { | 53 | { |
| 54 | // clear matrix and keyboard state | 54 | // clear keyboard state |
| 55 | matrix_init(); | ||
| 56 | clear_keyboard(); | 55 | clear_keyboard(); |
| 57 | #ifdef BACKLIGHT_ENABLE | 56 | #ifdef BACKLIGHT_ENABLE |
| 58 | backlight_init(); | 57 | backlight_init(); |
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index c1617cd05..a4e57b227 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c | |||
| @@ -531,19 +531,24 @@ static void SetupHardware(void) | |||
| 531 | 531 | ||
| 532 | // for Console_Task | 532 | // for Console_Task |
| 533 | USB_Device_EnableSOFEvents(); | 533 | USB_Device_EnableSOFEvents(); |
| 534 | print_set_sendchar(sendchar); | ||
| 534 | } | 535 | } |
| 535 | 536 | ||
| 536 | int main(void) __attribute__ ((weak)); | 537 | int main(void) __attribute__ ((weak)); |
| 537 | int main(void) | 538 | int main(void) |
| 538 | { | 539 | { |
| 539 | SetupHardware(); | 540 | SetupHardware(); |
| 541 | sei(); | ||
| 542 | while (USB_DeviceState != DEVICE_STATE_Configured) ; | ||
| 543 | print("USB configured.\n"); | ||
| 544 | |||
| 540 | keyboard_init(); | 545 | keyboard_init(); |
| 541 | host_set_driver(&lufa_driver); | 546 | host_set_driver(&lufa_driver); |
| 542 | #ifdef SLEEP_LED_ENABLE | 547 | #ifdef SLEEP_LED_ENABLE |
| 543 | sleep_led_init(); | 548 | sleep_led_init(); |
| 544 | #endif | 549 | #endif |
| 545 | sei(); | ||
| 546 | 550 | ||
| 551 | print("Keyboard start.\n"); | ||
| 547 | while (1) { | 552 | while (1) { |
| 548 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 553 | while (USB_DeviceState == DEVICE_STATE_Suspended) { |
| 549 | suspend_power_down(); | 554 | suspend_power_down(); |
