Struct imxrt_iomuxc::Config
source · pub struct Config { /* private fields */ }
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§
source§impl Config
impl Config
sourcepub const fn zero() -> Self
pub const fn zero() -> Self
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
};
// Set a configuration
configure(
&mut gpio_ad_b0_13,
Config::zero()
.set_slew_rate(SlewRate::Fast)
.set_drive_strength(DriveStrength::R0_7)
);
// DriveStrength::R0_7 as u32 | SlewRate::Fast as u32
// Completely change that configuration
configure(
&mut gpio_ad_b0_13,
Config::zero()
.set_hysteresis(Hysteresis::Enabled)
.set_pull_keeper(Some(PullKeeper::Pullup22k))
);
// Hysteresis::Enabled as u32 | PullKeeper::Pullup22k as u32
//
// Notice that SlewRate and DriveStrength were set to zero.
sourcepub const fn modify() -> Self
pub const fn modify() -> Self
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};
// Assume a starting value in the register...
configure(
&mut gpio_ad_b0_13,
Config::zero()
.set_slew_rate(SlewRate::Fast)
.set_drive_strength(DriveStrength::R0_7)
);
// DriveStrength::R0_7 as u32 | SlewRate::Fast as u32
// Now change the slew rate, and add hysteresis
configure(
&mut gpio_ad_b0_13,
Config::modify()
.set_slew_rate(SlewRate::Slow)
.set_hysteresis(Hysteresis::Enabled)
);
// DriveStrength::R0_7 as u32 | Hysteresis::Enabled as u32
//
// Notice that the DriveStrength field is preserved.
sourcepub const fn set_hysteresis(self, hys: Hysteresis) -> Self
pub const fn set_hysteresis(self, hys: Hysteresis) -> Self
Set the hysteresis bit
sourcepub const fn set_pull_keeper(self, pk: Option<PullKeeper>) -> Self
pub const fn set_pull_keeper(self, pk: Option<PullKeeper>) -> Self
Set the pull up / pull down / keeper configuration.
A None
value disables the pull / keeper function.
sourcepub const fn set_pullupdown(self, pud: PullUpDown) -> Self
👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper
pub const fn set_pullupdown(self, pud: PullUpDown) -> Self
Set the pull-up / pull-down value
sourcepub const fn set_pull_keep_select(self, pke: PullKeepSelect) -> Self
👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper
pub const fn set_pull_keep_select(self, pke: PullKeepSelect) -> Self
Set the the pull-up / pull-down or keeper selection bit
sourcepub const fn set_pull_keep(self, pk: PullKeep) -> Self
👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper
pub const fn set_pull_keep(self, pk: PullKeep) -> Self
Set the flag that enables the keeper or pull-up / pull-down configuration
sourcepub const fn set_open_drain(self, od: OpenDrain) -> Self
pub const fn set_open_drain(self, od: OpenDrain) -> Self
Set the open drain value
sourcepub const fn set_drive_strength(self, dse: DriveStrength) -> Self
pub const fn set_drive_strength(self, dse: DriveStrength) -> Self
Set the drive strength
sourcepub const fn set_slew_rate(self, sre: SlewRate) -> Self
pub const fn set_slew_rate(self, sre: SlewRate) -> Self
Set the slew rate