pub trait I2cSlave {
// Required methods
fn slave_sbc(&mut self, sbc_enabled: bool);
fn slave_addressed(&mut self) -> Result<Option<(u16, I2cDirection)>, Error>;
fn slave_wait_addressed(&mut self) -> Result<(u16, I2cDirection), Error>;
fn slave_read(&mut self, bytes: &mut [u8]) -> Result<(), Error>;
fn slave_write(&mut self, bytes: &[u8]) -> Result<(), Error>;
}
Required Methods§
Sourcefn 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.
Sourcefn 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
Sourcefn 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
Sourcefn 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)
Sourcefn 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)