Skip to content
sunsidedPublic

About

Rust driver and register map for the Hynitron CST820 touch controller, with Wokwi emulation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Hynitron CST820 Touch Controller

Build Status codecov

Platform-agnostic Rust support for the Hynitron CST820 self-capacitive touch controller.

Crate Description
cst820-registers A typed map of the CST820's I²C registers.
cst820 An embedded-hal 1.0 driver (blocking and async).
cst820-sim A behavioral model of the chip for tests and emulation.

The CST820 datasheet (V1.2) documents the I²C protocol and timing, but not the register map. The register map used here follows the CST816 family, which the CST820 is compatible with.

Emulation

The behavioral model in cst820-sim is used both as a fake I²C bus in host tests and as a Wokwi custom chip (sim/wokwi-chip). Example firmware in examples/ runs against the emulated chip using wokwi-cli.

Try it in the browser: an ESP32-C3 talking to the emulated CST820 on wokwi.com. Click the chip to drive touches and gestures.

Use the chip in your own Wokwi project

Every GitHub Release carries the chip as chip.zip. Add a chip-cst820 part and this dependency to your diagram.json, with the latest release version written without the tag's v (@v0.2.2 fails to load):

"dependencies": { "chip-cst820": "github:sunsided/cst820@0.2.2" }

This works on wokwi.com, in the Wokwi VS Code extension and with wokwi-cli; nothing needs to be built.

Run the example locally

Needs wokwi-cli and a WOKWI_CLI_TOKEN from the Wokwi CI dashboard:

sim/wokwi-chip/build.sh
cd examples/esp32c3
cargo build --release
wokwi-cli . --scenario scenarios/touch.yaml --timeout 10000

sim/wokwi-chip describes building the chip and its pins; examples/esp32c3 the wiring and the scenario.

Development

The Taskfile wraps the common commands: task check and task test run what CI runs, task sim builds the Wokwi chip and the ESP32-C3 firmware and runs the touch scenario. task lists everything.

Releasing

Both crates share one version. From main, with the changes listed under ## [Unreleased] in each crate's CHANGELOG.md:

cargo release <patch|minor|major>            # dry run
cargo release <patch|minor|major> --execute

This commits Release X.Y.Z and pushes the tag vX.Y.Z. The tag runs the release workflow, which publishes cst820-registers and cst820 to crates.io via trusted publishing (no API token in the repository) and then creates a GitHub Release named X.Y.Z with the changelog sections as notes.

Each GitHub Release carries the packaged .crate files and the Wokwi chip as chip.zip, all with build provenance attestations:

gh attestation verify chip.zip -R sunsided/cst820

Code of Conduct

We abide by the Contributor Covenant and ask that you do as well.

License

Copyright © 2026 Markus Mayer

Triple licensed under your choice of either of:

About

Rust driver and register map for the Hynitron CST820 touch controller, with Wokwi emulation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages