USB Device: improve HID idle handling - #181
Merged
Merged
Conversation
MiloradCvjetkovic
commented
Sep 8, 2026
Collaborator
- fixed HID idle handling for endpoint intervals not aligned to 4 ms
- fixed HID idle handling for multiple input reports
- fixed HID idle handling for endpoint intervals not aligned to 4 ms - fixed HID idle handling for multiple input reports
There was a problem hiding this comment.
🟡 Changes recommended
The idle counter discards elapsed-time overshoot, causing incorrect reload cadence; targeted regression validation is also missing.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Improves USB Device HID idle scheduling and multi-report handling while updating the component to version 8.0.3.
Changes:
- Handles polling intervals not divisible by 4 ms.
- Processes pending updates for multiple input reports.
- Updates version metadata, history, and copyright notices.
File summaries
| File | Description |
|---|---|
Keil.MDK-Middleware.pdsc |
Records USB 8.0.3 release metadata. |
Documentation/Doxygen/USB/src/revision_history.md |
Documents the HID fixes. |
Components/USB/USB.scvd |
Updates the component viewer version. |
Components/USB/Source/usbd_lib.h |
Corrects a HID field comment and copyright. |
Components/USB/Source/usbd_lib_hid.c |
Implements HID timing and multi-report changes. The expiry logic must preserve elapsed-time overshoot at lines 513 and 630; targeted regression validation should also cover non-4-ms intervals and multiple reports. |
Components/USB/Source/usbd_config.c |
Updates the copyright notice. |
Components/USB/Include/rl_usb.h |
Increments the public USB patch version. |
Review details
Suppressed comments (2)
Components/USB/Source/usbd_lib_hid.c:630
- Always scanning from report 0 can starve higher report IDs. When the endpoint interval exceeds 4 ms, the timer can reassert bit 0 before the current transfer completes, so every completion selects report 0 while older pending bits remain indefinitely. Resume scanning from a rotating per-instance cursor (the existing
last_in_reportfield can serve this purpose) and advance it after selecting a report.
for (i = 0U; i < ptr_hid_cfg->in_report_num; i++) {
Components/USB/Source/usbd_lib_hid.c:513
- The existing HID validation configuration uses one input report and a 16 ms interval, so it does not exercise either regression this change targets. Add validation cases with a non-4-ms interval (such as 5 ms) and multiple input reports, asserting the reload cadence and delivery of every pending report ID.
if (ptr_hid_data->polling_count >= polling_interval) {
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RobertRostohar
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.