[][src]Crate lpc82x_hal

LPC82x Hardware Abstraction Layer

Hardware Abstraction Layer (HAL) for the NXP LPC82x series of ARM Cortex-M0+ microcontrollers.

Using LPC82x HAL in a Library

Writing a library on top of LPC82x HAL is pretty simple. All you need to do is include it via Cargo, by adding the following to your Cargo.toml:

lpc82x-hal = "0.4"

With that in place, you can just reference the crate in your Rust code, like this:

// lib.rs

extern crate lpc82x_hal;

That's it! Now you can start using the LPC82x HAL APIs. Take a look at Peripherals, which is the entry point to the whole API.

Please note that LPC82x HAL is an implementation of embedded-hal. If your library is not specific to LPC82x, please consider depending on embedded-hal instead. Doing so means that your library should work on top of all embedded-hal implementations.

Using LPC82x HAL in an Application

To use LPC82x HAL in an application, you need to enable its rt feature. Add the following to your Cargo.toml:

version  = "0.4"
features = ["rt"]

How to upload your application to the microcontroller depends on the details of your specific case. If you happen to be using the LPCXpresso824-MAX development board, you can use the configuration in this repository to set up the uploading process. The following configuration files are relevant:

  • memory.x
  • .cargo/config
  • openocd.cfg
  • .gdbinit

If everything is set up correctly, you should be able to upload your application to the board using cargo run. You can test this out using one of the example in this repository, by running the following from the repository root:

This example is not tested
cargo run --release --features=rt --example gpio


There are a number of examples in the repository. A good place to start is the GPIO example.

If you have an LPCXpresso824-MAX development board connected via USB, you should be able to run any example like this:

This example is not tested
cargo run --release --features=rt --example gpio


Various places in this crate's documentation reference the LPC82x User manual, which is available from NXP.


pub extern crate lpc82x_pac as raw;
pub use self::dma::DMA;
pub use self::gpio::GPIO;
pub use self::i2c::I2C;
pub use self::pmu::PMU;
pub use self::swm::SWM;
pub use self::syscon::SYSCON;
pub use self::usart::USART;
pub use self::wkt::WKT;



Common types for system clocks


API for Direct Memory Access (DMA)


API for General Purpose I/O (GPIO)


API for the I2C peripherals


Contains types that encode the state of hardware initialization


API for the Power Management Unit (PMU)


Re-exports various traits that are required to use lpc82x-hal


Higher-level sleep API


APIs for the switch matrix (SWM)


API for system configuration (SYSCON)




API for the self-wake-up timer (WKT)



Provides access to all peripherals