V-USB remote wakeup (#7627)

* V-USB remote wakeup

Backport from tmk/tmk_keyboard@391c979be7

* Change vusb.c remote wake config

as per fauxpark's suggestion
master
Drashna Jaelre 2020-04-05 01:18:19 -07:00 committed by GitHub
parent c3c2eb71e1
commit 845953cc67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -20,6 +20,7 @@
#include "timer.h" #include "timer.h"
#include "uart.h" #include "uart.h"
#include "debug.h" #include "debug.h"
#include "suspend.h"
#ifdef SLEEP_LED_ENABLE #ifdef SLEEP_LED_ENABLE
# include "sleep_led.h" # include "sleep_led.h"
#endif #endif
@ -41,6 +42,23 @@ static void initForUsbConnectivity(void) {
sei(); 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) { int main(void) {
bool suspended = false; bool suspended = false;
#if USB_COUNT_SOF #if USB_COUNT_SOF
@ -115,6 +133,8 @@ int main(void) {
raw_hid_task(); raw_hid_task();
} }
#endif #endif
} else if (suspend_wakeup_condition()) {
usb_remote_wakeup();
} }
} }
} }

View File

@ -521,11 +521,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
# endif # endif
.bConfigurationValue = 0x01, .bConfigurationValue = 0x01,
.iConfiguration = 0x00, .iConfiguration = 0x00,
# if USB_CFG_IS_SELF_POWERED .bmAttributes = (1 << 7) | USBATTR_REMOTEWAKE,
.bmAttributes = (1 << 7) | USBATTR_SELFPOWER,
# else
.bmAttributes = (1 << 7),
# endif
.bMaxPower = USB_MAX_POWER_CONSUMPTION / 2 .bMaxPower = USB_MAX_POWER_CONSUMPTION / 2
}, },