You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds STM32C5 HAL v2 USB device support to the shared USBDevice library.
This PR implements the following features:
HAL v2 USB device low-level adapter for STM32C5
CDC endpoint and PMA configuration for the C5 USB DRD FS peripheral
CDC transmit handling compatible with HAL v2 endpoint fields
Optional CDC line-coding callback for board-specific actions such as 1200-bps touch
HAL-level USB re-enumeration using HAL_PCD_DeviceDisconnect() and the matching HAL_PCD_Start() attach path
Motivation
The Seeed XIAO STM32C5 uses the STM32C5 HAL v2 USB device peripheral. The shared USBDevice library currently has no HAL v2 low-level adapter, so the board cannot provide USB CDC through the normal Arduino core path.
This change is intentionally separated from the XIAO board definition so the common USB implementation can be reviewed independently. The initial split first used a direct PA_12 GPIO detach in usbd_if.c; after checking the STM32C5 HAL, this was replaced with the HAL PCD device-connect API. The common re-enumeration helper no longer contains a C5-specific pin reference.
Validation
USB CDC enumeration, serial communication and sustained CDC transfers were validated on Seeed XIAO STM32C5. The C5 CDC PMA endpoints are configured as non-overlapping single-buffer areas.
Follow-up: after checking the STM32C5 HAL source, I replaced the temporary direct PA_12 GPIO detach with HAL_PCD_DeviceDisconnect() after PCD initialization. HAL_PCD_Start() performs the matching attach when USB is ready. The common usbd_if.c no longer contains a C5-specific pin reference.
Follow-up split PRs are now open for the remaining shared pieces: #3060 contains the HAL v2 UART helper compatibility fix, and #3061 contains the generic UF2 upload recipe. The UF2 recipe invokes the uf2upload executable from Arduino_Tools #122; end-to-end C5 1200-bps upload requires both #3061 and this USB PR (#3059), while #3060 is independent of USB and Tools.
Hi @cumin777
I try to test this PR but by default it does not build when USB is enabled.
I've fixed the build issue but could not get USB working yet.
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
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.
Summary
This PR adds STM32C5 HAL v2 USB device support to the shared USBDevice library.
This PR implements the following features:
HAL_PCD_DeviceDisconnect()and the matchingHAL_PCD_Start()attach pathMotivation
The Seeed XIAO STM32C5 uses the STM32C5 HAL v2 USB device peripheral. The shared USBDevice library currently has no HAL v2 low-level adapter, so the board cannot provide USB CDC through the normal Arduino core path.
This change is intentionally separated from the XIAO board definition so the common USB implementation can be reviewed independently. The initial split first used a direct
PA_12GPIO detach inusbd_if.c; after checking the STM32C5 HAL, this was replaced with the HAL PCD device-connect API. The common re-enumeration helper no longer contains a C5-specific pin reference.Validation
USB CDC enumeration, serial communication and sustained CDC transfers were validated on Seeed XIAO STM32C5. The C5 CDC PMA endpoints are configured as non-overlapping single-buffer areas.
Code formatting
Closing issues
N/A