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>
impl<I2C, E, MAP> Mcp230xx<I2C, MAP>
sourcepub fn new_default(i2c: I2C) -> Result<Self, Error<E>>
pub fn new_default(i2c: I2C) -> Result<Self, Error<E>>
Creates an expander with the default configuration.
sourcepub fn new(i2c: I2C, address: u8) -> Result<Self, Error<E>>
pub fn new(i2c: I2C, address: u8) -> Result<Self, Error<E>>
Creates an expander with specific address.
sourcepub fn io_configuration(&mut self, value: u8) -> Result<(), E>
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.
sourcepub fn set_direction(&mut self, pin: MAP, value: Direction) -> Result<(), E>
pub fn set_direction(&mut self, pin: MAP, value: Direction) -> Result<(), E>
Pin direction
sourcepub fn input_polarity(&mut self, pin: MAP) -> Result<Polarity, E>
pub fn input_polarity(&mut self, pin: MAP) -> Result<Polarity, E>
Input polarity inversion
sourcepub fn set_input_polarity(&mut self, pin: MAP, value: Polarity) -> Result<(), E>
pub fn set_input_polarity(&mut self, pin: MAP, value: Polarity) -> Result<(), E>
Input polarity inversion
sourcepub fn int_on_change(&mut self, pin: MAP) -> Result<IntOnChange, E>
pub fn int_on_change(&mut self, pin: MAP) -> Result<IntOnChange, E>
Interrupt on change
sourcepub fn set_int_on_change(
&mut self,
pin: MAP,
value: IntOnChange
) -> Result<(), E>
pub fn set_int_on_change( &mut self, pin: MAP, value: IntOnChange ) -> Result<(), E>
Interrupt on change
sourcepub fn int_on_level(&mut self, pin: MAP) -> Result<Level, E>
pub fn int_on_level(&mut self, pin: MAP) -> Result<Level, E>
Default compare value for interrupt on level
sourcepub fn set_int_on_level(&mut self, pin: MAP, value: Level) -> Result<(), E>
pub fn set_int_on_level(&mut self, pin: MAP, value: Level) -> Result<(), E>
Default compare value for interrupt on level
sourcepub fn set_int_mode(&mut self, pin: MAP, value: IntMode) -> Result<(), E>
pub fn set_int_mode(&mut self, pin: MAP, value: IntMode) -> Result<(), E>
Interrupt configuration
sourcepub fn set_pull_up(&mut self, pin: MAP, value: PullUp) -> Result<(), E>
pub fn set_pull_up(&mut self, pin: MAP, value: PullUp) -> Result<(), E>
Weak pull up resistor state
sourcepub fn set_int_flag(&mut self, pin: MAP, value: IntFlag) -> Result<(), E>
pub fn set_int_flag(&mut self, pin: MAP, value: IntFlag) -> Result<(), E>
Interrupt flag
sourcepub fn int_capture(&mut self, pin: MAP) -> Result<Level, E>
pub fn int_capture(&mut self, pin: MAP) -> Result<Level, E>
Interrupt level capture
sourcepub fn set_int_capture(&mut self, pin: MAP, value: Level) -> Result<(), E>
pub fn set_int_capture(&mut self, pin: MAP, value: Level) -> Result<(), E>
Interrupt level capture
sourcepub fn gpio(&mut self, pin: MAP) -> Result<Level, E>
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.
sourcepub fn set_gpio(&mut self, pin: MAP, value: Level) -> Result<(), E>
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.
sourcepub fn output_latch(&mut self, pin: MAP) -> Result<Level, E>
pub fn output_latch(&mut self, pin: MAP) -> Result<Level, E>
Output latch state
sourcepub fn set_output_latch(&mut self, pin: MAP, value: Level) -> Result<(), E>
pub fn set_output_latch(&mut self, pin: MAP, value: Level) -> Result<(), E>
Output latch state