cub-uanic/tmk_keyboard

No wake from USB Suspend

tulth opened this issue · 1 comments

Problem: Using my Ergodox on Arch Linux, the Ergodox will not wake the computer from suspend.

Attempted fix:

First "fix" caused it to always wake up instantly.

Ultimately ended up with the following diffs and it works great for me:

--- a/common/avr/suspend.c
+++ b/common/avr/suspend.c
@@ -59,6 +59,7 @@ static void power_down(uint8_t wdto)
 #ifdef PROTOCOL_LUFA
     if (USB_DeviceState == DEVICE_STATE_Configured) return;
 #endif
+#ifndef NO_SUSPEND_POWER_DOWN
     wdt_timeout = wdto;

     // Watchdog Interrupt Mode
@@ -78,6 +79,7 @@ static void power_down(uint8_t wdto)

     // Disable watchdog after sleep
     wdt_disable();
+#endif
 }

 void suspend_power_down(void)
@@ -90,8 +92,10 @@ bool suspend_wakeup_condition(void)
     matrix_power_up();
     matrix_scan();
     matrix_power_down();
-    for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
-        if (matrix_get_row(r)) return true;
+    for (uint8_t r = 0; r < MATRIX_ROWS; r++) { 
+      for (uint8_t c = 0; c < MATRIX_COLS; c++) {
+        if (matrix_is_on(r,c)) { return true; }
+      }
     }
     return false;
 }

you should make a pull request. maybe he'll merge it