Struct bitbang_hal::i2c::I2cBB

source ·
pub struct I2cBB<SCL, SDA, CLK>
where SCL: OutputPin, SDA: OutputPin + InputPin, CLK: CountDown + Periodic,
{ /* private fields */ }
Expand description

Bit banging I2C device

Implementations§

source§

impl<SCL, SDA, CLK, E> I2cBB<SCL, SDA, CLK>
where SCL: OutputPin<Error = E>, SDA: OutputPin<Error = E> + InputPin<Error = E>, CLK: CountDown + Periodic,

source

pub fn new(scl: SCL, sda: SDA, clk: CLK) -> Self

Create instance

source

pub fn raw_i2c_start(&mut self) -> Result<(), Error<E>>

Send a raw I2C start.

This is a low-level control function. For normal I2C devices, please use the embedded-hal traits Read, Write, or WriteRead.

source

pub fn raw_i2c_stop(&mut self) -> Result<(), Error<E>>

Send a raw I2C stop.

This is a low-level control function. For normal I2C devices, please use the embedded-hal traits Read, Write, or WriteRead.

source

pub fn raw_read_from_slave(&mut self, input: &mut [u8]) -> Result<(), Error<E>>

Read raw bytes from the slave.

This is a low-level control function. For normal I2C devices, please use the embedded-hal traits Read, Write, or WriteRead.

source

pub fn raw_write_to_slave(&mut self, output: &[u8]) -> Result<(), Error<E>>

Send raw bytes to the slave.

This is a low-level control function. For normal I2C devices, please use the embedded-hal traits Read, Write, or WriteRead.

Trait Implementations§

source§

impl<SCL, SDA, CLK, E> Read for I2cBB<SCL, SDA, CLK>
where SCL: OutputPin<Error = E>, SDA: OutputPin<Error = E> + InputPin<Error = E>, CLK: CountDown + Periodic,

§

type Error = Error<E>

Error type
source§

fn read(&mut self, addr: u8, input: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill buffer Read more
source§

impl<SCL, SDA, CLK, E> Write for I2cBB<SCL, SDA, CLK>
where SCL: OutputPin<Error = E>, SDA: OutputPin<Error = E> + InputPin<Error = E>, CLK: CountDown + Periodic,

§

type Error = Error<E>

Error type
source§

fn write(&mut self, addr: u8, output: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address Read more
source§

impl<SCL, SDA, CLK, E> WriteRead for I2cBB<SCL, SDA, CLK>
where SCL: OutputPin<Error = E>, SDA: OutputPin<Error = E> + InputPin<Error = E>, CLK: CountDown + Periodic,

§

type Error = Error<E>

Error type
source§

fn write_read( &mut self, addr: u8, output: &[u8], input: &mut [u8] ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more

Auto Trait Implementations§

§

impl<SCL, SDA, CLK> Freeze for I2cBB<SCL, SDA, CLK>
where SCL: Freeze, SDA: Freeze, CLK: Freeze,

§

impl<SCL, SDA, CLK> RefUnwindSafe for I2cBB<SCL, SDA, CLK>
where SCL: RefUnwindSafe, SDA: RefUnwindSafe, CLK: RefUnwindSafe,

§

impl<SCL, SDA, CLK> Send for I2cBB<SCL, SDA, CLK>
where SCL: Send, SDA: Send, CLK: Send,

§

impl<SCL, SDA, CLK> Sync for I2cBB<SCL, SDA, CLK>
where SCL: Sync, SDA: Sync, CLK: Sync,

§

impl<SCL, SDA, CLK> Unpin for I2cBB<SCL, SDA, CLK>
where SCL: Unpin, SDA: Unpin, CLK: Unpin,

§

impl<SCL, SDA, CLK> UnwindSafe for I2cBB<SCL, SDA, CLK>
where SCL: UnwindSafe, SDA: UnwindSafe, CLK: 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.