[Rust] register mappings for the [NXP LPC82x] family of ARM Cortex-M0+ microcontrollers. The code is generated automatically from the [SVD file] available from ARM, using [svd2rust].
The purpose of this crate is to give embedded programs or libraries written in the Rust programming access to the complete functionality of LPC82x MCUs.
Add this to the [dependencies]
section of your Cargo.toml
to include rust-lpc82x in your Cargo project:
toml
lpc82x = "0.1"
This crate includes an optional rt
feature that can be activated by instead adding the following snippet to your Cargo.toml
:
toml
[dependencies.lpc82x]
version = "0.1"
features = ["rt"]
The rt
feature includes the [cortex-m-rt] crate and provides overridable interrupt handlers. Please refer to the [svd2rust documentation] for further details.
Here's a simple example that could be extended into an embedded program that blinks an LED.
``` rust extern crate lpc82x;
// This bit represents the PIO0_3 pin. We could connect an LED there. const PIN: u32 = 0x1 << 3;
// Get a reference to the GPIOPORT peripheral let gpio = lpc82x::GPIOPORT.get();
unsafe { // Set pin direction to "output" (*gpio).dir0.modify(|r, w| w.dirp().bits(r.dirp().bits() | PIN));
loop {
// Set pin to HIGH
(*gpio).set0.modify(|r, w| w.setp().bits(r.setp().bits() | PIN));
// Set pin to LOW
(*gpio).clr0.write(|w| w.clrp().bits(PIN));
}
} ```
For specific information on the API, check out the [API reference].
All code in this crate is automatically generated by [svd2rust], so check out [svd2rust documentation] for more general information about how the API works.
This crate is complete and actively maintained, but not all parts of it have been tested. Please [open an issue], if you find any problems. Feel free to check the [list of open issues] for any known problems.
At this point, there is no guarantee of API stability. This means that we reserve the right to make changes to the API, that might break existing programs when they upgrade.
You need a nightly version of Rust to use this crate. If you installed Rust via [rustup], you can switch to the nightly version with rustup default nightly
.
The repository contains an [update script], that can be used to re-generate the source code. This script updates all required tools ([svd2rust] and [rustfmt]), downloads the [SVD file], applies various patches to it, and re-generates the code.
The patches that are applied to the SVD file are relatively minimal, and are just intended to fix various problems with the file that otherwise would prevent code generation, or would lead to incorrect code being generated.
This project is open source software, licensed under the terms of the [0BSD license]. This basically means you do anything with the software, without any restrictions, but you can't hold the authors liable for any problems.
Please refer to [LICENSE] for full details.
Supported by [Braun Robotics]