Skip to main content

I2c

Struct I2c 

Source
pub struct I2c<I2C> { /* private fields */ }
Expand description

An I2C driver for the PIC32.

Contains primitives transmit(), receive(), rstart(), stop() that can be called one after another to build a complex I2C transaction. A Transaction must be started with transmit() and concluded with stop()

Implementations§

Source§

impl I2c<I2C1>

Source

pub fn i2c1(i2c: I2C1, pb_clock: Hertz, fscl: Fscl) -> I2c<I2C1>

Create a new I2C object

Source

pub fn free(self) -> I2C1

Destroy I2C object and return i2c HAL object

Source§

impl I2c<I2C2>

Source

pub fn i2c2(i2c: I2C2, pb_clock: Hertz, fscl: Fscl) -> I2c<I2C2>

Create a new I2C object

Source

pub fn free(self) -> I2C2

Destroy I2C object and return i2c HAL object

Trait Implementations§

Source§

impl ErrorType for I2c<I2C1>

Source§

type Error = Error

Error type
Source§

impl ErrorType for I2c<I2C2>

Source§

type Error = Error

Error type
Source§

impl I2c for I2c<I2C1>

Source§

fn transaction( &mut self, address: SevenBitAddress, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
Source§

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

Reads enough bytes from slave with address to fill read. Read more
Source§

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

Writes bytes to slave with address address. Read more
Source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
Source§

impl I2c for I2c<I2C2>

Source§

fn transaction( &mut self, address: SevenBitAddress, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
Source§

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

Reads enough bytes from slave with address to fill read. Read more
Source§

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

Writes bytes to slave with address address. Read more
Source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
Source§

impl Ops for I2c<I2C1>

Source§

fn transmit(&mut self, data: &[u8]) -> Result<(), Error>

Transmit data over the bus. Generate a START condition if called first during a transaction.
Source§

unsafe fn transmit_dma<D: Ops>( &mut self, dma: &mut D, addr: PhysicalAddress, len: usize, ) -> Result<(), Error>

Initiate DMA transmission Read more
Source§

fn start(&mut self)

Generate a start or repeated start condition.
Source§

fn stop(&mut self)

Generate a stop condition and terminate the I2C transaction
Source§

fn receive(&mut self, data: &mut [u8], nack_last: bool) -> Result<(), Error>

Receive data.len() bytes. Read more
Source§

impl Ops for I2c<I2C2>

Source§

fn transmit(&mut self, data: &[u8]) -> Result<(), Error>

Transmit data over the bus. Generate a START condition if called first during a transaction.
Source§

unsafe fn transmit_dma<D: Ops>( &mut self, dma: &mut D, addr: PhysicalAddress, len: usize, ) -> Result<(), Error>

Initiate DMA transmission Read more
Source§

fn start(&mut self)

Generate a start or repeated start condition.
Source§

fn stop(&mut self)

Generate a stop condition and terminate the I2C transaction
Source§

fn receive(&mut self, data: &mut [u8], nack_last: bool) -> Result<(), Error>

Receive data.len() bytes. Read more
Source§

impl Read for I2c<I2C1>

Source§

type Error = Error

Error type
Source§

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

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

impl Read for I2c<I2C2>

Source§

type Error = Error

Error type
Source§

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

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

impl Write for I2c<I2C1>

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl Write for I2c<I2C2>

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl WriteRead for I2c<I2C1>

Source§

type Error = Error

Error type
Source§

fn write_read( &mut self, addr: u8, bytes: &[u8], buffer: &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
Source§

impl WriteRead for I2c<I2C2>

Source§

type Error = Error

Error type
Source§

fn write_read( &mut self, addr: u8, bytes: &[u8], buffer: &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<I2C> Freeze for I2c<I2C>
where I2C: Freeze,

§

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

§

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

§

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

§

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

§

impl<I2C> UnsafeUnpin for I2c<I2C>
where I2C: UnsafeUnpin,

§

impl<I2C> UnwindSafe for I2c<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>,

Source§

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>,

Source§

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.