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):
- Select a less specific target.
- 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 self::adc::ADC;
pub use self::ctimer::CTIMER;
pub use self::dma::DMA;
pub use self::gpio::GPIO;
pub use self::i2c::I2C;
pub use self::mrt::MRT;
pub use self::pinint::PININT;
pub use self::pmu::PMU;
pub use self::spi::SPI;
pub use self::swm::SWM;
pub use self::syscon::SYSCON;
pub use self::usart::USART;
pub use self::wkt::WKT;
pub use lpc845_pac as pac;
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 (Multi-Rate Timer) 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§
- Core
Peripherals - Core peripherals
- Peripherals
- Provides access to all peripherals