pub struct Transfer {
pub buf: FixedVec<u8>,
pub len: usize,
pub end: bool,
pub dir: OpKind,
pub rsp: Sender<Result<FixedVec<u8>, ErrorKind>>,
}
Expand description
An I²C bus transfer within a Transaction
.
This message is sent to the I2cService
by a Transaction
in order
to perform an individual bus read or write as part of that transaction.
Fields§
§buf: FixedVec<u8>
A buffer to read bytes into (if dir
is OpKind::Read
), or write
bytes from (if dir
is OpKind::Write
).
If performing a write, this buffer is guaranteed to contain at least
len
bytes. The driver is expected to write the contents of this
buffer to the I²C bus starting at buf[0]
and ending at
buf[len - 1]
.
If performing a read, this buffer is guaranteed to have at least
len
capacity remaining. The driver is expected to read by
appending bytes to the end of this buffer until len
bytes have
been appended.
len: usize
The number of bytes to read or write from buf
in this I²C bus
transfer.
end: bool
If true
, this transfer is the last transfer in the transaction.
If end
is true
, the driver is expected to send a STOP
condition
when the transfer has completed. Otherwise, the driver should send a
repeated START
, as additional transfers will be performed.
Once the driver has completed a transfer with end == true
, it is
permitted to return errors for any subsequent transfers in the
current transaction.
dir: OpKind
Whether this is a read (OpKind::Read
) or write
(OpKind::Write
) transfer.
rsp: Sender<Result<FixedVec<u8>, ErrorKind>>
Sender for responses once the transfer has completed.
Once the driver has completed the transfer, it is required to send
back the buf
received in this Transfer
message if the transfer
completed successfully.
If the transfer was a read, then buf
should contain the bytes read
from the I²C bus. If the transfer was a write, buf may
contain any data, or be empty.
If the transfer could not be completed successfully, then the driver
must send an i2c::ErrorKind
indicating the cause of the failure,
instead.