X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=protocol%2Flufa%2Flufa.c;h=6802f3b6319c7cd0a0a4509cbf429e263b49eb07;hb=541913029150d57e83396293d35807a16d3755e8;hp=d60aecc3f12bb7cdc75dfe39b89030ed84fe581a;hpb=abe5edcaa7c6391cb313a672910d7beb9b7d8fa2;p=max%2Ftmk_keyboard.git diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index d60aecc3..6802f3b6 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -148,10 +148,23 @@ static void Console_Task(void) */ void EVENT_USB_Device_Connect(void) { + /* For battery powered device */ + if (!USB_IsInitialized) { + USB_Init(); + USB_Device_EnableSOFEvents(); + } } void EVENT_USB_Device_Disconnect(void) { + /* For battery powered device */ +/* TODO: This doesn't work. After several plug in/outs can not be enumerated. + if (USB_IsInitialized) { + USB_Disable(); // Disable all interrupts + USB_Controller_Enable(); + USB_INT_Enable(USB_INT_VBUSTI); + } +*/ } void EVENT_USB_Device_Reset(void) @@ -272,7 +285,9 @@ void EVENT_USB_Device_ControlRequest(void) // Interface switch (USB_ControlRequest.wIndex) { case KEYBOARD_INTERFACE: +#ifdef NKRO_ENABLE case NKRO_INTERFACE: +#endif Endpoint_ClearSETUP(); while (!(Endpoint_IsOUTReceived())) { @@ -572,7 +587,7 @@ int main(void) print("Keyboard start.\n"); while (1) { while (USB_DeviceState == DEVICE_STATE_Suspended) { - suspend_power_down(); + suspend_power_down(WDTO_120MS); if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { USB_Device_SendRemoteWakeup(); }