Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for Idle Wake issue #304

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tmk_core/protocol/chibios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main(void) {
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
if (suspend_wakeup_condition()) {
usbWakeupHost(&USB_DRIVER);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usbWakeupHost() must be used to send a resume signal to host (from J state to K state)

https://www.nxp.com/docs/en/application-note/AN5385.pdf

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good question is, is this actually required, because, the lack of it doesn't seem to adversely affect the keyboard, nor it's ability to wake the system.

restart_driver(&USB_DRIVER);
}
}
/* Woken up */
Expand Down
11 changes: 11 additions & 0 deletions tmk_core/protocol/chibios/usb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,17 @@ void init_usb_driver(USBDriver *usbp) {
chVTObjectInit(&keyboard_idle_timer);
}

/*
* Reinit the USB driver on wake
*/
void restart_driver(USBDriver *usbp) {
usbStop(usbp);
usbDisconnectBus(usbp);
wait_ms(1500);
usbStart(usbp, &usbcfg);
usbConnectBus(usbp);
}

/* ---------------------------------------------------------
* Keyboard functions
* ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/protocol/chibios/usb_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/* Initialize the USB driver and bus */
void init_usb_driver(USBDriver *usbp);

void restart_driver(USBDriver *usbp);
/* ---------------
* Keyboard header
* ---------------
Expand Down