Struct mcp230xx::Mcp230xx

source ·
pub struct Mcp230xx<I2C, MAP> { /* private fields */ }
Expand description

MCP23017/MCP23008, a 16/8-Bit I2C I/O Expander with I2C Interface. Provide the chip variant (its register map) via MAP.

Implementations§

source§

impl<I2C, E, MAP> Mcp230xx<I2C, MAP>
where I2C: WriteRead<Error = E> + Write<Error = E>, MAP: Map,

source

pub fn new_default(i2c: I2C) -> Result<Self, Error<E>>

Creates an expander with the default configuration.

source

pub fn new(i2c: I2C, address: u8) -> Result<Self, Error<E>>

Creates an expander with specific address.

source

pub fn address(&self) -> u8

Return the I2C address

source

pub fn read(&mut self, addr: u8) -> Result<u8, E>

Read an 8 bit register

source

pub fn write(&mut self, addr: u8, data: u8) -> Result<(), E>

Write an 8 bit register

source

pub fn io_configuration(&mut self, value: u8) -> Result<(), E>

Set IOCON register Note(BANK): Do not change the register mapping by setting the IOCON.BANK bit.

source

pub fn direction(&mut self, pin: MAP) -> Result<Direction, E>

Pin direction

source

pub fn set_direction(&mut self, pin: MAP, value: Direction) -> Result<(), E>

Pin direction

source

pub fn input_polarity(&mut self, pin: MAP) -> Result<Polarity, E>

Input polarity inversion

source

pub fn set_input_polarity(&mut self, pin: MAP, value: Polarity) -> Result<(), E>

Input polarity inversion

source

pub fn int_on_change(&mut self, pin: MAP) -> Result<IntOnChange, E>

Interrupt on change

source

pub fn set_int_on_change( &mut self, pin: MAP, value: IntOnChange ) -> Result<(), E>

Interrupt on change

source

pub fn int_on_level(&mut self, pin: MAP) -> Result<Level, E>

Default compare value for interrupt on level

source

pub fn set_int_on_level(&mut self, pin: MAP, value: Level) -> Result<(), E>

Default compare value for interrupt on level

source

pub fn int_mode(&mut self, pin: MAP) -> Result<IntMode, E>

Interrupt configuration

source

pub fn set_int_mode(&mut self, pin: MAP, value: IntMode) -> Result<(), E>

Interrupt configuration

source

pub fn pull_up(&mut self, pin: MAP) -> Result<PullUp, E>

Weak pull up resistor state

source

pub fn set_pull_up(&mut self, pin: MAP, value: PullUp) -> Result<(), E>

Weak pull up resistor state

source

pub fn int_flag(&mut self, pin: MAP) -> Result<IntFlag, E>

Interrupt flag

source

pub fn set_int_flag(&mut self, pin: MAP, value: IntFlag) -> Result<(), E>

Interrupt flag

source

pub fn int_capture(&mut self, pin: MAP) -> Result<Level, E>

Interrupt level capture

source

pub fn set_int_capture(&mut self, pin: MAP, value: Level) -> Result<(), E>

Interrupt level capture

source

pub fn gpio(&mut self, pin: MAP) -> Result<Level, E>

GPIO Pin value. This reads the actual hardware pin but writes to the OLAT register.

source

pub fn set_gpio(&mut self, pin: MAP, value: Level) -> Result<(), E>

GPIO Pin value. This reads the actual hardware pin but writes to the OLAT register.

source

pub fn output_latch(&mut self, pin: MAP) -> Result<Level, E>

Output latch state

source

pub fn set_output_latch(&mut self, pin: MAP, value: Level) -> Result<(), E>

Output latch state

Trait Implementations§

source§

impl<I2C: Clone, MAP: Clone> Clone for Mcp230xx<I2C, MAP>

source§

fn clone(&self) -> Mcp230xx<I2C, MAP>

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<I2C: Debug, MAP: Debug> Debug for Mcp230xx<I2C, MAP>

source§

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

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

impl<I2C: Copy, MAP: Copy> Copy for Mcp230xx<I2C, MAP>

Auto Trait Implementations§

§

impl<I2C, MAP> Freeze for Mcp230xx<I2C, MAP>
where I2C: Freeze,

§

impl<I2C, MAP> RefUnwindSafe for Mcp230xx<I2C, MAP>
where I2C: RefUnwindSafe, MAP: RefUnwindSafe,

§

impl<I2C, MAP> Send for Mcp230xx<I2C, MAP>
where I2C: Send, MAP: Send,

§

impl<I2C, MAP> Sync for Mcp230xx<I2C, MAP>
where I2C: Sync, MAP: Sync,

§

impl<I2C, MAP> Unpin for Mcp230xx<I2C, MAP>
where I2C: Unpin, MAP: Unpin,

§

impl<I2C, MAP> UnwindSafe for Mcp230xx<I2C, MAP>
where I2C: UnwindSafe, MAP: UnwindSafe,

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.