]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Output/pjrcUSB/arm/usb_keyboard.c
Major USB update, fixes most (if not all) known issues
[kiibohd-controller.git] / Output / pjrcUSB / arm / usb_keyboard.c
index ec4aae6bfb88a187fac5f732b719e004a177077e..233cc317fe0d4af52583a4d8d7081f6ab1bf87e9 100644 (file)
@@ -1,7 +1,7 @@
 /* Teensyduino Core Library
  * http://www.pjrc.com/teensy/
  * Copyright (c) 2013 PJRC.COM, LLC.
- * Modifications by Jacob Alexander 2013-2015
+ * Modifications by Jacob Alexander 2013-2016
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -29,6 +29,9 @@
  * SOFTWARE.
  */
 
+#include <kll_defs.h>
+#if enableKeyboard_define == 1
+
 // ----- Includes -----
 
 // Compiler Includes
@@ -123,14 +126,25 @@ void usb_keyboard_send()
                        }
                }
 
+               // USB Timeout, drop the packet, and potentially try something more drastic to re-enable the bus
                if ( ++wait_count > TX_TIMEOUT || transmit_previous_timeout )
                {
                        transmit_previous_timeout = 1;
-                       warn_print("USB Transmit Timeout...restarting device");
                        USBKeys_Changed = USBKeyChangeState_None; // Indicate packet lost
+                       #if enableDeviceRestartOnUSBTimeout == 1
+                       warn_print("USB Transmit Timeout...restarting device");
                        usb_device_software_reset();
+                       #else
+                       warn_print("USB Transmit Timeout...auto-restart disabled");
+                       #endif
+                       // Try to wakeup
                        return;
                }
+
+               // Try to wake up the device if we can't allocate a packet for some reason
+               // XXX This is a bit aggressive, but seems to work well. Unfortunately, not as quick as I'd like it -HaaTa
+               usb_resume();
+
                yield();
        }
 
@@ -277,3 +291,5 @@ void usb_keyboard_send()
        return;
 }
 
+#endif
+