]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - protocol/lufa/lufa.c
Merge branch 'merge_rn42'
[tmk_firmware.git] / protocol / lufa / lufa.c
index 58201e5c986e8cf042c4fb968cb6e1ba24395b53..6802f3b6319c7cd0a0a4509cbf429e263b49eb07 100644 (file)
 #endif
 #include "suspend.h"
 
-#ifdef SERIAL_MOUSE_ENABLE
-#include "serial_mouse.h"
-#endif
-
 #include "descriptor.h"
 #include "lufa.h"
 
@@ -152,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)
@@ -575,14 +584,10 @@ int main(void)
     sleep_led_init();
 #endif
 
-#ifdef SERIAL_MOUSE_ENABLE
-    serial_mouse_init();
-#endif
-
     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();
             }
@@ -590,10 +595,6 @@ int main(void)
 
         keyboard_task();
 
-#ifdef SERIAL_MOUSE_ENABLE
-        serial_mouse_task();
-#endif
-
 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
         USB_USBTask();
 #endif