Skip to content

Commit 3c0e35c

Browse files
jfischer-nocarlescufi
authored andcommitted
[nrf fromtree] samples: usb: hid-keyboard: allow to set polling period at runtime
Add an example of how to set the polling period at runtime. Signed-off-by: Johann Fischer <[email protected]> (cherry picked from commit e295a38)
1 parent 7796de1 commit 3c0e35c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

samples/subsys/usb/hid-keyboard/sample.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ tests:
3333
sample.usbd.hid-keyboard.large-out-report:
3434
extra_args:
3535
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
36+
extra_configs:
37+
- CONFIG_USBD_HID_SET_POLLING_PERIOD=y

samples/subsys/usb/hid-keyboard/src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ int main(void)
206206
return ret;
207207
}
208208

209+
if (IS_ENABLED(CONFIG_USBD_HID_SET_POLLING_PERIOD)) {
210+
ret = hid_device_set_in_polling(hid_dev, 1000);
211+
if (ret) {
212+
LOG_WRN("Failed to set IN report polling period, %d", ret);
213+
}
214+
215+
ret = hid_device_set_out_polling(hid_dev, 1000);
216+
if (ret != 0 && ret != -ENOTSUP) {
217+
LOG_WRN("Failed to set OUT report polling period, %d", ret);
218+
}
219+
}
220+
209221
sample_usbd = sample_usbd_init_device(msg_cb);
210222
if (sample_usbd == NULL) {
211223
LOG_ERR("Failed to initialize USB device");

0 commit comments

Comments
 (0)