Struct rp2040_hal::i2c::I2C
source · pub struct I2C<I2C, Pins, Mode = Controller> { /* private fields */ }
Expand description
I2C peripheral
Implementations§
source§impl<T: SubsystemReset + Deref<Target = Block>, Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Controller>
impl<T: SubsystemReset + Deref<Target = Block>, Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Controller>
sourcepub fn new_controller(
i2c: T,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: HertzU32,
resets: &mut RESETS,
system_clock: HertzU32
) -> Selfwhere
Sda: SdaPin<T>,
Scl: SclPin<T>,
pub fn new_controller(
i2c: T,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: HertzU32,
resets: &mut RESETS,
system_clock: HertzU32
) -> Selfwhere
Sda: SdaPin<T>,
Scl: SclPin<T>,
Configures the I2C peripheral to work in controller mode
source§impl<T, Sda, Scl> I2C<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Peripheral>where
T: SubsystemReset + Deref<Target = I2CBlock>,
Sda: PinId + BankPinId,
Scl: PinId + BankPinId,
impl<T, Sda, Scl> I2C<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Peripheral>where
T: SubsystemReset + Deref<Target = I2CBlock>,
Sda: PinId + BankPinId,
Scl: PinId + BankPinId,
sourcepub fn new_peripheral_event_iterator(
i2c: T,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
resets: &mut RESETS,
addr: u16
) -> I2CPeripheralEventIterator<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)> ⓘwhere
Sda: SdaPin<T>,
Scl: SclPin<T>,
pub fn new_peripheral_event_iterator(
i2c: T,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
resets: &mut RESETS,
addr: u16
) -> I2CPeripheralEventIterator<T, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)> ⓘwhere
Sda: SdaPin<T>,
Scl: SclPin<T>,
Configures the I2C peripheral to work in peripheral mode
The bus MUST be idle when this method is called.
source§impl<Block, Sda, Scl, Mode> I2C<Block, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Mode>where
Block: SubsystemReset + Deref<Target = I2CBlock>,
Sda: PinId + BankPinId,
Scl: PinId + BankPinId,
Mode: I2CMode,
impl<Block, Sda, Scl, Mode> I2C<Block, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>), Mode>where
Block: SubsystemReset + Deref<Target = I2CBlock>,
Sda: PinId + BankPinId,
Scl: PinId + BankPinId,
Mode: I2CMode,
sourcepub fn free(
self,
resets: &mut RESETS
) -> (Block, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>))
pub fn free(
self,
resets: &mut RESETS
) -> (Block, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>))
Releases the I2C peripheral and associated pins
source§impl<Block: Deref<Target = I2CBlock>, PINS, Mode> I2C<Block, PINS, Mode>
impl<Block: Deref<Target = I2CBlock>, PINS, Mode> I2C<Block, PINS, Mode>
sourcepub fn rx_fifo_used(&self) -> u8
pub fn rx_fifo_used(&self) -> u8
Number of bytes currently in the RX FIFO
sourcepub fn rx_fifo_free(&self) -> u8
pub fn rx_fifo_free(&self) -> u8
Remaining capacity in the RX FIFO
sourcepub fn rx_fifo_empty(&self) -> bool
pub fn rx_fifo_empty(&self) -> bool
RX FIFO is empty
sourcepub fn tx_fifo_used(&self) -> u8
pub fn tx_fifo_used(&self) -> u8
Number of bytes currently in the TX FIFO
sourcepub fn tx_fifo_free(&self) -> u8
pub fn tx_fifo_free(&self) -> u8
Remaining capacity in the TX FIFO
sourcepub fn tx_fifo_full(&self) -> bool
pub fn tx_fifo_full(&self) -> bool
TX FIFO is at capacity
source§impl<Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<I2C0, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)>
impl<Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<I2C0, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)>
sourcepub fn i2c0<F, SystemF>(
i2c: I2C0,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: F,
resets: &mut RESETS,
system_clock: SystemF
) -> Selfwhere
F: Into<HertzU32>,
Sda: SdaPin<I2C0>,
Scl: SclPin<I2C0>,
SystemF: Into<HertzU32>,
pub fn i2c0<F, SystemF>(
i2c: I2C0,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: F,
resets: &mut RESETS,
system_clock: SystemF
) -> Selfwhere
F: Into<HertzU32>,
Sda: SdaPin<I2C0>,
Scl: SclPin<I2C0>,
SystemF: Into<HertzU32>,
Configures the I2C peripheral to work in master mode
source§impl<Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<I2C1, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)>
impl<Sda: PinId + BankPinId, Scl: PinId + BankPinId> I2C<I2C1, (Pin<Sda, FunctionI2C>, Pin<Scl, FunctionI2C>)>
sourcepub fn i2c1<F, SystemF>(
i2c: I2C1,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: F,
resets: &mut RESETS,
system_clock: SystemF
) -> Selfwhere
F: Into<HertzU32>,
Sda: SdaPin<I2C1>,
Scl: SclPin<I2C1>,
SystemF: Into<HertzU32>,
pub fn i2c1<F, SystemF>(
i2c: I2C1,
sda_pin: Pin<Sda, FunctionI2C>,
scl_pin: Pin<Scl, FunctionI2C>,
freq: F,
resets: &mut RESETS,
system_clock: SystemF
) -> Selfwhere
F: Into<HertzU32>,
Sda: SdaPin<I2C1>,
Scl: SclPin<I2C1>,
SystemF: Into<HertzU32>,
Configures the I2C peripheral to work in master mode