Skip to content

refactor(i2c): drop embedded-hal 0.2 compatibility - #205

Open
alexxy wants to merge 1 commit into
ch32-rs:mainfrom
alexxy:remove-embedded-hal-02
Open

alexxy wants to merge 1 commit into
ch32-rs:mainfrom
alexxy:remove-embedded-hal-02

Conversation

@alexxy

@alexxy alexxy commented Sep 4, 2026

Copy link
Copy Markdown

What

Removes the embedded-hal 0.2 dependency and its last consumers: the embedded_hal_02::blocking::i2c::{Read, Write, WriteRead} impls in src/i2c.rs. Pure deletion: −30 lines, no behavior change.

Why

  • The dependency was already annotated # TODO: remove this.
  • The removed impls were thin forwarders to the inherent blocking_read/blocking_write/blocking_write_read methods; the same functionality is covered by the embedded-hal 1.0 embedded_hal::i2c::I2c impl (blocking mode) and embedded_hal_async::i2c::I2c (async mode), which are untouched.
  • No other code in the HAL references eh 0.2, and no example uses it — all examples already consume eh 1.0 / eh-async traits.

Breaking change

Downstream code that passed I2c to drivers expecting eh 0.2 traits must switch to eh 1.0 (or use inherent methods / embassy-embedded-hal adapters). Acceptable for a 0.x HAL.

Note: embedded-hal 0.2.x may still appear in a resolver graph transitively (e.g. via embassy-time); that is outside this HAL's control.

Verification

Library, CI recipe (cargo build --features <chip>,embassy,rt,memory-x --no-default-features --target <target>), zero errors on all matrix chips:
ch32v103c8t6, ch32v203f8u6, ch32v208wbu6, ch32v303cbt6, ch32v305fbp6, ch32v307vct6, ch32x035f7p6, ch32l103c8t6, ch643 (riscv32imc); ch32v003f4u6, ch32v006k8u6, ch641 (riscv32i).

Example crates that exercise I2C build clean: ch32v003 (--release, as in CI; includes embassy_i2c_shared_bus), ch32v305 (blocking write_read), ch32v307 (all bins, including i2c-bmp180 on eh-async).

Cargo.lock unchanged. Commit is GPG-signed.

Closes #204

Remove the embedded-hal 0.2 dependency (previously marked 'TODO: remove
this') and the blocking i2c Read/Write/WriteRead impls that forwarded to
the inherent blocking_read/blocking_write/blocking_write_read methods.

This was the only remaining use of eh 0.2 in the HAL. All drivers and
examples already target embedded-hal 1.0 / embedded-hal-async 1.0, which
provide the same functionality via embedded_hal::i2c::I2c and
embedded_hal_async::i2c::I2c.

Downstream code that still relies on the eh 0.2 trait impls should
switch to the embedded-hal 1.0 traits. Note that embedded-hal 0.2.7 may
still appear in dependency graphs transitively (e.g. via embassy-time),
independently of this change.

Verified: cargo build for all CI chip targets (ch32v103c8t6,
ch32v203f8u6, ch32v208wbu6, ch32v303cbt6, ch32v305fbp6, ch32v307vct6,
ch32x035f7p6, ch32l103c8t6, ch643 on riscv32imc; ch32v003f4u6,
ch32v006k8u6, ch641 on riscv32i) and the i2c-using example crates
(ch32v003 release, ch32v305, ch32v307).
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.

Remove the embedded-hal 0.2 direct dependency

2 participants