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