Struct tca9539::Pca9539

source ·
pub struct Pca9539<I2C> { /* private fields */ }
Expand description

PCA9539/TCA9539 is a 16-pin I2C I/O Expander with I2C Interface.

Implementations§

source§

impl<I2C, E> Pca9539<I2C>
where I2C: WriteRead<Error = E> + Write<Error = E>,

source

pub fn new_default(i2c: I2C) -> Result<Self, Error<E>>

Creates an expander with the default configuration.

source

pub fn new(i2c: I2C, address: u8) -> Result<Self, Error<E>>

Creates an expander with specific address.

source

pub fn address(&self) -> u8

Return the I2C address

source

pub fn read(&mut self, addr: u8) -> Result<u8, E>

Read an 8 bit register

source

pub fn write(&mut self, addr: u8, data: u8) -> Result<(), E>

Write an 8 bit register

source

pub fn bit(&mut self, addr: u8, bit: usize) -> Result<bool, E>

Get a single bit in a register

source

pub fn set_bit(&mut self, addr: u8, bit: usize, value: bool) -> Result<(), E>

Set a single bit in a register

source

pub fn set_level(&mut self, pin: Pin, level: Level) -> Result<(), E>

source

pub fn set_direction(&mut self, pin: Pin, direction: Direction) -> Result<(), E>

Trait Implementations§

source§

impl<I2C: Clone> Clone for Pca9539<I2C>

source§

fn clone(&self) -> Pca9539<I2C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I2C: Debug> Debug for Pca9539<I2C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I2C: Copy> Copy for Pca9539<I2C>

Auto Trait Implementations§

§

impl<I2C> Freeze for Pca9539<I2C>
where I2C: Freeze,

§

impl<I2C> RefUnwindSafe for Pca9539<I2C>
where I2C: RefUnwindSafe,

§

impl<I2C> Send for Pca9539<I2C>
where I2C: Send,

§

impl<I2C> Sync for Pca9539<I2C>
where I2C: Sync,

§

impl<I2C> Unpin for Pca9539<I2C>
where I2C: Unpin,

§

impl<I2C> UnwindSafe for Pca9539<I2C>
where I2C: 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.