PR welcome!
Hardware Abstraction Layer crate for the lpc546xx family.
This crate relies on the lpc546xx-pac crate to provide appropriate register definition and implements a partial set of embedded-hal traits.
Add the lpc546xx-hal
crate to your dependencies in your Cargo.toml and make sure to pick the appropriate mcu-*
feature to enjoy the full feature set for your MCU.
For example, for the LPCXpresso54608 board that sports a LPC54608J512ET180:
lpc546xx-hal = { version = "0.2.0", features = ["mcu-LPC54608J512ET180", "rt"] }
This will select the appropriate memory.x linker script depending on both your RAM and FLASH, the correct feature set from the peripheral access crate, and the correct interrupt vector for your device. You can disable this feature using the disable-linker-script
feature.
If you look into Cargo.toml
file, you will see the supported devices.
If you want to run an example, you can run it by using:
$ cargo run --example gpio --features=mcu-LPC54608J512ET180,rt
This HAL will also include a __pre_init
stub in src/lib.rs
to be called by cortex-m-rt when the "rt" feature is enabled. In this stub all the rams are turned on. You can disable this feature by using the disable-pre-init-blob
feature. But you should do it yourself, otherwise your program will not boot, as cortex-m-rt
will try to init memory regions that are not enabled.
In order to use this HAL, you need the following Setup:
-
Install Rustup
See rustup.rs for details. You may als be able to install Rustup directly through your distro.
-
Install the
arm-none-eabi
compiler toolchainhttps://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
If you cannot install the toolchain directly through your OS / distro, we recommend installing the precompiled binaries to '/usr/local/opt'. Add the bin folders (/bin & /arm-none-eabi/bin) to your environments variable 'PATH'.
-
Install the
thumbv7em-none-eabi/hf
target for RustSimply run
rustup target add thumbv7em-none-eabi
orrustup target add thumbv7em-none-eabihf
For more instructions on how to get started with ARM / Cortex-M programming using Rust, check out the Embedded Rust Book.
You can build examples through Cargo:
$ cargo build --example gpio --features="mcu-LPC54608J512ET180,rt"
Note that not all examples are compatible with all MCUs. You might need to peek into the example source code.
0-Clause BSD License, see LICENSE-0BSD.txt for more details.