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

source

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.
source

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.
source

pub const fn is_zero(&self) -> bool

Returns true if this Config was created using zero(), meaning that it will zero any unspecified fields. If false, this config was created using modify(), which will not touch unspecified fields.

use imxrt_iomuxc::Config;

assert!(Config::zero().is_zero());
assert!(!Config::modify().is_zero());
source

pub const fn set_hysteresis(self, hys: Hysteresis) -> Self

Set the hysteresis bit

source

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.

source

pub const fn set_pullupdown(self, pud: PullUpDown) -> Self

👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper

Set the pull-up / pull-down value

source

pub const fn set_pull_keep_select(self, pke: PullKeepSelect) -> Self

👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper

Set the the pull-up / pull-down or keeper selection bit

source

pub const fn set_pull_keep(self, pk: PullKeep) -> Self

👎Deprecated since 0.2.0: Use PullKeeper and Config::set_pull_keeper

Set the flag that enables the keeper or pull-up / pull-down configuration

source

pub const fn set_open_drain(self, od: OpenDrain) -> Self

Set the open drain value

source

pub const fn set_speed(self, speed: Speed) -> Self

Set the pin speed

source

pub const fn set_drive_strength(self, dse: DriveStrength) -> Self

Set the drive strength

source

pub const fn set_slew_rate(self, sre: SlewRate) -> Self

Set the slew rate

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Config

source§

fn eq(&self, other: &Config) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Config

source§

impl Eq for Config

source§

impl StructuralEq for Config

source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.