Struct stmpe1600::Pin [−][src]
A single I/O pin on the STMPE1600.
Pin
takes a MODE
as a generic argument, which is either Input
, Output
or Interrupt
,
and indicates which mode of operation the current pin is configured for. This mode can be
changed by using the into_input_pin
, into_output_pin
and into_interrupt_pin
functions
respectively.
Input and interrupt pins implement the trait embedded_hal::digital::v2::InputPin
, and output
pins implement embedded_hal::digital::v2::OutputPin
. This means that the pins on the I/O
expander can be used by platform agnostic drivers as if they were regular GPIO pins.
Examples
Changing pin mode
use embedded_hal::digital::v2::{InputPin, OutputPin}; use linux_embedded_hal::I2cdev; use stmpe1600::Stmpe1600Builder; let dev = I2cdev::new("/dev/i2c-1").unwrap(); let stmpe1600 = Stmpe1600Builder::new(dev) .build() .expect("Could not initialise STMPE1600 driver"); let mut input_pin = stmpe1600.pin_input(0)?; let _ = input_pin.is_high()?; let mut output_pin = input_pin.into_output_pin()?; output_pin.set_high()?;
Setting interrupt polarity
use linux_embedded_hal::I2cdev; use stmpe1600::{Polarity, Stmpe1600Builder}; let dev = I2cdev::new("/dev/i2c-1").unwrap(); let stmpe1600 = Stmpe1600Builder::new(dev) .build() .expect("Could not initialise STMPE1600 driver"); let mut input_pin = stmpe1600.pin_input(0)?; input_pin.set_interrupt_polarity(Polarity::High)?;
Implementations
impl<'a, E, I2C, MODE> Pin<'a, I2C, MODE> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
pub fn polarity_inversion(&mut self) -> Result<Polarity, Error<E>>
[src]
Get the polarity inversion of the current pin.
pub fn set_polarity_inversion(
&mut self,
polarity: Polarity
) -> Result<(), Error<E>>
[src]
&mut self,
polarity: Polarity
) -> Result<(), Error<E>>
Set the polarity inversion of the current pin.
impl<'a, E, I2C> Pin<'a, I2C, Input> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
pub fn into_output_pin(self) -> Result<Pin<'a, I2C, Output>, Error<E>>
[src]
Configure the pin as an output pin.
pub fn into_interrupt_pin(self) -> Result<Pin<'a, I2C, Interrupt>, Error<E>>
[src]
Configure the pin as an interrupt pin.
impl<'a, E, I2C> Pin<'a, I2C, Output> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
pub fn into_input_pin(self) -> Result<Pin<'a, I2C, Input>, Error<E>>
[src]
Configure the pin as an input pin.
pub fn into_interrupt_pin(self) -> Result<Pin<'a, I2C, Interrupt>, Error<E>>
[src]
Configure the pin as an interrupt pin.
impl<'a, E, I2C> Pin<'a, I2C, Interrupt> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
pub fn into_input_pin(self) -> Result<Pin<'a, I2C, Input>, Error<E>>
[src]
Configure the pin as an input pin.
pub fn into_output_pin(self) -> Result<Pin<'a, I2C, Output>, Error<E>>
[src]
Configure the pin as an output pin.
Trait Implementations
impl<'a, E, I2C> InputPin for Pin<'a, I2C, Input> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
type Error = Error<E>
Error type
fn is_low(&self) -> Result<bool, Self::Error>
[src]
fn is_high(&self) -> Result<bool, Self::Error>
[src]
impl<'a, E, I2C> InputPin for Pin<'a, I2C, Interrupt> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
type Error = Error<E>
Error type
fn is_low(&self) -> Result<bool, Self::Error>
[src]
fn is_high(&self) -> Result<bool, Self::Error>
[src]
impl<'a, E, I2C> OutputPin for Pin<'a, I2C, Output> where
I2C: Read<Error = E> + Write<Error = E>,
[src]
I2C: Read<Error = E> + Write<Error = E>,
Auto Trait Implementations
impl<'a, I2C, MODE> !Send for Pin<'a, I2C, MODE>
impl<'a, I2C, MODE> !Sync for Pin<'a, I2C, MODE>
impl<'a, I2C, MODE> Unpin for Pin<'a, I2C, MODE> where
MODE: Unpin,
MODE: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,