Skip to content

samples: usb: hid-keyboard: enable and use remote wakeup on button press #79341

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

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
1 change: 1 addition & 0 deletions samples/subsys/usb/hid-keyboard/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_USBD_LOG_LEVEL_WRN=y
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_SAMPLE_USBD_PID=0x0007
CONFIG_SAMPLE_USBD_REMOTE_WAKEUP=y

CONFIG_GPIO=y
CONFIG_INPUT=y
Expand Down
11 changes: 11 additions & 0 deletions samples/subsys/usb/hid-keyboard/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,17 @@ int main(void)
continue;
}

if (usbd_is_suspended(sample_usbd)) {
/* on a press of any button, send wakeup request */
if (kb_evt.value) {
ret = usbd_wakeup_request(sample_usbd);
if (ret) {
LOG_ERR("Remote wakeup error, %d", ret);
}
}
continue;
}

ret = hid_device_submit_report(hid_dev, KB_REPORT_COUNT, report);
if (ret) {
LOG_ERR("HID submit report error, %d", ret);
Expand Down