pub struct PCA9539<B>{ /* private fields */ }
Expand description
Abstraction of PCA9539 I/O expander
Implementations§
source§impl<B> PCA9539<B>
impl<B> PCA9539<B>
pub fn new(bus: B, address: u8) -> Self
sourcepub fn pins(&mut self) -> Pins<B, LockFreeGuard<'_, B>>
pub fn pins(&mut self) -> Pins<B, LockFreeGuard<'_, B>>
Returns a pins container without using any locks This is the most efficient way of using individual pins The downside is, that these pins are neither Send or Sync, so can only be used in single-threaded and interrupt-free applications
sourcepub fn set_mode(
&mut self,
bank: Bank,
id: PinID,
mode: Mode
) -> Result<(), <B as Write>::Error>
pub fn set_mode( &mut self, bank: Bank, id: PinID, mode: Mode ) -> Result<(), <B as Write>::Error>
Switches the given pin to the input/output mode by adjusting the configuration register
sourcepub fn set_mode_all(
&mut self,
bank: Bank,
mode: Mode
) -> Result<(), <B as Write>::Error>
pub fn set_mode_all( &mut self, bank: Bank, mode: Mode ) -> Result<(), <B as Write>::Error>
Switches all pins of the given bank to output/input mode1
sourcepub fn set_state(&mut self, bank: Bank, id: PinID, is_high: bool)
pub fn set_state(&mut self, bank: Bank, id: PinID, is_high: bool)
Sets the given output state by adjusting the output register
Pin needs to be in OUTPUT mode for correct electrical state
Note: This just updates the internal register, to make the changes effective,
an additional call to write_output_state()
is needed.
sourcepub fn set_state_all(
&mut self,
bank: Bank,
is_high: bool
) -> Result<(), <B as Write>::Error>
pub fn set_state_all( &mut self, bank: Bank, is_high: bool ) -> Result<(), <B as Write>::Error>
Sets output state for all pins of a bank
sourcepub fn reverse_polarity(
&mut self,
bank: Bank,
id: PinID,
reversed: bool
) -> Result<(), <B as Write>::Error>
pub fn reverse_polarity( &mut self, bank: Bank, id: PinID, reversed: bool ) -> Result<(), <B as Write>::Error>
Reveres/Resets the input polarity of the given pin
sourcepub fn refresh_input_state(
&mut self,
bank: Bank
) -> Result<(), RefreshInputError<B>>
pub fn refresh_input_state( &mut self, bank: Bank ) -> Result<(), RefreshInputError<B>>
Refreshes the input state of the given bank
sourcepub fn is_pin_input_high(&self, bank: Bank, id: PinID) -> bool
pub fn is_pin_input_high(&self, bank: Bank, id: PinID) -> bool
Returns true if the given pin input is high
Pin needs to be in INPUT mode
This method is using the cached register, for a updated result refresh_input_state()
needs
to be called beforehand
sourcepub fn is_pin_output_high(&self, bank: Bank, id: PinID) -> bool
pub fn is_pin_output_high(&self, bank: Bank, id: PinID) -> bool
Returns true if the pins output state is set high