pub struct I2c<I2C, SDA, SCL> { /* private fields */ }
Expand description
I2C abstraction
Implementations§
Source§impl<SDA, SCL> I2c<I2C1, SDA, SCL>
impl<SDA, SCL> I2c<I2C1, SDA, SCL>
Source§impl<SDA, SCL> I2c<I2C2, SDA, SCL>
impl<SDA, SCL> I2c<I2C2, SDA, SCL>
Trait Implementations§
Source§impl<SDA, SCL> I2cSlave for I2c<I2C1, SDA, SCL>
impl<SDA, SCL> I2cSlave for I2c<I2C1, SDA, SCL>
Source§fn slave_sbc(&mut self, sbc_enabled: bool)
fn slave_sbc(&mut self, sbc_enabled: bool)
Enable/Disable Slave Byte Control. Default SBC is switched on.
For master write/read the transaction should start with sbc disabled.
So ACK will be send on the last received byte.
Before the send phase SBC should be enabled again.
Source§fn slave_addressed(&mut self) -> Result<Option<(u16, I2cDirection)>, Error>
fn slave_addressed(&mut self) -> Result<Option<(u16, I2cDirection)>, Error>
An optional tuple is returned with the address as sent by the master. The address is for 7 bit in range of 0..127
Source§fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>
fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>
Wait until this slave is addressed by the master.
A tuple is returned with the address as sent by the master. The address is for 7 bit in range of 0..127
Source§fn slave_write(&mut self, bytes: &[u8]) -> Result<(), Error>
fn slave_write(&mut self, bytes: &[u8]) -> Result<(), Error>
Start writing the bytes, the master want to receive. If OK returned, all bytes are transferred
If the master wants more data than bytes.len() the master will run into a timeout, This function will return Ok(())
If the master wants less data than bytes.len(), the function will return IncorrectFrameSize(bytes.len() + 1)
Source§fn slave_read(&mut self, bytes: &mut [u8]) -> Result<(), Error>
fn slave_read(&mut self, bytes: &mut [u8]) -> Result<(), Error>
Start reading the bytes, send by the master . If OK returned, all bytes are transferred
If the master want to send more bytes than the slave can recieve the slave will NACK the n+1 byte
In this case the function will return IncorrectFrameSize(bytes.len() + 1)
If the master did send a STOP before all bytes are recieve, the slave will return IncorrectFrameSize(actual nr of bytes send)
Source§impl<SDA, SCL> I2cSlave for I2c<I2C2, SDA, SCL>
impl<SDA, SCL> I2cSlave for I2c<I2C2, SDA, SCL>
Source§fn slave_sbc(&mut self, sbc_enabled: bool)
fn slave_sbc(&mut self, sbc_enabled: bool)
Enable/Disable Slave Byte Control. Default SBC is switched on.
For master write/read the transaction should start with sbc disabled.
So ACK will be send on the last received byte.
Before the send phase SBC should be enabled again.
Source§fn slave_addressed(&mut self) -> Result<Option<(u16, I2cDirection)>, Error>
fn slave_addressed(&mut self) -> Result<Option<(u16, I2cDirection)>, Error>
An optional tuple is returned with the address as sent by the master. The address is for 7 bit in range of 0..127
Source§fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>
fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>
Wait until this slave is addressed by the master.
A tuple is returned with the address as sent by the master. The address is for 7 bit in range of 0..127
Source§fn slave_write(&mut self, bytes: &[u8]) -> Result<(), Error>
fn slave_write(&mut self, bytes: &[u8]) -> Result<(), Error>
Start writing the bytes, the master want to receive. If OK returned, all bytes are transferred
If the master wants more data than bytes.len() the master will run into a timeout, This function will return Ok(())
If the master wants less data than bytes.len(), the function will return IncorrectFrameSize(bytes.len() + 1)
Source§fn slave_read(&mut self, bytes: &mut [u8]) -> Result<(), Error>
fn slave_read(&mut self, bytes: &mut [u8]) -> Result<(), Error>
Start reading the bytes, send by the master . If OK returned, all bytes are transferred
If the master want to send more bytes than the slave can recieve the slave will NACK the n+1 byte
In this case the function will return IncorrectFrameSize(bytes.len() + 1)
If the master did send a STOP before all bytes are recieve, the slave will return IncorrectFrameSize(actual nr of bytes send)
Auto Trait Implementations§
impl<I2C, SDA, SCL> Freeze for I2c<I2C, SDA, SCL>
impl<I2C, SDA, SCL> RefUnwindSafe for I2c<I2C, SDA, SCL>
impl<I2C, SDA, SCL> Send for I2c<I2C, SDA, SCL>
impl<I2C, SDA, SCL> Sync for I2c<I2C, SDA, SCL>
impl<I2C, SDA, SCL> Unpin for I2c<I2C, SDA, SCL>
impl<I2C, SDA, SCL> UnwindSafe for I2c<I2C, SDA, SCL>
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