]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
ChibiOS/kinetis: sending remote wakeup.
authorflabbergast <s3+flabbergast@sdfeu.org>
Wed, 14 Oct 2015 18:55:09 +0000 (19:55 +0100)
committerflabbergast <s3+flabbergast@sdfeu.org>
Wed, 14 Oct 2015 18:55:09 +0000 (19:55 +0100)
tmk_core/protocol/chibios/main.c
tmk_core/protocol/chibios/usb_main.c
tmk_core/protocol/chibios/usb_main.h

index c4666ebd01bfe0d1f89f6daa69af351b92622e14..9607f1a9ac68327447e1701be65b0c4d0fd16741 100644 (file)
@@ -121,10 +121,10 @@ int main(void) {
       while(USB_DRIVER.state == USB_SUSPENDED) {
         /* Do this in the suspended state */
         suspend_power_down(); // on AVR this deep sleeps for 15ms
-        // TODO: remote wakeup
-        // if(USB_Device_RemoteWakeupEnabled (USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
-          // USB_Device_SendRemoteWakeup();
-        // }
+        /* Remote wakeup */
+        if((USB_DRIVER.status & 2) && suspend_wakeup_condition()) {
+          send_remote_wakeup(&USB_DRIVER);
+        }
       }
       /* Woken up */
       // variables has been already cleared by the wakeup hook
index 872d1c65d0a24eb6d3c9856e61771e0f12931ff3..09de7196368d47eba1cdcb26060d3daa332760a5 100644 (file)
@@ -1024,6 +1024,23 @@ void init_usb_driver(USBDriver *usbp) {
 #endif
 }
 
+/*
+ * Send remote wakeup packet
+ * Note: should not be called from ISR
+ */
+void send_remote_wakeup(USBDriver *usbp) {
+  (void)usbp;
+#if defined(K20x) || defined(KL2x)
+#if KINETIS_USB_USE_USB0
+  USB0->CTL |= USBx_CTL_RESUME;
+  chThdSleepMilliseconds(15);
+  USB0->CTL &= ~USBx_CTL_RESUME;
+#endif /* KINETIS_USB_USE_USB0 */
+#else /* K20x || KL2x */
+#warning Sending remote wakeup packet not implemented for your platform.
+#endif /* K20x || KL2x */
+}
+
 /* ---------------------------------------------------------
  *                  Keyboard functions
  * ---------------------------------------------------------
index 85ea9153452c570e09c3d2a1fd8df3497232cb93..d8f30e9550e3c56cc9d090b19076fc4e8244426e 100644 (file)
@@ -36,6 +36,9 @@
 /* Initialize the USB driver and bus */
 void init_usb_driver(USBDriver *usbp);
 
+/* Send remote wakeup packet */
+void send_remote_wakeup(USBDriver *usbp);
+
 /* ---------------
  * Keyboard header
  * ---------------