Skip to content

Commit

Permalink
V-USB remote wakeup (#7627)
Browse files Browse the repository at this point in the history
* V-USB remote wakeup

Backport from tmk/tmk_keyboard@391c979

* Change vusb.c remote wake config

as per fauxpark's suggestion
  • Loading branch information
drashna committed Apr 5, 2020
1 parent c3c2eb7 commit 845953c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 20 additions & 0 deletions tmk_core/protocol/vusb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -115,6 +133,8 @@ int main(void) {
raw_hid_task();
}
#endif
} else if (suspend_wakeup_condition()) {
usb_remote_wakeup();
}
}
}
6 changes: 1 addition & 5 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,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
},

Expand Down

0 comments on commit 845953c

Please sign in to comment.