-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ci_hs: add deinit support #3394
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive deinitialization support to TinyUSB, enabling dynamic switching between USB device and host modes at runtime. The changes introduce new pre-init and post-deinit callback hooks, implement deinit functions across multiple USB controller drivers, and include a new example demonstrating the dual-role switching capability.
Key Changes:
- Added
tusb_pre_init_cb()andtusb_post_deinit_cb()callback hooks with weak default implementations for MCU-specific initialization/cleanup - Implemented deinit support across multiple USB drivers: dwc2 (DCD/HCD), EHCI, and chipidea ci_hs (DCD/HCD)
- Created a new
dynamic_switchexample demonstrating runtime switching between device and host modes via button press
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tusb.h | Declares new pre-init and post-deinit callback hooks |
| src/tusb.c | Provides weak default implementations for the new callback hooks |
| src/host/usbh.c | Integrates pre-init/post-deinit callbacks into host stack init/deinit flow, changes to TU_ASSERT |
| src/device/usbd.c | Integrates pre-init/post-deinit callbacks into device stack init/deinit flow, changes to TU_ASSERT |
| src/portable/synopsys/dwc2/dwc2_common.h | Declares dwc2_core_deinit function |
| src/portable/synopsys/dwc2/dwc2_common.c | Implements core deinit with soft disconnect and reset |
| src/portable/synopsys/dwc2/hcd_dwc2.c | Adds HCD deinit, removes CONIDSTSCHNG interrupt handling, fixes DATATOGGLE_ERR handling |
| src/portable/synopsys/dwc2/dcd_dwc2.c | Adds DCD deinit implementation |
| src/portable/ehci/ehci_api.h | Declares ehci_deinit function |
| src/portable/ehci/ehci.c | Implements EHCI deinit with interrupt/schedule disable |
| src/portable/chipidea/ci_hs/hcd_ci_hs.c | Adds HCD deinit, fixes comment from "device" to "host", fixes full-speed logic |
| src/portable/chipidea/ci_hs/dcd_ci_hs.c | Implements DCD deinit with interrupt disable and endpoint flushing |
| hw/bsp/stm32u5/family.c | Implements tusb_pre_init_cb for role-specific VBUS/OTG configuration, fixes interrupt handler naming |
| hw/bsp/stm32h7rs/family.c | Implements tusb_pre_init_cb with rhport-aware VBUS/OTG configuration |
| hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.h | Fixes button active_state from 1 to 0 (active low) |
| hw/bsp/lpc43/family.c | Adds GPIO configuration for VIF_OUT, conditionally includes EA4357 board-specific code |
| examples/dual/dynamic_switch/* | New example demonstrating dynamic device/host mode switching with CDC echo and host enumeration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in size
Changes <1% in size
No changes
|
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com> Signed-off-by: HiFiPhile <admin@hifiphile.com>
Describe the PR
Tested on LPC4322 with new dynamic_switch example.
Rebase after #3378