Skip to content

Half-duplex becomes a compile-time feature with a shared-wire drive discipline#32

Merged
aq1018 merged 1 commit into
mainfrom
half-duplex-shared-wire
Jul 11, 2026
Merged

Half-duplex becomes a compile-time feature with a shared-wire drive discipline#32
aq1018 merged 1 commit into
mainfrom
half-duplex-shared-wire

Conversation

@aq1018

@aq1018 aq1018 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Half-duplex worked point-to-point but couldn't sit on a shared (multi-drop) wire: the pin idled push-pull, driving against other talkers, and enabling TE before HDSEL latched the TX output LOW — clamping the bus from init until the first own transmission (measured on CH32V006).

Breaking: duplex selection moves from runtime config to compile time. The Duplex enum and UsartConfig::duplex are gone; single-wire operation is now the half-duplex cargo feature (rx_pull only exists without it). A bootloader binary serves one board, so there's no runtime switch worth paying for — full-duplex binaries are byte-identical to before, which matters on the CH32V003's 1920-byte system flash.

With the feature on, the wire follows a shared-bus drive discipline:

  • usart::init raises HDSEL before TE, so the TX output idles at mark from the start.
  • The single-wire pin parks open-drain and flips to push-pull only around writes — an idle node never drives the wire, so multiple devices can share one bus. The bus pull-up owns the idle level.

The transports guide, troubleshooting doc, and examples are updated, including the new hardware requirement: an external pull-up on the wire. CI gains a half-duplex clippy leg per family.

@aq1018 aq1018 force-pushed the half-duplex-shared-wire branch from ee7563c to 41e1053 Compare July 11, 2026 06:03
@aq1018 aq1018 changed the title Make half-duplex safe on a shared wire Half-duplex becomes a compile-time feature with a shared-wire drive discipline Jul 11, 2026
@aq1018 aq1018 force-pushed the half-duplex-shared-wire branch from 41e1053 to f8c5fe6 Compare July 11, 2026 06:08
@aq1018 aq1018 merged commit 06eb300 into main Jul 11, 2026
10 checks passed
@aq1018 aq1018 deleted the half-duplex-shared-wire branch July 11, 2026 06:12
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.

1 participant