Skip to content

feat(esp_tinyusb): Added device suspend/resume events#387

Merged
peter-marcisovsky merged 1 commit intomasterfrom
feat/esp_tinyusb_add_suspend_resume_events
Feb 2, 2026
Merged

feat(esp_tinyusb): Added device suspend/resume events#387
peter-marcisovsky merged 1 commit intomasterfrom
feat/esp_tinyusb_add_suspend_resume_events

Conversation

@peter-marcisovsky
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky commented Jan 23, 2026

Description

This PR adds suspend/resume events to the device event callback handler

Reason for this change:

  • Current esp_tinyusb V.2 lacks suspend/resume events needed for further HID Host tests, CDC-ACM Host tests and general usage of the esp_tinyusb

The device events are implemented using tud_suspend_cb() and tud_suspend_cb() provided by TinyUSB. The callbacks registering in configurable via Kconfig. Users can:

  • register tud_suspend_cb() and tud_suspend_cb() in esp_tinyusb and benefit from internal event handling
  • register their own custom callback

Related


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

Medium Risk
Medium risk because it introduces new TinyUSB callback hooks (tud_suspend_cb/tud_resume_cb) behind Kconfig flags and adds a new public API (tinyusb_remote_wakeup) that changes runtime USB device behavior and is exercised in CI with new hardware-dependent tests.

Overview
Adds optional USB device suspend/resume event reporting to esp_tinyusb, gated by new Kconfig flags (CONFIG_TINYUSB_SUSPEND_CALLBACK, CONFIG_TINYUSB_RESUME_CALLBACK) that register strong tud_suspend_cb()/tud_resume_cb() implementations and emit TINYUSB_EVENT_SUSPENDED/TINYUSB_EVENT_RESUMED (including a remote-wakeup-enabled bit on suspend).

Introduces a new public API tinyusb_remote_wakeup() and internal tracking of host-enabled remote wakeup, plus documentation/CHANGELOG updates describing the opt-in behavior and linker constraints.

Extends CI and test coverage with a new power_management device test app and pytest suite validating suspend/resume event delivery and remote wakeup behavior, and updates the USB runner workflow/container setup to mount /dev/bus/usb and install libusb for pyusb-based tests.

Written by Cursor Bugbot for commit 28f055e. This will update automatically on new commits. Configure here.

@peter-marcisovsky peter-marcisovsky self-assigned this Jan 23, 2026
@peter-marcisovsky peter-marcisovsky added the Component: usb_device Issue affects usb_device component label Jan 23, 2026
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from 0ddf733 to bde4855 Compare January 23, 2026 17:30
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from ede084a to 1f55633 Compare January 24, 2026 21:17
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from 3df8428 to adaf4eb Compare January 26, 2026 18:32
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from 54cf7b0 to 7b92695 Compare January 27, 2026 12:43
@peter-marcisovsky peter-marcisovsky marked this pull request as ready for review January 27, 2026 12:46
@peter-marcisovsky peter-marcisovsky added the Status: Reviewing Issue is being reviewed label Jan 27, 2026
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from dadba3e to bc169d6 Compare January 30, 2026 14:44
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from bc169d6 to 5a79e76 Compare January 30, 2026 15:00
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Collaborator

@tore-espressif tore-espressif left a comment

Choose a reason for hiding this comment

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

@peter-marcisovsky nice work, LGTM!

@tore-espressif tore-espressif added this to the esp_tinyusb v2.0.2 milestone Feb 2, 2026
    - Configurable Suspend/Resume device event callbacks
    - User can register the tud_suspend_cb and tud_resume_cb callbacks to esp_tinyusb,
      or to it's own custom suspend/resume callbacks implementations
    - Configurable via Kconfig
@peter-marcisovsky peter-marcisovsky force-pushed the feat/esp_tinyusb_add_suspend_resume_events branch from d29982c to 28f055e Compare February 2, 2026 11:51
@peter-marcisovsky peter-marcisovsky merged commit 3cc139e into master Feb 2, 2026
61 checks passed
@peter-marcisovsky peter-marcisovsky deleted the feat/esp_tinyusb_add_suspend_resume_events branch February 2, 2026 13:02
@peter-marcisovsky peter-marcisovsky added Status: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed labels Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: usb_device Issue affects usb_device component Status: Done Issue is done internally

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants