Struct stm32_hal2::i2c::I2c [−][src]
pub struct I2c<R> {
pub regs: R,
pub cfg: I2cConfig,
}
Expand description
Represents an Inter-Integrated Circuit (I2C) peripheral.
Fields
regs: R
cfg: I2cConfig
Implementations
Initialize a I2C peripheral, including configuration register writes, and enabling and resetting
its RCC peripheral clock. freq
is in Hz.
Enable SMBus support. See L44 RM, section 37.4.11: SMBus initialization
Read multiple words to a buffer. Can return an error due to Bus, Arbitration, or NACK.
Write an array of words. Can return an error due to Bus, Arbitration, or NACK.
Write and read an array of words. Can return an error due to Bus, Arbitration, or NACK.
pub unsafe fn write_dma<D>(
&mut self,
addr: u8,
buf: &[u8],
autoend: bool,
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
pub unsafe fn write_dma<D>(
&mut self,
addr: u8,
buf: &[u8],
autoend: bool,
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
Read data, using DMA. See L44 RM, 37.4.16: “Transmission using DMA”
Note that the channel
argument is only used on F3 and L4.
For a single write, set autoend
to true
. For a write_read and other use cases,
set it to false
.
pub unsafe fn read_dma<D>(
&mut self,
addr: u8,
buf: &mut [u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
pub unsafe fn read_dma<D>(
&mut self,
addr: u8,
buf: &mut [u8],
channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
) where
D: Deref<Target = RegisterBlock>,
Read data, using DMA. See L44 RM, 37.4.16: “Reception using DMA”
Note that the channel
argument is only used on F3 and L4.