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 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.
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/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)