psoc-rs
Rust drivers and hardware abstraction layer for Infineon PSOC microcontrollers.
Current status
This project currently supports all devices in the PSOC 6 and PSOC Control C3 families. Peripheral Access Crates generated by svd2pac (providing raw register access) are complete and available in the pacs/ directory and published to crates.io under the psoc-pac- prefix. The psoc crate provides linker scripts, startup code, and (mostly complete) clock configuration for all devices in supported families, and flashing and debugging is supported through probe-rs.
However, HAL abstractions and drivers are currently minimal and in a very early alpha state. Currently, only clocking and GPIO are implemented, and breaking changes are likely as the design evolves. We will continue to add more drivers and supported device families over time, and we welcome contributions as well.
If you are interested in a particular device or driver, please open an issue!
Getting started
To build an application from scratch, add psoc as a dependency in your Cargo.toml and
specify your device with a feature flag. You'll also need
cortex-m-rt, and a panic handler such as
panic-halt or
panic-probe.
[]
= { = "0.1", = ["device-psc3m5fds2afq1"] }
= "0.7.5"
= "1.0.0"
Specify flashing, linker, and target options in .cargo/config.toml:
[]
= ["probe-rs", "run", "--log-format=oneline", "--speed=16000"]
[]
= [
"-Clink-arg=-Tpsoc.x",
"-Clink-arg=-Tdefmt.x",
"-C", "link-arg=--nmagic"
]
# Pick ONE of these for your target
# target = "thumbv6m-none-eabi" # Cortex-M0/M0+
# target = "thumbv7m-none-eabi" # Cortex-M3
# target = "thumbv7em-none-eabi" # Cortex-M4/M7 (no FPU)
# target = "thumbv7em-none-eabihf" # Cortex-M4/M7 (with FPU)
# target = "thumbv8m.main-none-eabi" # Cortex-M33/M55/M85 (no FPU)
= "thumbv8m.main-none-eabihf" # Cortex-M33/M55/M85 (with FPU)
Write a main function and initialize the device:
use panic_halt as _;
!
Install probe-rs, and flash with cargo flash --release.
See the example applications for examples on how to structure applications and BSPS, and recommended configuration for improved compiler optimizations and IDE integration.
Important note about documentation
The documentation available on docs.rs only covers a single chip (PSC3M5FDS2AFQ1, a PSOC Control C3 device). Available drivers and APIs vary across devices. It is recommended to build documentation locally for your specific chip by running cargo doc --open in your project.
Contributing
Contributions are welcome; feel free to open a PR!
Helpful resources:
docs/ARCHITECTURE.mdfor an overview of the codebase's structure, terminology, and style- Hardware documentation:
- ModusToolbox Peripheral Driver Library (in C, not used directly by this project but useful to cross-reference
Be sure to test your changes using scripts/check_all.rs to ensure your code compiles across all supported devices.