samples: usb: hid-keyboard: enable and use remote wakeup on button press
USB remote wakeup capability is a common feature of keyboards, allowing them to wake up a suspended host. Currently there is no USB sample that demonstrates remote wakeup, which makes basic evaluation of the functionality non-trivial. Modify the hid-keyboard sample with a minimalistic solution of demonstrating remote wakeup capability. While it is not required to have been configured prior to suspend to issue a wakeup request, from usability perspective I'd say it makes sense. Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
This commit is contained in:
parent
5309e11df2
commit
f5b3362c79
2 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue