Struct I2cDriver

Source
pub struct I2cDriver<'a> {
    regs: *mut RegisterBlock,
    _callback: Option<Box<dyn FnMut(Event) + 'a>>,
    config: I2cConfig,
    data_count: u32,
}
Expand description

A polling-based I2C driver for STM32F407.

Fields§

§regs: *mut RegisterBlock§_callback: Option<Box<dyn FnMut(Event) + 'a>>§config: I2cConfig§data_count: u32

Implementations§

Source§

impl<'a> I2cDriver<'a>

Source

pub fn new(i2c_base_addr: u32, config: I2cConfig) -> Self

Source

pub fn new_i2c1(config: I2cConfig) -> Self

Create a new I2C1 driver instance

Source

pub fn new_i2c2(config: I2cConfig) -> Self

Create a new I2C2 driver instance

Source

pub fn new_i2c3(config: I2cConfig) -> Self

Create a new I2C3 driver instance

Source

fn regs(&self) -> &mut RegisterBlock

Source

fn generate_start_condition(&mut self)

Source

fn generate_stop_condition(&mut self)

Source

fn execute_address_phase_write(&mut self, slave_addr: u32)

Source

fn execute_address_phase_read(&mut self, slave_addr: u32)

Source

fn get_flag_status(&self, flag_bit: u32) -> bool

Source

fn clear_addr_flag(&mut self)

Source

fn manage_acking(&mut self, enable: bool)

Trait Implementations§

Source§

impl<'a> I2c<'a> for I2cDriver<'a>

Source§

fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>

Initializes the I2C peripheral. Read more
Source§

fn uninitialize(&mut self) -> Result<(), i32>

De-initializes the I2C peripheral.
Source§

fn master_transmit( &mut self, addr: u32, data: &[u8], xfer_pending: bool, ) -> Result<(), i32>

Transmits data as an I2C master. Read more
Source§

fn master_receive( &mut self, addr: u32, data: &mut [u8], xfer_pending: bool, ) -> Result<(), i32>

Receives data as an I2C master. Read more
Source§

fn slave_transmit(&mut self, _data: &[u8]) -> Result<(), i32>

Transmits data as an I2C slave.
Source§

fn slave_receive(&mut self, _data: &mut [u8]) -> Result<(), i32>

Receives data as an I2C slave.
Source§

fn get_data_count(&self) -> Result<u32, i32>

Gets the number of bytes transferred in the last transaction.
Source§

fn set_bus_speed(&mut self, _speed: BusSpeed) -> Result<(), i32>

Sets the bus speed for the I2C communication.
Source§

fn set_own_address(&mut self, _address: u32) -> Result<(), i32>

Sets the slave address for the I2C peripheral when in slave mode.
Source§

fn clear_bus(&mut self) -> Result<(), i32>

Initiates a bus clear operation.
Source§

fn abort_transfer(&mut self) -> Result<(), i32>

Aborts an ongoing I2C transfer.
Source§

fn get_status(&self) -> Status

Gets the current status of the I2C peripheral.

Auto Trait Implementations§

§

impl<'a> Freeze for I2cDriver<'a>

§

impl<'a> !RefUnwindSafe for I2cDriver<'a>

§

impl<'a> !Send for I2cDriver<'a>

§

impl<'a> !Sync for I2cDriver<'a>

§

impl<'a> Unpin for I2cDriver<'a>

§

impl<'a> !UnwindSafe for I2cDriver<'a>

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.