Skip to content

ch32v: i2c: Fix setting NACK#826

Merged
mattnite merged 1 commit intomainfrom
wch_i2c_fix
Jan 2, 2026
Merged

ch32v: i2c: Fix setting NACK#826
mattnite merged 1 commit intomainfrom
wch_i2c_fix

Conversation

@Grazfather
Copy link
Collaborator

The ch32v chips borrow a lot from the STM32 peripherals, and so I was able to take a lot from the stm32 hal. It seems, however, that they diverge in the behaviour here: The STM32 I2C HALs I read check signal BTF, rather than RxNE, and they set the NACK a byte earlier.

Noticed this while playing with the ICM-20948 driver. My original PR was only tested lightly with i2c-bus-scan, which never had to do reads over 1 byte.

The ch32v chips borrow a lot from the STM32 peripherals, and so I was
able to take a lot from the stm32 hal. It seems, however, that they
diverge in the behaviour here: The STM32 I2C HALs I read check
signal BTF, rather than RxNE, so they set the NACK a byte earlier.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🔍 Lint Results

ℹ️ Additional issues on unchanged lines
The following 1 issue(s) exist but are not on lines changed in this PR:

port/wch/ch32v/src/hals/i2c.zig:16: Suggestion: Rename `I2cRegs` to `I2C_Regs`, it _should_ be more in line with our [style guidelines](https://microzig.tech/docs/contributing/). This automation is not perfect so take it with a grain of salt.

@mattnite mattnite merged commit bb06c65 into main Jan 2, 2026
52 checks passed
@mattnite mattnite deleted the wch_i2c_fix branch January 2, 2026 23:50
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.

2 participants