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

[Bug] Fix non-functional S3 wakeup / resume from suspense #19780

Merged
merged 4 commits into from
Jun 26, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
#define RP_USB_USE_USBD0 TRUE
#define RP_USB_FORCE_VBUS_DETECT TRUE
#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
#define RP_USB_USE_SOF_INTR TRUE
#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE

#endif /* MCUCONF_H */
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
#define RP_USB_USE_USBD0 TRUE
#define RP_USB_FORCE_VBUS_DETECT TRUE
#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
#define RP_USB_USE_SOF_INTR TRUE
#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE

#endif /* MCUCONF_H */
4 changes: 0 additions & 4 deletions platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,3 @@ void __early_init(void) {
void boardInit(void) {

}

void restart_usb_driver(USBDriver *usbp) {
// Do nothing. Restarting the USB driver on these boards breaks it.
}
4 changes: 0 additions & 4 deletions platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,3 @@ void __early_init(void) {
void boardInit(void) {

}

void restart_usb_driver(USBDriver *usbp) {
// Do nothing. Restarting the USB driver on these boards breaks it.
}
5 changes: 0 additions & 5 deletions platforms/chibios/boards/IC_TEENSY_3_1/board/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,3 @@ void __early_init(void) {
* @todo Add your board-specific code, if any.
*/
void boardInit(void) {}


void restart_usb_driver(USBDriver *usbp) {
// Do nothing. Restarting the USB driver on these boards breaks it.
}
2 changes: 1 addition & 1 deletion platforms/chibios/boards/PJRC_TEENSY_3_5/board/board.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(CHIBIOS_CONTRIB)/os/hal/boards/PJRC_TEENSY_3_5/board.mk

# List of all the board related files.
BOARDSRC += $(BOARD_PATH)/board/extra.c
BOARDSRC +=

# Required include directories
BOARDINC += $(BOARD_PATH)/board
Expand Down
7 changes: 0 additions & 7 deletions platforms/chibios/boards/PJRC_TEENSY_3_5/board/extra.c

This file was deleted.

2 changes: 1 addition & 1 deletion platforms/chibios/boards/PJRC_TEENSY_3_6/board/board.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(CHIBIOS_CONTRIB)/os/hal/boards/PJRC_TEENSY_3_6/board.mk

# List of all the board related files.
BOARDSRC += $(BOARD_PATH)/board/extra.c
BOARDSRC +=

# Required include directories
BOARDINC += $(BOARD_PATH)/board
Expand Down
7 changes: 0 additions & 7 deletions platforms/chibios/boards/PJRC_TEENSY_3_6/board/extra.c

This file was deleted.

1 change: 0 additions & 1 deletion platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
#define RP_USB_USE_USBD0 TRUE
#define RP_USB_FORCE_VBUS_DETECT TRUE
#define RP_USE_EXTERNAL_VBUS_DETECT FALSE
#define RP_USB_USE_SOF_INTR TRUE
#define RP_USB_USE_ERROR_DATA_SEQ_INTR FALSE

#endif /* MCUCONF_H */
1 change: 1 addition & 0 deletions platforms/chibios/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void suspend_wakeup_init(void) {
clear_keys();
#ifdef MOUSEKEY_ENABLE
mousekey_clear();
mousekey_send();
#endif /* MOUSEKEY_ENABLE */
#ifdef PROGRAMMABLE_BUTTON_ENABLE
programmable_button_clear();
Expand Down
22 changes: 9 additions & 13 deletions tmk_core/protocol/chibios/chibios.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,28 +180,24 @@ void protocol_post_init(void) {
}

void protocol_pre_task(void) {
usb_event_queue_task();

#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
print("[s]");
dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
suspend_power_down();
if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
/* issue a remote wakeup event to the host which should resume
* the bus and get our keyboard out of suspension. */
usbWakeupHost(&USB_DRIVER);
restart_usb_driver(&USB_DRIVER);
}
}
/* Woken up */
// variables has been already cleared by the wakeup hook
send_keyboard_report();
# ifdef MOUSEKEY_ENABLE
mousekey_send();
# endif /* MOUSEKEY_ENABLE */
/* after a successful wakeup a USB_EVENT_WAKEUP is signaled to QMK by
* ChibiOS, which triggers a wakeup callback that restores the state of
* the keyboard. Therefore we do nothing here. */
}
#endif

usb_event_queue_task();
}

void protocol_post_task(void) {
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void protocol_post_init(void) {
void protocol_pre_task(void) {
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DeviceState == DEVICE_STATE_Suspended) {
print("[s]");
dprintln("suspending keyboard");
while (USB_DeviceState == DEVICE_STATE_Suspended) {
suspend_power_down();
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
Expand Down