Struct max7301::config::Configurator[][src]

#[must_use = "Configuration changes are not applied unless committed"]pub struct Configurator<'e, EI: ExpanderInterface + Send> { /* fields omitted */ }

A Configurator provides methods to build a list of device configuration changes, such as port modes and device configuration bits, and commit them to the device. You obtain one from the Expander::configure(), chain method calls on it to make configuration changes, and then end the chain with commit() to transmit them to the MAX7301.

let mut expander = Expander::new(ei);
expander
    .configure()
    .ports(4..=7, PortMode::Output)
    .shutdown(false)
    .commit()
    .unwrap();

Implementations

impl<'e, EI: ExpanderInterface + Send> Configurator<'e, EI>[src]

pub fn port(self, port: u8, mode: PortMode) -> Self[src]

Set the port mode of a single GPIO pin on the MAX7301 to mode. port is the port number as specified in the device datasheet, in the range 4..=31.

pub fn ports<I>(self, ports: I, mode: PortMode) -> Self where
    I: IntoIterator<Item = u8>, 
[src]

Set the port mode of a sequence of GPIO pins to the given PortMode. ports must yield values corresponding to port numbers as specified in the device datasheet, in the range 4..=31. All of the ports will be set to mode mode.

pub fn shutdown(self, enable: bool) -> Self[src]

Set the MAX7301’s shutdown bit. When false the device will operate normally; when true the device enters shutdown mode. In shutdown mode all ports are overridden to input mode and pull-up current sources are disabled, but all registers retain their values and may be read and written normally. See the datasheet for more details.

pub fn detect_transitions(self, enable: bool) -> Self[src]

Set the MAX7301’s transition detection feature control bit. When false the feature is disabled; when true ports 24 through 31 will be monitored for changes, setting an interrupt pin when they are detected. See datasheet for details. Interrupts generated from this hardware feature are not managed by this driver.

pub fn commit(self) -> Result<(), ()>[src]

Commit the configuration changes to the MAX7301. The configurator will attempt to update the device’s configuration registers while minimizing bus traffic (avoiding read-modify-writes when possible, not setting registers that were not changed).

Auto Trait Implementations

impl<'e, EI> RefUnwindSafe for Configurator<'e, EI> where
    EI: RefUnwindSafe

impl<'e, EI> Send for Configurator<'e, EI>

impl<'e, EI> Sync for Configurator<'e, EI> where
    EI: Sync

impl<'e, EI> Unpin for Configurator<'e, EI>

impl<'e, EI> !UnwindSafe for Configurator<'e, EI>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.