Skip to content

Conversation

@Grazfather
Copy link
Collaborator

@Grazfather Grazfather commented Jan 4, 2026

  • Add support to verify (at comptime) that a peripheral can be assigned to a specific DMA channel.
  • Run ch32v port tests in CI
  • Add i2c_position_sensor example
  • Add support for DMA in I2C hal
  • Add support for DMA I2C in I2CDevice

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

Found 4 issues on changed lines in 3 files:

  • examples/wch/ch32v/src/i2c_accel.zig: 2 issues
  • examples/wch/ch32v/src/i2c_dma.zig: 1 issue
  • port/wch/ch32v/src/hals/i2c.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 24 issue(s) exist but are not on lines changed in this PR:

drivers/sensor/ICM-20948.zig:27: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:200: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:208: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:230: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:494: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:535: Suggestion: Rename `Accel_data_unscaled` to `AccelDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:556: Suggestion: Rename `Accel_data` to `AccelData`, 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.
drivers/sensor/ICM-20948.zig:599: Suggestion: Rename `Gyro_data_unscaled` to `GyroDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:620: Suggestion: Rename `Gyro_data` to `GyroData`, 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.
drivers/sensor/ICM-20948.zig:827: Suggestion: Rename `Mag_data_unscaled` to `MagDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:868: Suggestion: Rename `Mag_data` to `MagData`, 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.
drivers/sensor/ICM-20948.zig:886: Suggestion: Rename `TestI2CDevice` to `Test_I2C_Device`, 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.
port/wch/ch32v/build.zig:3: Suggestion: Rename `CpuName` to `CPU_Name`, 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.
port/wch/ch32v/build.zig:10: Suggestion: Rename `KiB` to `Ki_B`, 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.
port/wch/ch32v/src/hals/dma.zig:18: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:47: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:258: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:16: Suggestion: Rename `DmaRegs` to `DMA_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.
port/wch/ch32v/src/hals/drivers.zig:14: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:15: Suggestion: Rename `Stream_Device` to `StreamDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:17: Suggestion: Rename `Clock_Device` to `ClockDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:18: Suggestion: Rename `I2CError` to `I2C_Error`, 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.
port/wch/ch32v/src/hals/drivers.zig:19: Suggestion: Rename `I2CAddress` to `I2C_Address`, 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.
port/wch/ch32v/src/hals/i2c.zig:17: 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.

@github-actions github-actions bot dismissed their stale review January 4, 2026 15:39

Updating with new lint results

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

Found 2 issues on changed lines in 2 files:

  • examples/wch/ch32v/src/i2c_dma.zig: 1 issue
  • port/wch/ch32v/src/hals/i2c.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 24 issue(s) exist but are not on lines changed in this PR:

drivers/sensor/ICM-20948.zig:27: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:200: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:208: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:230: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:494: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:535: Suggestion: Rename `Accel_data_unscaled` to `AccelDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:556: Suggestion: Rename `Accel_data` to `AccelData`, 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.
drivers/sensor/ICM-20948.zig:599: Suggestion: Rename `Gyro_data_unscaled` to `GyroDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:620: Suggestion: Rename `Gyro_data` to `GyroData`, 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.
drivers/sensor/ICM-20948.zig:827: Suggestion: Rename `Mag_data_unscaled` to `MagDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:868: Suggestion: Rename `Mag_data` to `MagData`, 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.
drivers/sensor/ICM-20948.zig:886: Suggestion: Rename `TestI2CDevice` to `Test_I2C_Device`, 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.
port/wch/ch32v/build.zig:3: Suggestion: Rename `CpuName` to `CPU_Name`, 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.
port/wch/ch32v/build.zig:10: Suggestion: Rename `KiB` to `Ki_B`, 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.
port/wch/ch32v/src/hals/dma.zig:18: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:47: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:258: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:16: Suggestion: Rename `DmaRegs` to `DMA_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.
port/wch/ch32v/src/hals/drivers.zig:14: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:15: Suggestion: Rename `Stream_Device` to `StreamDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:17: Suggestion: Rename `Clock_Device` to `ClockDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:18: Suggestion: Rename `I2CError` to `I2C_Error`, 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.
port/wch/ch32v/src/hals/drivers.zig:19: Suggestion: Rename `I2CAddress` to `I2C_Address`, 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.
port/wch/ch32v/src/hals/i2c.zig:17: 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.

@github-actions github-actions bot dismissed their stale review January 5, 2026 00:17

Updating with new lint results

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

Found 2 issues on changed lines in 2 files:

  • examples/wch/ch32v/src/i2c_dma.zig: 1 issue
  • port/wch/ch32v/src/hals/i2c.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 24 issue(s) exist but are not on lines changed in this PR:

