Struct imxrt_iomuxc::Config [−][src]
pub struct Config { /* fields omitted */ }
Expand description
A configuration capable of compile-time, const
configuration:
use imxrt_iomuxc::{Config, SlewRate, Hysteresis};
const UART_TX_CONFIG: Config = Config::zero()
.set_slew_rate(SlewRate::Fast)
.set_hysteresis(Hysteresis::Enabled);
Use configure()
to set configurations to pads.
Implementations
Create a Config
that will zero any unspecified field
This may not represent any register’s reset value. A config that’s
created using zero()
will have the effect of writing all fields
to the register. Those that are not set explicitly set are written as zero.
use imxrt_iomuxc::{
Config, configure, SlewRate,
Hysteresis, PullKeeper, DriveStrength
};
unsafe {
// Set a configuration
configure(
&mut ad_b0_13,
Config::zero()
.set_slew_rate(SlewRate::Fast)
.set_drive_strength(DriveStrength::R0_7)
);
assert_eq!(
*ad_b0_13.pad(),
DriveStrength::R0_7 as u32 | SlewRate::Fast as u32
);
// Completely change that configuration
configure(
&mut ad_b0_13,
Config::zero()
.set_hysteresis(Hysteresis::Enabled)
.set_pull_keeper(Some(PullKeeper::Pullup22k))
);
assert_eq!(
*ad_b0_13.pad(),
Hysteresis::Enabled as u32 | PullKeeper::Pullup22k as u32
);
}
Create a Config
that will only modify the specified fields
Any field that is is not specified in the configuration will not be touched.
use imxrt_iomuxc::{Config, configure, SlewRate, DriveStrength, Hysteresis};
unsafe {
// Assume a starting value in the register...
configure(
&mut ad_b0_13,
Config::zero()
.set_slew_rate(SlewRate::Fast)
.set_drive_strength(DriveStrength::R0_7)
);
assert_eq!(
*ad_b0_13.pad(),
DriveStrength::R0_7 as u32 | SlewRate::Fast as u32
);
// Now change the slew rate, and add hysteresis
configure(
&mut ad_b0_13,
Config::modify()
.set_slew_rate(SlewRate::Slow)
.set_hysteresis(Hysteresis::Enabled)
);
assert_eq!(
*ad_b0_13.pad(),
DriveStrength::R0_7 as u32 | Hysteresis::Enabled as u32
);
}
Set the hysteresis bit
Set the pull up / pull down / keeper configuration.
A None
value disables the pull / keeper function.
Set the pull-up / pull-down value
Set the the pull-up / pull-down or keeper selection bit
Set the flag that enables the keeper or pull-up / pull-down configuration
Set the open drain value
Set the drive strength
Set the slew rate