Skip to content

usb: device_next: hid: allow to set polling period at runtime #94518

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jfischer-no
Copy link
Contributor

Allow to set input or output report polling period at runtime.

Fail on initialization if no HID device is registered.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Allow to set input or output report polling period at runtime.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add an example of how to set the polling period at runtime.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
@jfischer-no jfischer-no self-assigned this Aug 14, 2025
@jfischer-no jfischer-no added the area: USB Universal Serial Bus label Aug 14, 2025
@zephyrbot zephyrbot added the area: Samples Samples label Aug 14, 2025
@zephyrbot zephyrbot requested review from kartben and nashif August 14, 2025 21:07
Copy link

Copy link
Contributor

@josuah josuah left a comment

Choose a reason for hiding this comment

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

I tried to spot any bug and compared with the USB HID standard (which I am new to) and did not spot any issue.

* @param[in] dev Pointer to HID device
* @param[in] period Polling period in microseconds
*
* @return 0 on success, negative errno code on fail.
Copy link
Contributor

Choose a reason for hiding this comment

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

Simillar to above.

Suggested change
* @return 0 on success, negative errno code on fail.
* @return 0 on success, negative errno code on failure.

* @param[in] dev Pointer to HID device
* @param[in] period Polling period in microseconds
*
* @return 0 on success, negative errno code on fail.
Copy link
Contributor

Choose a reason for hiding this comment

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

It is probably just me who read the sentence wrong.

Suggested change
* @return 0 on success, negative errno code on fail.
* @return 0 on success, negative errno code on failure.

Comment on lines +219 to +220
* different polling periods at runtime. Depends on Kconfig options
* USBD_HID_SET_POLLING_PERIOD.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* different polling periods at runtime. Depends on Kconfig options
* USBD_HID_SET_POLLING_PERIOD.
* different polling periods at runtime.
*
* @kconfig_dep{CONFIG_USBD_HID_SET_POLLING_PERIOD}

Comment on lines +234 to +235
* different polling periods at runtime. Depends on Kconfig options
* USBD_HID_SET_POLLING_PERIOD.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* different polling periods at runtime. Depends on Kconfig options
* USBD_HID_SET_POLLING_PERIOD.
* different polling periods at runtime.
*
* @kconfig_dep{CONFIG_USBD_HID_SET_POLLING_PERIOD}

@@ -212,6 +212,36 @@ int hid_device_register(const struct device *dev,
int hid_device_submit_report(const struct device *dev,
const uint16_t size, const uint8_t *const report);

/**
* @brief Set intput report polling period
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @brief Set intput report polling period
* @brief Set input report polling period

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Samples Samples area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants