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.
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.
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.
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 10000sim/wokwi-chip describes building the chip and its pins;
examples/esp32c3 the wiring and the scenario.
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.
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> --executeThis 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/cst820We abide by the Contributor Covenant and ask that you do as well.
Copyright © 2026 Markus Mayer
Triple licensed under your choice of either of:
- European Union Public Licence, Version 1.2, (LICENSE-EUPL or https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)