Expand description
Build script support for the imxrt-iomuxc
crate
§Audience
This crate is intended for i.MX RT IOMUXC crate developers. End users should not use this crate directly.
§Generate type aliases
Create type aliases for processor pads. Use a combination of PadRange
and write_pads()
in a build script to generate your module. Then, include!
it
in your crate.
For example, a build.rs
build script resembling
// ~~ build.rs ~~
use imxrt_iomuxc_build as build;
use std::{env, fs, io, path::PathBuf};
fn main() -> io::Result<()> {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let mut pads_rs = fs::File::create(out_dir.join("pads.rs"))?;
let emc = build::PadRange::new("EMC", 0..42);
let ad_b0 = build::PadRange::new("AD_B0", 0..16);
let ad_b1 = build::PadRange::new("AD_B1", 0..16);
let b0 = build::PadRange::new("B0", 0..16);
let b1 = build::PadRange::new("B1", 0..16);
let sd_b0 = build::PadRange::new("SD_B0", 0..6);
let sd_b1 = build::PadRange::new("SD_B1", 0..12);
build::write_pads(
&mut pads_rs,
vec![&emc, &ad_b0, &ad_b1, &b0, &b1, &sd_b0, &sd_b1],
)?;
Ok(())
}
would generate type aliases that could be included in your lib.rs
ⓘ
// ~~ lib.rs ~~
include!(concat!(env!("OUT_DIR"), "/pads.rs"));
See the write_pads()
function for details on the generated module.
§Implement GPIO Pin
traits
For the type aliases created in crate type aliases, you can implement
GPIO Pin
traits by using ImplGpioPin
and write_impl_gpio_pins()
.
build::write_impl_gpio_pins(
&mut pads_rs,
vec![
// GPIO1
build::ImplGpioPin::from_range(&ad_b0, build::GpioRange::no_offset(1, 5)),
build::ImplGpioPin::from_range(&ad_b1, build::GpioRange {
module: 1,
offset: 16,
alt: 5,
}),
// GPIO2
build::ImplGpioPin::from_range(&b0, build::GpioRange::no_offset(2, 5)),
build::ImplGpioPin::from_range(&b1, build::GpioRange {
module: 2,
offset: 16,
alt: 5,
}),
],
).unwrap();
Structs§
- Gpio
Range - Defines a GPIO range
- Impl
Gpio Pin - A type that describes how to
impl gpio::Pin
for a series of pads - PadRange
- Defines a range of i.MX RT pads
Functions§
- write_
impl_ gpio_ pins - Write the
impl gpio::Pin for Pad
implementations for all providedImplGpioPin
descriptions - write_
pads - Write type for all pad
ranges
to the provided writer,out