[−][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
:
[dependencies]
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
:
[dependencies.lpc82x-hal]
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:
cargo run --release --features=rt --example gpio
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=rt --example gpio
References
Various places in this crate's documentation reference the LPC82x User manual, which is available from NXP.
Re-exports
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; |
Modules
clock | Common types for system clocks |
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 |
pmu | API for the Power Management Unit (PMU) |
prelude | Re-exports various traits that are required to use lpc82x-hal |
sleep | Higher-level sleep API |
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
Peripherals | Provides access to all peripherals |