I2C

Struct I2C 

Source
pub struct I2C<I: Instance, State, MasterMode, SlaveMode> {
    pub master: Master<I, State, MasterMode>,
    pub slave: Slave<I, State, SlaveMode>,
    /* private fields */
}
Expand description

Interface to an I2C peripheral

Please refer to the module documentation for more information.

Fields§

§master: Master<I, State, MasterMode>

API for I2C master mode

§slave: Slave<I, State, SlaveMode>

API for I2C slave mode

Implementations§

Source§

impl<I> I2C<I, Disabled, Disabled, Disabled>
where I: Instance,

Source

pub fn enable<C, SdaPin, SclPin>( self, _clock: &C, _: Function<I::Scl, Assigned<SclPin>>, _: Function<I::Sda, Assigned<SdaPin>>, syscon: &mut Handle, ) -> I2C<I, Enabled<PhantomData<C>>, Disabled, Disabled>
where C: ClockSource,

Enable this I2C instance

This method is only available, if I2C is in the Disabled state. Code that attempts to call this method when the peripheral is already enabled will not compile.

Consumes this instance of I2C and returns another instance that has its State type parameter set to Enabled.

Source§

impl<I, C, SlaveMode> I2C<I, Enabled<PhantomData<C>>, Disabled, SlaveMode>
where I: Instance,

Source

pub fn enable_master_mode( self, clock: &Clock<C>, ) -> I2C<I, Enabled<PhantomData<C>>, Enabled, SlaveMode>

Enable master mode

This method is only available, if the I2C instance is enabled, but master mode is disabled. Code that attempts to call this method when this is not the case will not compile.

Consumes this instance of I2C and returns another instance that has its type state updated.

§Limitations

This method does not check that the supplied clock configuration matches the configuration of the pins. You need to verify manually that this is the case. What this means exactly may depend on your specific part. Check out the LPC84x user manual, section 19.4, for example.

If you don’t mess with the IOCON configuration and use I2C clock rates of up to 400 kHz, you should be fine.

Source§

impl<I, C, MasterMode> I2C<I, Enabled<PhantomData<C>>, MasterMode, Disabled>
where I: Instance,

Source

pub fn enable_slave_mode( self, address: u8, ) -> Result<I2C<I, Enabled<PhantomData<C>>, MasterMode, Enabled>, (Error, Self)>

Enable slave mode

This method is only available, if the peripheral instance is enabled and slave mode is disabled. Code that attempts to call this method when this is not the case will not compile.

Consumes this instance of I2C and returns another instance that has its type state updated.

Source§

impl<I, C, MasterMode, SlaveMode> I2C<I, Enabled<PhantomData<C>>, MasterMode, SlaveMode>
where I: Instance,

Source

pub fn enable_interrupts(&mut self, interrupts: Interrupts)

Enable interrupts

Enables all interrupts set to true in interrupts. Interrupts set to false are not affected.

Source

pub fn disable_interrupts(&mut self, interrupts: Interrupts)

Disable interrupts

Disables all interrupts set to true in interrupts. Interrupts set to false are not affected.

Source

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

Read and clear a detected error

The read and write methods will return an error and clear it, if one was detected. However, if multiple errors occur, only one error will be returned and cleared.

This method can be used to read and clear all currently detected errors before resuming normal operation.

Source§

impl<I, State, MasterMode, SlaveMode> I2C<I, State, MasterMode, SlaveMode>
where I: Instance,

Source

pub fn free(self) -> I

Return the raw peripheral

This method serves as an escape hatch from the HAL API. It returns the raw peripheral, allowing you to do whatever you want with it, without limitations imposed by the API.

If you are using this method because a feature you need is missing from the HAL API, please open an issue or, if an issue for your feature request already exists, comment on the existing issue, so we can prioritize it accordingly.

Trait Implementations§

Source§

impl<I, State, MasterMode, SlaveMode> Debug for I2C<I, State, MasterMode, SlaveMode>
where I: Instance,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, State, MasterMode, SlaveMode> Freeze for I2C<I, State, MasterMode, SlaveMode>
where I: Freeze,

§

impl<I, State, MasterMode, SlaveMode> RefUnwindSafe for I2C<I, State, MasterMode, SlaveMode>
where I: RefUnwindSafe, State: RefUnwindSafe, MasterMode: RefUnwindSafe, SlaveMode: RefUnwindSafe,

§

impl<I, State, MasterMode, SlaveMode> Send for I2C<I, State, MasterMode, SlaveMode>
where I: Send, State: Send, MasterMode: Send, SlaveMode: Send,

§

impl<I, State, MasterMode, SlaveMode> !Sync for I2C<I, State, MasterMode, SlaveMode>

§

impl<I, State, MasterMode, SlaveMode> Unpin for I2C<I, State, MasterMode, SlaveMode>
where I: Unpin, State: Unpin, MasterMode: Unpin, SlaveMode: Unpin,

§

impl<I, State, MasterMode, SlaveMode> UnwindSafe for I2C<I, State, MasterMode, SlaveMode>
where I: UnwindSafe + RefUnwindSafe, State: UnwindSafe, MasterMode: UnwindSafe, SlaveMode: 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.