Struct mcp23017_rpi_lib::MCP23017
source · [−]pub struct MCP23017 { /* private fields */ }
Expand description
MCP23017 i2c Interface
Implementations
sourceimpl MCP23017
impl MCP23017
pub fn new(address: u16, bus: u8) -> Result<MCP23017, Error>
sourcepub fn pull_up(&self, pin: &Pin, value: State) -> Result<u16, Error>
pub fn pull_up(&self, pin: &Pin, value: State) -> Result<u16, Error>
Used to set the pullUp resistor setting for a pin. Returns the whole register value.
sourcepub fn pin_mode(&mut self, pin: &Pin, mode: Mode) -> Result<u16, Error>
pub fn pin_mode(&mut self, pin: &Pin, mode: Mode) -> Result<u16, Error>
Set pin to either input or output mode. Returns the value of the combined IODIRA and IODIRB registers.
sourcepub fn output(&self, pin: &Pin, value: State) -> Result<u8, Error>
pub fn output(&self, pin: &Pin, value: State) -> Result<u8, Error>
Set an output pin to a specific value.
sourcepub fn current_val(&self, pin: &Pin) -> Result<State, Error>
pub fn current_val(&self, pin: &Pin) -> Result<State, Error>
Read the value of a pin regardless of it’s mode
sourcepub fn config_system_interrupt(
&mut self,
mirror: Feature,
intpol: State
) -> Result<(), Error>
pub fn config_system_interrupt(
&mut self,
mirror: Feature,
intpol: State
) -> Result<(), Error>
Configure system interrupt settings. Mirror - are the int pins mirrored? Intpol - polarity of the int pin.
sourcepub fn config_pin_interrupt(
&self,
pin: &Pin,
enabled: Feature,
compare_mode: Compare,
defval: Option<State>
) -> Result<(), Error>
pub fn config_pin_interrupt(
&self,
pin: &Pin,
enabled: Feature,
compare_mode: Compare,
defval: Option<State>
) -> Result<(), Error>
Configure interrupt setting for a specific pin. set on or off.
sourcepub fn read_interrupt(&self, port: Bank) -> Result<Option<(Pin, State)>, Error>
pub fn read_interrupt(&self, port: Bank) -> Result<Option<(Pin, State)>, Error>
The function determines the pin that caused the interrupt and gets its value. The interrupt is cleared. Returns pin and the value.
sourcepub fn clear_interrupts(&self) -> Result<(), Error>
pub fn clear_interrupts(&self) -> Result<(), Error>
Check to see if there is an interrupt pending 3 times in a row (indicating it’s stuck) and if needed clear the interrupt without reading values.
Auto Trait Implementations
impl RefUnwindSafe for MCP23017
impl Send for MCP23017
impl !Sync for MCP23017
impl Unpin for MCP23017
impl UnwindSafe for MCP23017
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more