pub struct Mcp23x17<I2C> { /* private fields */ }
Expand description
16bit GPIO Expander
Implementations
sourceimpl<I2C, E> Mcp23x17<I2C>where
I2C: WriteRead<Error = E> + Write<Error = E>,
impl<I2C, E> Mcp23x17<I2C>where
I2C: WriteRead<Error = E> + Write<Error = E>,
sourcepub fn select_port(&mut self, port: Port)
pub fn select_port(&mut self, port: Port)
This chip optionally splits its registers between two eight bit ports or virtuall one large 16 bit port. This function sets the port internally.
sourcepub fn set_direction(&mut self, data: u8) -> Result<(), E>
pub fn set_direction(&mut self, data: u8) -> Result<(), E>
Set the I/O direction for the currently active port. A value of 1 is for input, 0 for output
sourcepub fn set_config(&mut self, data: Config) -> Result<(), E>
pub fn set_config(&mut self, data: Config) -> Result<(), E>
Set configuration register. Given the structure of this library and how
the chip can rearrange its registers, any attempt to set the BANK
bit
will be masked to zero.
sourcepub fn set_pullups(&mut self, data: u8) -> Result<(), E>
pub fn set_pullups(&mut self, data: u8) -> Result<(), E>
Set the pullups. A value of 1 enables the 100KOhm pullup.
sourcepub fn who_interrupted(&mut self) -> Result<u8, E>
pub fn who_interrupted(&mut self) -> Result<u8, E>
Read interrupt state. Each pin that caused an interrupt will have a bit is set. Not settable.
The value will be reset after a read from data_at_interrupt
or
data()
.
sourcepub fn data_at_interrupt(&mut self) -> Result<u8, E>
pub fn data_at_interrupt(&mut self) -> Result<u8, E>
GPIO value at time of interrupt. It will remain latched to this value until another interrupt is fired. While it won’t reset on read, it does reset the interrupt state on the corresponding interrupt output pin
sourcepub fn set_int_compare(&mut self, data: u8) -> Result<(), E>
pub fn set_int_compare(&mut self, data: u8) -> Result<(), E>
Set a comparison value for the interrupts. The interrupt will fire if the input value is different from what is set here
sourcepub fn int_compare(&mut self) -> Result<u8, E>
pub fn int_compare(&mut self) -> Result<u8, E>
Read interrupt comparison value. Check set_int_compare()
for more
details
sourcepub fn set_int_control(&mut self, data: u8) -> Result<(), E>
pub fn set_int_control(&mut self, data: u8) -> Result<(), E>
Decide how interrupts will fire. If a bit is set, the input data
is compared against what’s set by int_compare()
. If unset, the
interrupt will fire when the pin has changed.
sourcepub fn int_control(&mut self) -> Result<u8, E>
pub fn int_control(&mut self) -> Result<u8, E>
Read how interrupts will fire. More details on set_int_control()
.
sourcepub fn set_interrupt(&mut self, data: u8) -> Result<(), E>
pub fn set_interrupt(&mut self, data: u8) -> Result<(), E>
Enable interrupts. If a bit is set, a change on this pin will trigger an
interrupt. You’ll also need to call set_int_compare()
and
set_int_control()
sourcepub fn interrupt(&mut self) -> Result<u8, E>
pub fn interrupt(&mut self) -> Result<u8, E>
Read the data state from the active port. See set_interrupt()
for
more details
sourcepub fn latches(&mut self) -> Result<u8, E>
pub fn latches(&mut self) -> Result<u8, E>
Read output latches. This essentially reads the values set from
calling set_data()
sourcepub fn set_polarity(&mut self, data: u8) -> Result<(), E>
pub fn set_polarity(&mut self, data: u8) -> Result<(), E>
Set polarity allows inverting the values from input pins. A value of 1 will flip the polarity.