Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds deinitialization support for the Synopsys DWC2 USB controller, enabling dynamic start/stop of USB host and device modes. The implementation mirrors the initialization sequence in reverse, disabling interrupts, disconnecting from the bus, and resetting the core. This was tested on STM32H7S3 with device mode toggling via button press.
Key Changes
- Implements
hcd_deinit()anddcd_deinit()functions for DWC2 host and device controllers - Adds common
dwc2_core_deinit()function shared between host and device modes - Updates error handling in
tuh_deinit()andtud_deinit()to useTU_ASSERTconsistently - Fixes button active state configuration for STM32H7S3 Nucleo board
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/portable/synopsys/dwc2/hcd_dwc2.c |
Adds host controller deinit implementation with interrupt disable |
src/portable/synopsys/dwc2/dwc2_common.h |
Declares dwc2_core_deinit() for shared deinitialization logic |
src/portable/synopsys/dwc2/dwc2_common.c |
Implements common core deinit with soft disconnect and core reset |
src/portable/synopsys/dwc2/dcd_dwc2.c |
Adds device controller deinit with disconnect and cleanup |
src/host/usbh.c |
Changes hcd_deinit() call to use TU_ASSERT for error checking |
src/device/usbd.c |
Changes dcd_deinit() call to use TU_ASSERT for consistency |
hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.h |
Corrects button active state from 1 to 0 (active-low with pullup) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2c8f34d to
2a994a3
Compare
9461753 to
e214976
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e214976 to
ceb4274
Compare
|
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
|
| return phys_addr; | ||
| } | ||
|
|
||
| TU_ATTR_WEAK void tusb_pre_init_cb(uint8_t rhport, tusb_role_t role) { |
There was a problem hiding this comment.
do we really need this, both init() and de-init() is called by application, they should call them before/after those accordingly ?
There was a problem hiding this comment.
@hathach It's for host/device specific init, like STM32's GCCFG and GOTGCTL register, which need to be set to different value on host/device. Their meaning is also different across families, I haven't found a easy way to include them in the driver.
tinyusb/hw/bsp/stm32h7rs/family.c
Line 390 in 8a466ff
There was a problem hiding this comment.
Give me a bit of time, I will try to review and see if we could avoid using these callbacks
7c4233b to
f7d82a1
Compare
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>



@roma-jam Hi, I've added deinit support to dwc2.
A dynamic switch example is added and tested on: