]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Fix CTRL/ALT keyboard does not wake computer from sleep
authorpatrickmt <40182064+patrickmt@users.noreply.github.com>
Tue, 30 Oct 2018 16:23:57 +0000 (12:23 -0400)
committerDrashna Jaelre <drashna@live.com>
Fri, 2 Nov 2018 21:33:07 +0000 (14:33 -0700)
Fix for Massdrop CTRL and ALT keyboards not waking computer from sleep

tmk_core/protocol/arm_atsam/main_arm_atsam.c
tmk_core/protocol/arm_atsam/usb/udc.h

index 54d056a14ea1553c2a818464f7b2b59d17adb8b3..d3dc272ee0ebd86342391e96917ce2dcf5705dfe 100644 (file)
@@ -62,6 +62,12 @@ void send_keyboard(report_keyboard_t *report)
 {
     uint32_t irqflags;
 
+    if (usb_state == USB_STATE_POWERDOWN)
+    {
+        udc_remotewakeup();
+        return;
+    }
+
 #ifdef NKRO_ENABLE
     if (!keymap_config.nkro)
     {
@@ -156,25 +162,27 @@ void send_consumer(uint16_t data)
 }
 
 uint8_t g_drvid;
+uint8_t g_usb_sleeping = 0;
 
 void main_subtask_usb_state(void)
 {
     if (usb_state == USB_STATE_POWERDOWN)
     {
-        uint32_t timer_led = timer_read32();
-
-        led_on;
-        if (led_enabled)
+        if (!g_usb_sleeping)
         {
-            for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
+            g_usb_sleeping = 1;
+            if (led_enabled)
             {
-                I2C3733_Control_Set(0);
+                for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
+                {
+                    I2C3733_Control_Set(0);
+                }
             }
         }
-        while (usb_state == USB_STATE_POWERDOWN)
-        {
-            if (timer_read32() - timer_led > 1000) led_off; //Good to indicate went to sleep, but only for a second
-        }
+    }
+    else if (g_usb_sleeping)
+    {
+        g_usb_sleeping = 0;
         if (led_enabled)
         {
             for (g_drvid = 0; g_drvid < ISSI3733_DRIVER_COUNT; g_drvid++)
@@ -182,12 +190,12 @@ void main_subtask_usb_state(void)
                 I2C3733_Control_Set(1);
             }
         }
-        led_off;
     }
 }
 
 void main_subtask_led(void)
 {
+    if (g_usb_sleeping) return;
     led_matrix_task();
 }
 
index c88a442cb65a13aa82ae99edf6e580dddce69d38..33335d1869fb20541b534deaf24e191fb6a77719 100644 (file)
@@ -210,7 +210,7 @@ static inline void udc_detach(void)
 /*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
  * This is authorized only when the remote wakeup feature is enabled by host.
  */
-static inline void udc_remotewakeup(void)
+inline void udc_remotewakeup(void)
 {
     udd_send_remotewakeup();
 }