cub-uanic / tmk_keyboard

keyboard controller firmware for Atmel AVR USB family
158 stars 157 forks source link

No wake from USB Suspend #21

Open tulth opened 9 years ago

tulth commented 9 years ago

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;
 }
cdarken commented 9 years ago

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