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

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.

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 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 !=.

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

Performs the conversion.

Performs the conversion.

Should always be Self

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.