Skip to content

ch32: Add usbd peripheral - #995

Open
Grazfather wants to merge 5 commits into
mainfrom
ch32_usbd
Open

Grazfather wants to merge 5 commits into
mainfrom
ch32_usbd

Conversation

@Grazfather

Copy link
Copy Markdown
Collaborator

No description provided.

@Grazfather
Grazfather marked this pull request as draft July 25, 2026 13:54
@Grazfather
Grazfather marked this pull request as ready for review September 12, 2026 13:28
@Grazfather
Grazfather force-pushed the ch32_usbd branch 2 times, most recently from e19110a to 7f1e65b Compare September 26, 2026 15:31
@Grazfather
Grazfather requested review from mattnite and a balanced review from Copilot October 1, 2026 23:06

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.

Copilot review overview

🟡 Changes recommended

PMA sizing, control-transfer handling, GPIO clocking, and board UART initialization contain functional defects.

Review effort: Balanced
Findings: 3 High severity · 1 Medium severity

Open (4)
What changed in this PR

Adds a selectable PMA-based USBD backend for CH32V203 boards while standardizing USB setup APIs.

Changes:

  • Implements the USBD driver, clock setup, and board-level selection.
  • Updates USBFS/USBHS to the uniform Setup API.
  • Adds LANA TNY USB CDC support and board configuration.
File Description
port/​wch/​ch32v/​src/​hals/​usbhs.zig Adopts uniform USB setup API.
port/​wch/​ch32v/​src/​hals/​usbfs.zig Adopts uniform USB setup API.
port/​wch/​ch32v/​src/​hals/​usbd.zig Implements PMA-based USBD backend.
port/​wch/​ch32v/​src/​hals/​clocks.zig Adds USBD clock configuration.
port/​wch/​ch32v/​src/​hals/​ch32v20x.zig Selects USB backend by board.
port/​wch/​ch32v/​src/​boards/​Suzuduino_Uno_V1b.zig Adds USB and UART setup.
port/​wch/​ch32v/​src/​boards/​nanoCH32V203.zig Adds USB setup.
port/​wch/​ch32v/​src/​boards/​LANA_TNY.zig Selects and initializes USBD.
port/​wch/​ch32v/​src/​boards/​CH32V307V-R1-1v0.zig Adds USB and UART setup.
examples/​wch/​ch32v/​src/​usb_cdc.zig Uses board USB setup.
examples/​wch/​ch32v/​build.zig Adds LANA TNY CDC target.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread port/wch/ch32v/src/hals/usbd.zig
Comment thread port/wch/ch32v/src/hals/usbd.zig
Comment thread port/wch/ch32v/src/hals/usbd.zig
Comment thread examples/wch/ch32v/src/usb_cdc.zig

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.

Copilot review overview

🟡 Changes recommended

Shared receive staging can corrupt unread packets, and odd-sized PMA allocations can misalign subsequent endpoint buffers.

Review effort: Balanced
Findings: 2 High severity

Open (2)
Resolved since last review (4)

Comment thread port/wch/ch32v/src/hals/usbd.zig Outdated
Comment thread port/wch/ch32v/src/hals/usbd.zig
@Grazfather
Grazfather requested a balanced review from Copilot October 3, 2026 12:32
@Grazfather

Copy link
Copy Markdown
Collaborator Author

Note that I re-tested on my LANA_TNY after these fixes today.

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.

Copilot review overview

🔵 Needs a closer look

The new hardware backend’s PMA, register-toggle, and clock behavior requires validation on the target device.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

This branch has not been deployed

No deployments
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