Skip to content

USB Device: improve HID idle handling - #181

Merged
MiloradCvjetkovic merged 1 commit into
mainfrom
usbd_hid
Sep 9, 2026
Merged

MiloradCvjetkovic merged 1 commit into
mainfrom
usbd_hid

Conversation

@MiloradCvjetkovic

Copy link
Copy Markdown
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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_report field 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.

Comment thread Components/USB/Source/usbd_lib_hid.c
@MiloradCvjetkovic
MiloradCvjetkovic merged commit 594ff20 into main Sep 9, 2026
5 checks passed
@MiloradCvjetkovic
MiloradCvjetkovic deleted the usbd_hid branch September 9, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants