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: u32Implementations§
Source§impl<'a> I2cDriver<'a>
impl<'a> I2cDriver<'a>
pub fn new(i2c_base_addr: u32, config: I2cConfig) -> Self
fn regs(&self) -> &mut RegisterBlock
fn generate_start_condition(&mut self)
fn generate_stop_condition(&mut self)
fn execute_address_phase_write(&mut self, slave_addr: u32)
fn execute_address_phase_read(&mut self, slave_addr: u32)
fn get_flag_status(&self, flag_bit: u32) -> bool
fn clear_addr_flag(&mut self)
fn manage_acking(&mut self, enable: bool)
Trait Implementations§
Source§impl<'a> I2c<'a> for I2cDriver<'a>
impl<'a> I2c<'a> for I2cDriver<'a>
Source§fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
Initializes the I2C peripheral. Read more
Source§fn master_transmit(
&mut self,
addr: u32,
data: &[u8],
xfer_pending: bool,
) -> Result<(), i32>
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>
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_receive(&mut self, _data: &mut [u8]) -> Result<(), i32>
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>
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>
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>
fn set_own_address(&mut self, _address: u32) -> Result<(), i32>
Sets the slave address for the I2C peripheral when in slave mode.
Source§fn get_status(&self) -> Status
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more