@@ -9,19 +9,32 @@ pub trait Read<W = u8>: ErrorType {
9
9
/// The word value sent on MOSI during reading is implementation-defined,
10
10
/// typically `0x00`, `0xFF`, or configurable.
11
11
fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
12
+
13
+ /// Reads all slices in `words` from the slave as part of a single SPI transaction.
14
+ ///
15
+ /// The word value sent on MOSI during reading is implementation-defined,
16
+ /// typically `0x00`, `0xFF`, or configurable.
17
+ fn read_batch ( & mut self , words : & mut [ & mut [ W ] ] ) -> Result < ( ) , Self :: Error > ;
12
18
}
13
19
14
20
impl < T : Read < W > , W > Read < W > for & mut T {
15
21
fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
16
22
T :: read ( self , words)
17
23
}
24
+
25
+ fn read_batch ( & mut self , words : & mut [ & mut [ W ] ] ) -> Result < ( ) , Self :: Error > {
26
+ T :: read_batch ( self , words)
27
+ }
18
28
}
19
29
20
30
/// Blocking write-only SPI
21
31
pub trait Write < W = u8 > : ErrorType {
22
32
/// Writes `words` to the slave, ignoring all the incoming words
23
33
fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > ;
24
34
35
+ /// Writes all slices in `words` to the slave as part of a single SPI transaction, ignoring all the incoming words
36
+ fn write_batch ( & mut self , words : & [ & [ W ] ] ) -> Result < ( ) , Self :: Error > ;
37
+
25
38
/// Writes `words` to the slave, ignoring all the incoming words
26
39
fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
27
40
where
@@ -33,6 +46,10 @@ impl<T: Write<W>, W> Write<W> for &mut T {
33
46
T :: write ( self , words)
34
47
}
35
48
49
+ fn write_batch ( & mut self , words : & [ & [ W ] ] ) -> Result < ( ) , Self :: Error > {
50
+ T :: write_batch ( self , words)
51
+ }
52
+
36
53
fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
37
54
where
38
55
WI : IntoIterator < Item = W > ,
0 commit comments