Expand description

LPC8xx HAL

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

Adding LPC8xx HAL as a dependency

To use LPC8xx HAL in your project, you need to include it via Cargo, by adding a dependency to you Cargo.toml:

[dependencies.lpc8xx-hal]
version  = "0.9"
features = ["824m201jhi33"]

The above adds a dependency on the lpc8xx-hal crate and selects your target hardware. To find out which targets are supported, please check out the list of targets in our Cargo.toml.

In principle, there are two things you might want to do differently in your project (besides selecting another target):

  1. Select a less specific target.
  2. Enable runtime support.

If you’re writing an application or library that can work with (part of) a family you can select that instead:

[dependencies.lpc8xx-hal]
version  = "0.9"
features = ["82x"]

This selects the LPC82x family. Only the hardware resources available on all targets within that family will be provided, while the actual target hardware you’re running on might have more peripherals or more memory.

Again, check out Cargo.toml for a list of options.

If you want to use LPC8xx HAL in an application (as opposed to a library), you probably need to enable runtime support. You can do this by passing the runtime feature for your selected family:

[dependencies.lpc8xx-hal]
version  = "0.9"
features = ["824m201jhi33", "82x-rt"]

Again, the available options are listed in Cargo.toml.

Please note that LPC8xx HAL is an implementation of embedded-hal. If you are writing code that is not specific to LPC800, please consider depending on embedded-hal instead.

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

Examples

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:

cargo run --release --features=82x-rt --example gpio_simple

Other documentation

Please refer to the Embedded Rust Book for further documentation on how to use embedded Rust. The book does not use LPC8xx HAL as an example, but most of what you learn their will transfer over to this crate.

References

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

Re-exports

pub extern crate cortex_m;
pub extern crate embedded_hal;
pub extern crate embedded_hal_alpha;
pub extern crate embedded_time;
pub extern crate nb;
pub extern crate void;
pub use lpc845_pac as pac;
pub use self::adc::ADC;
pub use self::gpio::GPIO;
pub use self::pmu::PMU;
pub use self::syscon::SYSCON;
pub use self::wkt::WKT;

Modules

API for ADC
Common types for system clocks
API for the CTIMER peripheral
API for delays with the systick timer
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 MRT (Multi-Rate Timer) peripheral
Interface to the pin interrupts/pattern matching engine
API to control pins
API for the Power Management Unit (PMU)
Re-exports various traits that are required to use lpc8xx-hal
Higher-level sleep API
API for the SPI peripheral
APIs for the switch matrix (SWM)
API for system configuration (SYSCON)
API for USART
API for the self-wake-up timer (WKT)

Structs

Interface to a CTimer peripheral
Core peripherals
Entry point to the DMA API
Interface to an I2C peripheral
Represents the MRT instance
Entry point to the PININT API
Provides access to all peripherals
Interface to a SPI peripheral
Entry point to the switch matrix (SWM) API
Interface to a USART peripheral