Skip to content
sunsidedPublic

About

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

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

102 Commits

Folders and files

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 ci 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

release-plz does the releases (see CONTRIBUTING.md). Each merge to main updates a release PR. Merging it tags the changed crates (cst820-registers-vX.Y.Z, vX.Y.Z for cst820) and creates the GitHub Releases. Each tag runs the publish workflow, which publishes the crate to crates.io via trusted publishing (no API token in the repository).

The GitHub Release of cst820 also carries the Wokwi chip as chip.zip, with a build provenance attestation:

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

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages