Skip to content

Commit 5617082

Browse files
committed
Mention what happens when the write and read slices in futures::spi::Transfer are different lengths
1 parent 941c8bb commit 5617082

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/futures/spi.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ pub trait Transfer<W: 'static> {
1212
where
1313
Self: 'a;
1414

15-
/// Writes `words` to the slave from the `write` buffer. Puts the words returned in the `read` buffer.
16-
/// This method uses separate `write` and `read` buffers.
15+
/// Writes and reads simultaneously. `write` is written to the slave on MOSI and
16+
/// words received on MISO are stored in `read`.
17+
///
18+
/// It is allowed for `read` and `write` to have different lengths, even zero length.
19+
/// The transfer runs for `max(read.len(), write.len())` words. If `read` is shorter,
20+
/// incoming words after `read` has been filled will be discarded. If `write` is shorter,
21+
/// the value of words sent in MOSI after all `write` has been sent is implementation defined,
22+
/// typically `0x00`, `0xFF`, or configurable.
1723
fn transfer<'a>(&'a mut self, write: &'a [W], read: &'a mut [W]) -> Self::TransferFuture<'a>;
1824
}
1925

0 commit comments

Comments
 (0)