[−][src]Struct mcp23017::MCP23017
Struct for MCP23017. It provides 16-bit, general purpose parallel I/O expansion for I2C bus. It consists of multiple 8-bit configuration registers for input, output and polarity selection. The system master can enable the I/Os as either inputs or outputs by writing the I/O configuration bits (IODIRA/B). The data for each input or output is kept in the corresponding input or output register. The polarity of the Input Port register can be inverted with the Polarity Inversion register
Fields
address: u8
lol
Methods
impl<I2C, E> MCP23017<I2C> where
I2C: WriteRead<Error = E> + Write<Error = E>,
[src]
I2C: WriteRead<Error = E> + Write<Error = E>,
pub fn default(i2c: I2C) -> Result<MCP23017<I2C>, Error<E>> where
I2C: WriteRead<Error = E>,
[src]
I2C: WriteRead<Error = E>,
Creates an expander with default configuration
pub fn new(i2c: I2C, address: u8) -> Result<MCP23017<I2C>, Error<E>> where
I2C: WriteRead<Error = E>,
[src]
I2C: WriteRead<Error = E>,
Creates an expander with specific configuration
pub fn pin_mode(&mut self, pin: u8, pin_mode: PinMode) -> Result<(), E>
[src]
Sets the single pin mode to either Mode::INPUT or Mode::OUTPUT
pub fn all_pin_mode(&mut self, pin_mode: PinMode) -> Result<(), E>
[src]
Sets pin mode to either Mode::INPUT or Mode::OUTPUT
pub fn read_gpioab(&mut self) -> Result<u16, E>
[src]
Reads all 16 pins (port A and B) into a single 16 bits variable
pub fn read_gpio(&mut self, port: Port) -> Result<u8, E>
[src]
Reads a single port, A or B, and return its current 8 bit value
pub fn write_gpioab(&mut self, value: u16) -> Result<(), E>
[src]
Writes all the pins with the value at the same time
pub fn write_gpioa(&mut self, value: u8) -> Result<(), E>
[src]
Writes all the pins with the value at the same time for GPIOA
pub fn write_gpiob(&mut self, value: u8) -> Result<(), E>
[src]
Writes all the pins with the value at the same time for GPIOB
pub fn digital_write(&mut self, pin: u8, value: u8) -> Result<(), E>
[src]
Writes digital value
pub fn digital_read(&mut self, pin: u8) -> Result<u8, E>
[src]
Reads digital pin
pub fn pull_up(&mut self, pin: u8, value: u8) -> Result<(), E>
[src]
The GPPU register controls the pull-up resistors for the port pins. If a bit is set and the corresponding pin is configured as an input, the corresponding port pin is internally pulled up with a 100 kohm resistor
pub fn setup_interrupts(
&mut self,
mirroring: u8,
open_drain: u8,
polarity: Polarity
) -> Result<(), E>
[src]
&mut self,
mirroring: u8,
open_drain: u8,
polarity: Polarity
) -> Result<(), E>
Configures the interrupt system. both port A and B are assigned the same configuration. mirroring will OR both INTA and INTB pins. open_drain will set the INT pin to value or open drain. polarity will set LOW or HIGH on interrupt. Default values after Power On Reset are: (false, false, LOW)
pub fn setup_interrupt_pin(
&mut self,
pin: u8,
int_mode: InterruptMode
) -> Result<(), E>
[src]
&mut self,
pin: u8,
int_mode: InterruptMode
) -> Result<(), E>
Sets up a pin for interrupt Note that the interrupt condition finishes when you read the information about the port / value that caused the interrupt or you read the port itself
pub fn get_last_interrupt_pin(&mut self) -> Result<u8, Error<E>>
[src]
Get last interrupt pin
pub fn get_last_interrupt_value(&mut self) -> Result<u8, Error<E>>
[src]
Gets last interrupt value
Trait Implementations
Auto Trait Implementations
impl<I2C> Unpin for MCP23017<I2C> where
I2C: Unpin,
I2C: Unpin,
impl<I2C> Send for MCP23017<I2C> where
I2C: Send,
I2C: Send,
impl<I2C> Sync for MCP23017<I2C> where
I2C: Sync,
I2C: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self