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§

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.

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.

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());

Set the hysteresis bit

Set the pull up / pull down / keeper configuration.

A None value disables the pull / keeper function.

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

Set the pull-up / pull-down value

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

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

👎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

Set the open drain value

Set the pin speed

Set the drive strength

Set the slew rate

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.