aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-04-05 01:18:19 -0700
committerGitHub <noreply@github.com>2020-04-05 18:18:19 +1000
commit845953cc67e33dbd9ac5007ba3b39562f5aea962 (patch)
treebac32fdde7751e8c5487af480bf41b76a0fda39f /tmk_core
parentc3c2eb71e14500117aa974e10fa670fbca893661 (diff)
downloadqmk_firmware-845953cc67e33dbd9ac5007ba3b39562f5aea962.tar.gz
qmk_firmware-845953cc67e33dbd9ac5007ba3b39562f5aea962.zip
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')
-rw-r--r--tmk_core/protocol/vusb/main.c20
-rw-r--r--tmk_core/protocol/vusb/vusb.c6
2 files changed, 21 insertions, 5 deletions
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index 1ab765343..610638e7d 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -20,6 +20,7 @@
20#include "timer.h" 20#include "timer.h"
21#include "uart.h" 21#include "uart.h"
22#include "debug.h" 22#include "debug.h"
23#include "suspend.h"
23#ifdef SLEEP_LED_ENABLE 24#ifdef SLEEP_LED_ENABLE
24# include "sleep_led.h" 25# include "sleep_led.h"
25#endif 26#endif
@@ -41,6 +42,23 @@ static void initForUsbConnectivity(void) {
41 sei(); 42 sei();
42} 43}
43 44
45void usb_remote_wakeup(void) {
46 cli();
47
48 int8_t ddr_orig = USBDDR;
49 USBOUT |= (1 << USBMINUS);
50 USBDDR = ddr_orig | USBMASK;
51 USBOUT ^= USBMASK;
52
53 _delay_ms(25);
54
55 USBOUT ^= USBMASK;
56 USBDDR = ddr_orig;
57 USBOUT &= ~(1 << USBMINUS);
58
59 sei();
60}
61
44int main(void) { 62int main(void) {
45 bool suspended = false; 63 bool suspended = false;
46#if USB_COUNT_SOF 64#if USB_COUNT_SOF
@@ -115,6 +133,8 @@ int main(void) {
115 raw_hid_task(); 133 raw_hid_task();
116 } 134 }
117#endif 135#endif
136 } else if (suspend_wakeup_condition()) {
137 usb_remote_wakeup();
118 } 138 }
119 } 139 }
120} 140}
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 00314ebe8..470d29ba3 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -521,11 +521,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
521# endif 521# endif
522 .bConfigurationValue = 0x01, 522 .bConfigurationValue = 0x01,
523 .iConfiguration = 0x00, 523 .iConfiguration = 0x00,
524# if USB_CFG_IS_SELF_POWERED 524 .bmAttributes = (1 << 7) | USBATTR_REMOTEWAKE,
525 .bmAttributes = (1 << 7) | USBATTR_SELFPOWER,
526# else
527 .bmAttributes = (1 << 7),
528# endif
529 .bMaxPower = USB_MAX_POWER_CONSUMPTION / 2 525 .bMaxPower = USB_MAX_POWER_CONSUMPTION / 2
530 }, 526 },
531 527