Struct port_expander::Pin
source · pub struct Pin<'a, MODE, MUTEX> { /* private fields */ }
Expand description
Representation of a port-expander pin.
Pin
is not constructed directly, this type is created by instanciating a port-expander and
then getting access to all its pins using the .split()
method.
Implementations§
source§impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
source§impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverTotemPole,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverTotemPole,
MUTEX: PortMutex<Port = PD>,
sourcepub fn into_input(self) -> Result<Pin<'a, Input, MUTEX>, PinError<PD::Error>>
pub fn into_input(self) -> Result<Pin<'a, Input, MUTEX>, PinError<PD::Error>>
Configure this pin as an input.
The exact electrical details depend on the port-expander device which is used.
sourcepub fn into_output(self) -> Result<Pin<'a, Output, MUTEX>, PinError<PD::Error>>
pub fn into_output(self) -> Result<Pin<'a, Output, MUTEX>, PinError<PD::Error>>
Configure this pin as an output with an initial LOW state.
The LOW state is, as long as he port-expander chip allows this, entered without any electrical glitch.
sourcepub fn into_output_high(
self,
) -> Result<Pin<'a, Output, MUTEX>, PinError<PD::Error>>
pub fn into_output_high( self, ) -> Result<Pin<'a, Output, MUTEX>, PinError<PD::Error>>
Configure this pin as an output with an initial HIGH state.
The HIGH state is, as long as he port-expander chip allows this, entered without any electrical glitch.
source§impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPolarity,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPolarity,
MUTEX: PortMutex<Port = PD>,
sourcepub fn into_inverted(self) -> Result<Self, PinError<PD::Error>>
pub fn into_inverted(self) -> Result<Self, PinError<PD::Error>>
Turn on hardware polarity inversion for this pin.
sourcepub fn set_inverted(
&mut self,
inverted: bool,
) -> Result<(), PinError<PD::Error>>
pub fn set_inverted( &mut self, inverted: bool, ) -> Result<(), PinError<PD::Error>>
Set hardware polarity inversion for this pin.
source§impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
source§impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPullUp,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPullUp,
MUTEX: PortMutex<Port = PD>,
sourcepub fn enable_pull_up(
&mut self,
enable: bool,
) -> Result<(), PinError<PD::Error>>
pub fn enable_pull_up( &mut self, enable: bool, ) -> Result<(), PinError<PD::Error>>
Enable/Disable pull-up resistors for this pin.
If enable
is true
, the pull-up resistor is enabled, otherwise the pin is configured as floating input.
source§impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPullDown,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE: HasInput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver + PortDriverPullDown,
MUTEX: PortMutex<Port = PD>,
sourcepub fn enable_pull_down(
&mut self,
enable: bool,
) -> Result<(), PinError<PD::Error>>
pub fn enable_pull_down( &mut self, enable: bool, ) -> Result<(), PinError<PD::Error>>
Enable/Disable pull-down resistors for this pin.
If enable
is true
, the pull-down resistor is enabled, otherwise the pin is configured as floating input.
source§impl<'a, MODE: HasOutput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
impl<'a, MODE: HasOutput, MUTEX, PD> Pin<'a, MODE, MUTEX>where
PD: PortDriver,
MUTEX: PortMutex<Port = PD>,
sourcepub fn set_high(&mut self) -> Result<(), PinError<PD::Error>>
pub fn set_high(&mut self) -> Result<(), PinError<PD::Error>>
Set the pin’s output state to HIGH.
Note that this can have different electrical meanings depending on the port-expander chip.
sourcepub fn set_low(&mut self) -> Result<(), PinError<PD::Error>>
pub fn set_low(&mut self) -> Result<(), PinError<PD::Error>>
Set the pin’s output state to LOW.
Note that this can have different electrical meanings depending on the port-expander chip.
sourcepub fn is_set_high(&self) -> Result<bool, PinError<PD::Error>>
pub fn is_set_high(&self) -> Result<bool, PinError<PD::Error>>
Return true
if the pin’s output state is HIGH.
This method does not read the pin’s electrical state.
sourcepub fn is_set_low(&self) -> Result<bool, PinError<PD::Error>>
pub fn is_set_low(&self) -> Result<bool, PinError<PD::Error>>
Return true
if the pin’s output state is LOW.
This method does not read the pin’s electrical state.