summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
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 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();
}
}
}
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 867ffb33f2..588991524d 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -532,11 +532,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
# endif
.bConfigurationValue = 0x01,
.iConfiguration = 0x00,
-# if USB_CFG_IS_SELF_POWERED
- .bmAttributes = (1 << 7) | USBATTR_SELFPOWER,
-# else
- .bmAttributes = (1 << 7),
-# endif
+ .bmAttributes = (1 << 7) | USBATTR_REMOTEWAKE,
.bMaxPower = USB_MAX_POWER_CONSUMPTION / 2
},