Skip to content

ch32v: Revamp the board-level usart setup design - #1021

Open
Grazfather wants to merge 6 commits into
mainfrom
ch32_uart_2
Open

ch32v: Revamp the board-level usart setup design#1021
Grazfather wants to merge 6 commits into
mainfrom
ch32_uart_2

Conversation

@Grazfather

Copy link
Copy Markdown
Collaborator

Following up on discussion on discord, addressing some concerns.

  1. 'Config' vs. 'Setup'
  2. Stuff like baud should not be in the board file. It is an 'application level' configuration.
  3. The setup function is clunky. Put it into a method.
  4. The @hasDecl is clunky. Move it into the method.

Comment thread port/wch/ch32v/src/hals/usart.zig Outdated
Comment thread port/wch/ch32v/src/boards/nanoCH32V203.zig

@tact1m4n3 tact1m4n3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

Following up on  discussion on discord, addressing some concerns.

1. 'Config' vs. 'Setup'
2. Stuff like baud should not be in the board file. It is an
   'application level' configuration.
3. The setup function is clunky. Put it into a method.
4. The `@hasDecl` is clunky. Move it into the method.
@Grazfather

Copy link
Copy Markdown
Collaborator Author

Tested on the LANA_TNY and nanoch32v203

Comment thread examples/wch/ch32v/src/uart_log.zig Outdated
const time = hal.time;

const uart_cfg: hal.usart.UartConfig = if (@hasDecl(board, "uart_config")) board.uart_config else .{};
const uart = board.uart_setup;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not change the name here

Comment thread port/wch/ch32v/src/hals/usart.zig Outdated
/// Physical-layer UART setup: which USART instance and pins to use.
/// Boards export a `uart_setup` const of this type. Application-level
/// settings (baud rate, parity, etc.) are passed separately via `Config`.
pub const UartSetup = struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You're already in the uart namespace, so Setup is sufficient

@Grazfather
Grazfather requested a review from mattnite September 7, 2026 14:07
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.

4 participants