Struct pca9539::expander::PCA9539

source ·
pub struct PCA9539<B>{ /* private fields */ }
Expand description

Abstraction of PCA9539 I/O expander

Implementations§

source§

impl<B> PCA9539<B>

source

pub fn new(bus: B, address: u8) -> Self

source

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

source

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

source

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

source

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.

source

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

source

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

source

pub fn refresh_input_state( &mut self, bank: Bank ) -> Result<(), RefreshInputError<B>>

Refreshes the input state of the given bank

source

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

source

pub fn is_pin_output_high(&self, bank: Bank, id: PinID) -> bool

Returns true if the pins output state is set high

source

pub fn write_output_state( &mut self, bank: Bank ) -> Result<(), <B as Write>::Error>

Writes the output register of the given bank

Auto Trait Implementations§

§

impl<B> RefUnwindSafe for PCA9539<B>
where B: RefUnwindSafe,

§

impl<B> Send for PCA9539<B>
where B: Send,

§

impl<B> Sync for PCA9539<B>
where B: Sync,

§

impl<B> Unpin for PCA9539<B>
where B: Unpin,

§

impl<B> UnwindSafe for PCA9539<B>
where B: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.