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.
This commit is contained in:
parent
75d702a9bd
commit
b482e655ad
@ -54,9 +54,6 @@ static bool has_ghost_in_row(uint8_t row)
|
|||||||
|
|
||||||
void keyboard_init(void)
|
void keyboard_init(void)
|
||||||
{
|
{
|
||||||
// TODO: configuration of sendchar impl
|
|
||||||
print_set_sendchar(sendchar);
|
|
||||||
|
|
||||||
timer_init();
|
timer_init();
|
||||||
matrix_init();
|
matrix_init();
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
|
@ -51,8 +51,7 @@ bool suspend_wakeup_condition(void)
|
|||||||
// run immediately after wakeup
|
// run immediately after wakeup
|
||||||
void suspend_wakeup_init(void)
|
void suspend_wakeup_init(void)
|
||||||
{
|
{
|
||||||
// clear matrix and keyboard state
|
// clear keyboard state
|
||||||
matrix_init();
|
|
||||||
clear_keyboard();
|
clear_keyboard();
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
backlight_init();
|
backlight_init();
|
||||||
|
@ -531,19 +531,24 @@ static void SetupHardware(void)
|
|||||||
|
|
||||||
// for Console_Task
|
// for Console_Task
|
||||||
USB_Device_EnableSOFEvents();
|
USB_Device_EnableSOFEvents();
|
||||||
|
print_set_sendchar(sendchar);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) __attribute__ ((weak));
|
int main(void) __attribute__ ((weak));
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
sei();
|
||||||
|
while (USB_DeviceState != DEVICE_STATE_Configured) ;
|
||||||
|
print("USB configured.\n");
|
||||||
|
|
||||||
keyboard_init();
|
keyboard_init();
|
||||||
host_set_driver(&lufa_driver);
|
host_set_driver(&lufa_driver);
|
||||||
#ifdef SLEEP_LED_ENABLE
|
#ifdef SLEEP_LED_ENABLE
|
||||||
sleep_led_init();
|
sleep_led_init();
|
||||||
#endif
|
#endif
|
||||||
sei();
|
|
||||||
|
|
||||||
|
print("Keyboard start.\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
while (USB_DeviceState == DEVICE_STATE_Suspended) {
|
while (USB_DeviceState == DEVICE_STATE_Suspended) {
|
||||||
suspend_power_down();
|
suspend_power_down();
|
||||||
|
Reference in New Issue
Block a user