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,
impl<I> I2C<I, Disabled, Disabled, Disabled>where
I: Instance,
Source§impl<I, C, SlaveMode> I2C<I, Enabled<PhantomData<C>>, Disabled, SlaveMode>where
I: Instance,
impl<I, C, SlaveMode> I2C<I, Enabled<PhantomData<C>>, Disabled, SlaveMode>where
I: Instance,
Sourcepub fn enable_master_mode(
self,
clock: &Clock<C>,
) -> I2C<I, Enabled<PhantomData<C>>, Enabled, SlaveMode>
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,
impl<I, C, MasterMode> I2C<I, Enabled<PhantomData<C>>, MasterMode, Disabled>where
I: Instance,
Sourcepub fn enable_slave_mode(
self,
address: u8,
) -> Result<I2C<I, Enabled<PhantomData<C>>, MasterMode, Enabled>, (Error, Self)>
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,
impl<I, C, MasterMode, SlaveMode> I2C<I, Enabled<PhantomData<C>>, MasterMode, SlaveMode>where
I: Instance,
Sourcepub fn enable_interrupts(&mut self, interrupts: Interrupts)
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.
Sourcepub fn disable_interrupts(&mut self, interrupts: Interrupts)
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.
Sourcepub fn read_error(&mut self) -> Result<(), Error>
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,
impl<I, State, MasterMode, SlaveMode> I2C<I, State, MasterMode, SlaveMode>where
I: Instance,
Sourcepub fn free(self) -> I
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.