diff options
author | Drashna Jaelre <drashna@live.com> | 2020-04-05 01:18:19 -0700 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2020-06-12 17:00:27 +0900 |
commit | 8a8e1593d6a670c0e1d5c914aa4adba5549abe17 (patch) | |
tree | 360cbc54bf5d81c7072ac3b4cc9f1318b6dbcc60 /tmk_core/protocol/vusb/main.c | |
parent | ce318b12d78b6fbc5e34ee58c5379168298a1d47 (diff) |
V-USB remote wakeup (#7627)
* V-USB remote wakeup
Backport from tmk/tmk_keyboard@391c979be751eaf113c8f53c36644a6bb6ff12f6
* Change vusb.c remote wake config
as per fauxpark's suggestion
Diffstat (limited to 'tmk_core/protocol/vusb/main.c')
-rw-r--r-- | tmk_core/protocol/vusb/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c index 1ab765343b..610638e7d4 100644 --- a/tmk_core/protocol/vusb/main.c +++ b/tmk_core/protocol/vusb/main.c @@ -20,6 +20,7 @@ #include "timer.h" #include "uart.h" #include "debug.h" +#include "suspend.h" #ifdef SLEEP_LED_ENABLE # include "sleep_led.h" #endif @@ -41,6 +42,23 @@ static void initForUsbConnectivity(void) { sei(); } +void usb_remote_wakeup(void) { + cli(); + + int8_t ddr_orig = USBDDR; + USBOUT |= (1 << USBMINUS); + USBDDR = ddr_orig | USBMASK; + USBOUT ^= USBMASK; + + _delay_ms(25); + + USBOUT ^= USBMASK; + USBDDR = ddr_orig; + USBOUT &= ~(1 << USBMINUS); + + sei(); +} + int main(void) { bool suspended = false; #if USB_COUNT_SOF @@ -115,6 +133,8 @@ int main(void) { raw_hid_task(); } #endif + } else if (suspend_wakeup_condition()) { + usb_remote_wakeup(); } } } |