Skip to content

Commit

Permalink
make wakeup delay configurable, and adjust value
Browse files Browse the repository at this point in the history
  • Loading branch information
spidey3 committed Feb 1, 2021
1 parent f32e0c8 commit f1fb386
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ This is a C header file that is one of the first things included, and will persi
* sets the maximum power (in mA) over USB for the device (default: 500)
* `#define USB_POLLING_INTERVAL_MS 10`
* sets the USB polling rate in milliseconds for the keyboard, mouse, and shared (NKRO/media keys) interfaces
* `#define USB_SUSPEND_WAKEUP_DELAY 200`
* set the number of milliseconde to pause after sending a wakeup packet
* `#define F_SCL 100000L`
* sets the I2C clock rate speed for keyboards using I2C. The default is `400000L`, except for keyboards using `split_common`, where the default is `100000L`.

Expand Down
4 changes: 4 additions & 0 deletions tmk_core/common/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ void suspend_wakeup_init_user(void);
void suspend_wakeup_init_kb(void);
void suspend_power_down_user(void);
void suspend_power_down_kb(void);

#ifndef USB_SUSPEND_WAKEUP_DELAY
# define USB_SUSPEND_WAKEUP_DELAY 200
#endif
4 changes: 3 additions & 1 deletion tmk_core/protocol/chibios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,15 @@ int main(void) {
if (suspend_wakeup_condition()) {
usbWakeupHost(&USB_DRIVER);

# if USB_SUSPEND_WAKEUP_DELAY > 0
// Some hubs, kvm switches, and monitors do
// weird things, with USB device state bouncing
// around wildly on wakeup, yielding race
// conditions that can corrupt the keyboard state.
//
// Pause for a while to let things settle...
wait_ms(100);
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
# endif

restart_usb_driver(&USB_DRIVER);
}
Expand Down
4 changes: 3 additions & 1 deletion tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,15 @@ int main(void) {
USB_Device_SendRemoteWakeup();
clear_keyboard();

# if USB_SUSPEND_WAKEUP_DELAY > 0
// Some hubs, kvm switches, and monitors do
// weird things, with USB device state bouncing
// around wildly on wakeup, yielding race
// conditions that can corrupt the keyboard state.
//
// Pause for a while to let things settle...
wait_ms(100);
wait_ms(USB_SUSPEND_WAKEUP_DELAY);
# endif
}
}
suspend_wakeup_init();
Expand Down

0 comments on commit f1fb386

Please sign in to comment.