@@ -23,6 +23,17 @@ pub trait Read<W>: Spi {
23
23
/// The word value sent on MOSI during reading is implementation-defined,
24
24
/// typically `0x00`, `0xFF`, or configurable.
25
25
fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
26
+
27
+ /// Reads all slices in `words` from the slave as part of a single SPI transaction.
28
+ ///
29
+ /// The word value sent on MOSI during reading is implementation-defined,
30
+ /// typically `0x00`, `0xFF`, or configurable.
31
+ fn read_batch ( & mut self , words : & mut [ & mut [ W ] ] ) -> Result < ( ) , Self :: Error > {
32
+ for buf in words {
33
+ self . read ( buf) ?;
34
+ }
35
+ Ok ( ( ) )
36
+ }
26
37
}
27
38
28
39
impl < T : Read < W > , W > Read < W > for & mut T {
@@ -36,6 +47,14 @@ pub trait Write<W>: Spi {
36
47
/// Writes `words` to the slave, ignoring all the incoming words
37
48
fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > ;
38
49
50
+ /// Writes all slices in `words` to the slave as part of a single SPI transaction, ignoring all the incoming words
51
+ fn write_batch ( & mut self , words : & [ & [ W ] ] ) -> Result < ( ) , Self :: Error > {
52
+ for buf in words {
53
+ self . write ( buf) ?;
54
+ }
55
+ Ok ( ( ) )
56
+ }
57
+
39
58
/// Writes `words` to the slave, ignoring all the incoming words
40
59
fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
41
60
where
@@ -53,6 +72,10 @@ impl<T: Write<W>, W> Write<W> for &mut T {
53
72
T :: write ( self , words)
54
73
}
55
74
75
+ fn write_batch ( & mut self , words : & [ & [ W ] ] ) -> Result < ( ) , Self :: Error > {
76
+ T :: write_batch ( self , words)
77
+ }
78
+
56
79
fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
57
80
where
58
81
WI : IntoIterator < Item = W > ,
0 commit comments