drivers/sensor/ICM-20948.zig:27: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:200: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:208: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:230: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:494: TODO style comments need to have a linked microzig issue on the same line.
drivers/sensor/ICM-20948.zig:535: Suggestion: Rename `Accel_data_unscaled` to `AccelDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:556: Suggestion: Rename `Accel_data` to `AccelData`, 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.
drivers/sensor/ICM-20948.zig:599: Suggestion: Rename `Gyro_data_unscaled` to `GyroDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:620: Suggestion: Rename `Gyro_data` to `GyroData`, 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.
drivers/sensor/ICM-20948.zig:827: Suggestion: Rename `Mag_data_unscaled` to `MagDataUnscaled`, 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.
drivers/sensor/ICM-20948.zig:868: Suggestion: Rename `Mag_data` to `MagData`, 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.
drivers/sensor/ICM-20948.zig:886: Suggestion: Rename `TestI2CDevice` to `Test_I2C_Device`, 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.
port/wch/ch32v/build.zig:3: Suggestion: Rename `CpuName` to `CPU_Name`, 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.
port/wch/ch32v/build.zig:10: Suggestion: Rename `KiB` to `Ki_B`, 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.
port/wch/ch32v/src/hals/dma.zig:18: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:47: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:263: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:16: Suggestion: Rename `DmaRegs` to `DMA_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.
port/wch/ch32v/src/hals/drivers.zig:14: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:15: Suggestion: Rename `Stream_Device` to `StreamDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:17: Suggestion: Rename `Clock_Device` to `ClockDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:18: Suggestion: Rename `I2CError` to `I2C_Error`, 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.
port/wch/ch32v/src/hals/drivers.zig:19: Suggestion: Rename `I2CAddress` to `I2C_Address`, 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.
port/wch/ch32v/src/hals/i2c.zig:17: 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.

@github-actions github-actions bot dismissed their stale review January 5, 2026 22:36

Updating with new lint results

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

Found 2 issues on changed lines in 2 files:

  • examples/wch/ch32v/src/i2c_dma.zig: 1 issue
  • port/wch/ch32v/src/hals/i2c.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 12 issue(s) exist but are not on lines changed in this PR:

port/wch/ch32v/build.zig:3: Suggestion: Rename `CpuName` to `CPU_Name`, 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.
port/wch/ch32v/build.zig:10: Suggestion: Rename `KiB` to `Ki_B`, 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.
port/wch/ch32v/src/hals/dma.zig:18: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:47: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:263: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:16: Suggestion: Rename `DmaRegs` to `DMA_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.
port/wch/ch32v/src/hals/drivers.zig:14: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:15: Suggestion: Rename `Stream_Device` to `StreamDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:17: Suggestion: Rename `Clock_Device` to `ClockDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:18: Suggestion: Rename `I2CError` to `I2C_Error`, 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.
port/wch/ch32v/src/hals/drivers.zig:19: Suggestion: Rename `I2CAddress` to `I2C_Address`, 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.
port/wch/ch32v/src/hals/i2c.zig:17: 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.

@Grazfather Grazfather marked this pull request as ready for review January 5, 2026 22:38
@github-actions github-actions bot dismissed their stale review January 5, 2026 22:38

Updating with new lint results

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

Found 1 issue on changed lines in 1 file:

  • port/wch/ch32v/src/hals/i2c.zig: 1 issue
ℹ️ Additional issues on unchanged lines
The following 12 issue(s) exist but are not on lines changed in this PR:

port/wch/ch32v/build.zig:3: Suggestion: Rename `CpuName` to `CPU_Name`, 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.
port/wch/ch32v/build.zig:10: Suggestion: Rename `KiB` to `Ki_B`, 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.
port/wch/ch32v/src/hals/dma.zig:18: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:47: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:263: TODO style comments need to have a linked microzig issue on the same line.
port/wch/ch32v/src/hals/dma.zig:16: Suggestion: Rename `DmaRegs` to `DMA_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.
port/wch/ch32v/src/hals/drivers.zig:14: Suggestion: Rename `Datagram_Device` to `DatagramDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:15: Suggestion: Rename `Stream_Device` to `StreamDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:17: Suggestion: Rename `Clock_Device` to `ClockDevice`, 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.
port/wch/ch32v/src/hals/drivers.zig:18: Suggestion: Rename `I2CError` to `I2C_Error`, 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.
port/wch/ch32v/src/hals/drivers.zig:19: Suggestion: Rename `I2CAddress` to `I2C_Address`, 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.
port/wch/ch32v/src/hals/i2c.zig:17: 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.

Copy link
Collaborator

@tact1m4n3 tact1m4n3 left a comment

Choose a reason for hiding this comment

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

Looks good to me. My comments are mostly related to code style because I am unfamiliar with ch32v chips. I like that you used comptime a lot (I assume because of the space constraints, right?). Maybe we should use it more in other hals as well

@Grazfather
Copy link
Collaborator Author

Looks good to me. My comments are mostly related to code style because I am unfamiliar with ch32v chips. I like that you used comptime a lot (I assume because of the space constraints, right?). Maybe we should use it more in other hals as well

@tact1m4n3
Thank you. Good suggestions.

ch32fun made me very aware of how tiny we can make the code if we try, but also the fact that I can't build most examples in debug more makes it clearer still. The comptime stuff very nicely cleaves off a bunch of code, and of course, there are performance implications of making these branches at run time.

@Grazfather
Copy link
Collaborator Author

Re-tested on hardware with the small refactor.

@Grazfather Grazfather merged commit af5fd50 into main Jan 7, 2026
55 checks passed
@Grazfather Grazfather deleted the wch_i2c_dma branch January 7, 2026 17:57
Copper280z pushed a commit to Copper280z/microzig that referenced this pull request Jan 11, 2026
- Add support to verify (at comptime) that a peripheral can be assigned
to a specific DMA channel.
- Run ch32v port tests in CI
- Add i2c_position_sensor example
- Add support for DMA in I2C hal
- Add support for DMA I2C in I2CDevice
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