File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -125,3 +125,31 @@ pub trait Transactional<W: 'static> {
125
125
/// Execute the provided transactions
126
126
fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > ;
127
127
}
128
+
129
+ /// Blocking transactional impl over spi::Write and spi::Transfer
130
+ pub mod transactional {
131
+ use super :: Operation ;
132
+
133
+ /// Default implementation of `blocking::spi::Transactional<W>` for implementers of
134
+ /// `spi::Write<W>` and `spi::Transfer<W>`
135
+ pub trait Default : { }
136
+
137
+ impl < W : ' static , E , S > crate :: blocking:: spi:: Transactional < W > for S
138
+ where
139
+ S : self :: Default + crate :: blocking:: spi:: Transfer < W , Error =E > + crate :: blocking:: spi:: Write < W , Error =E > ,
140
+ W : Clone ,
141
+ {
142
+ type Error = E ;
143
+
144
+ fn exec < ' a > ( & mut self , operations : & mut [ super :: Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > {
145
+ for op in operations {
146
+ match op {
147
+ Operation :: Write ( w) => self . write ( w) ?,
148
+ Operation :: Transfer ( t) => self . transfer ( t) . map ( |_| ( ) ) ?,
149
+ }
150
+ }
151
+
152
+ Ok ( ( ) )
153
+ }
154
+ }
155
+ }
You can’t perform that action at this time.
0 commit comments