This repository provides Rust device support crates for some LPC microcontrollers, providing an API to that device's peripherals using svd2rust and the SVD files from NXP. These crates are commonly known as peripheral access crates or "PACs".
Not every register of each device will have been tested on hardware, and so errors or omissions may remain. Please report any bugs you find, or open a PR!
In your own project's Cargo.toml
:
[dependencies.lpc546xx-pac]
version = "x.y.z"
features = ["lpc54608", "rt"]
The rt
feature is optional but helpful. see svd2rust for details.
Then, in your code:
use lpc54606_pac as pac;
let mut peripherals = pac::Peripherals::take().unwrap();
Refer to svd2rust
documentation for further usage.
Replace lpc54606_pac
with your own device; see the individual crate READMEs for the complete list of supported devices.
cargo install --version 0.25.0 svd2rust
cargo install form --version 0.10.0
rustup component add rustfmt
cargo install svdtools --version 0.2.7
cd svd; ./extract.sh; cd ..
make patch -j8
make svd2rust -j8
make form -j8
svd2rust
: cargo install --version 0.24.0 svd2rust
form
: cargo install --version 0.8.0
rustfmt
: rustup component add rustfmt
./generate.sh
svd/vendor
to include new SVD.svd/extract.sh
to extract the zips into svd
(ignored in git).devices/
with the new SVD path and include any
required SVD patches for this device, such as renaming or merging fields.lpc_part_table
Makefile
> PACS
scripts/makecrates.py
> scripts/makecrates.py devices/
to update the crates with the new devices.make
to rebuild, which will make a patched SVD and then run svd2rust
on it to generate the final library.svd/extract.sh
at least once to pull the SVDs out.make
to rebuild all the crates using svd patch
and svd2rust
.cd lpc546xx-pac; cargo build --features lpc54628