[][src]Crate lpc8xx_hal

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.8"
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.8"
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.8"
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:

This example is not tested
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 nb;
pub extern crate void;
pub use lpc845_pac as pac;
pub use self::adc::ADC;
pub use self::ctimer::CTimer;
pub use self::gpio::GPIO;
pub use self::mrt::MRT;
pub use self::pmu::PMU;
pub use self::syscon::SYSCON;
pub use self::wkt::WKT;

Modules

adc

API for ADC

clock

Common types for system clocks

ctimer

API for the CTimer peripheral

delay

API for delays with the systick timer

dma

API for Direct Memory Access (DMA)

gpio

API for General Purpose I/O (GPIO)

i2c

API for the I2C peripherals

init_state

Contains types that encode the state of hardware initialization

mrt

API for the MRT peripheral

pinint

Interface to the pin interrupts/pattern matching engine

pins

API to control pins

pmu

API for the Power Management Unit (PMU)

prelude

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

sleep

Higher-level sleep API

spi

API for the SPI peripheral

swm

APIs for the switch matrix (SWM)

syscon

API for system configuration (SYSCON)

usart

API for USART

wkt

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

Structs

CorePeripherals

Core peripherals

DMA

Entry point to the DMA API

I2C

Interface to an I2C peripheral

PININT

Entry point to the PININT API

Peripherals

Provides access to all peripherals

SPI

Interface to a SPI peripheral

SWM

Entry point to the switch matrix (SWM) API

USART

Interface to a USART peripheral