@@ -77,31 +77,25 @@ mod nb {
7777mod blocking {
7878 use super :: super :: { Error , Instance , Spi , TransferModeBidi , TransferModeNormal } ;
7979 use embedded_hal_one:: spi:: {
80- blocking:: { Operation , Read , Transactional , Transfer , TransferInplace , Write , WriteIter } ,
80+ blocking:: { SpiBus , SpiBusFlush , SpiBusRead , SpiBusWrite } ,
8181 nb:: FullDuplex ,
8282 } ;
8383
84- impl < SPI , PINS , TRANSFER_MODE , W : Copy + ' static > TransferInplace < W >
84+ impl < SPI , PINS , TRANSFER_MODE , W : Copy + Default + ' static > SpiBus < W >
8585 for Spi < SPI , PINS , TRANSFER_MODE >
8686 where
87- Self : FullDuplex < W , Error = Error > ,
87+ Self : FullDuplex < W , Error = Error > + SpiBusWrite < W > ,
8888 SPI : Instance ,
8989 {
90- fn transfer_inplace ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
90+ fn transfer_in_place ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
9191 for word in words. iter_mut ( ) {
9292 nb:: block!( <Self as FullDuplex <W >>:: write( self , * word) ) ?;
9393 * word = nb:: block!( <Self as FullDuplex <W >>:: read( self ) ) ?;
9494 }
9595
9696 Ok ( ( ) )
9797 }
98- }
9998
100- impl < SPI , PINS , TRANSFER_MODE , W : Copy + ' static > Transfer < W > for Spi < SPI , PINS , TRANSFER_MODE >
101- where
102- Self : FullDuplex < W , Error = Error > ,
103- SPI : Instance ,
104- {
10599 fn transfer ( & mut self , buff : & mut [ W ] , data : & [ W ] ) -> Result < ( ) , Self :: Error > {
106100 assert_eq ! ( data. len( ) , buff. len( ) ) ;
107101
@@ -114,71 +108,45 @@ mod blocking {
114108 }
115109 }
116110
117- impl < SPI , PINS , W : Copy + ' static > Write < W > for Spi < SPI , PINS , TransferModeNormal >
111+ impl < SPI , PINS , TRANSFER_MODE > SpiBusFlush for Spi < SPI , PINS , TRANSFER_MODE >
118112 where
119- Self : FullDuplex < W , Error = Error > ,
120113 SPI : Instance ,
121114 {
122- fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > {
123- for word in words {
124- nb:: block!( <Self as FullDuplex <W >>:: write( self , * word) ) ?;
125- nb:: block!( <Self as FullDuplex <W >>:: read( self ) ) ?;
126- }
127-
115+ fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
128116 Ok ( ( ) )
129117 }
130118 }
131119
132- impl < SPI , PINS , W : Copy + ' static > Write < W > for Spi < SPI , PINS , TransferModeBidi >
120+ impl < SPI , PINS , W : Copy + ' static > SpiBusWrite < W > for Spi < SPI , PINS , TransferModeNormal >
133121 where
134122 Self : FullDuplex < W , Error = Error > ,
135123 SPI : Instance ,
136124 {
137125 fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > {
138126 for word in words {
139127 nb:: block!( <Self as FullDuplex <W >>:: write( self , * word) ) ?;
140- }
141-
142- Ok ( ( ) )
143- }
144- }
145-
146- impl < SPI , PINS , W : Copy + ' static > WriteIter < W > for Spi < SPI , PINS , TransferModeNormal >
147- where
148- Self : FullDuplex < W , Error = Error > ,
149- SPI : Instance ,
150- {
151- fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
152- where
153- WI : IntoIterator < Item = W > ,
154- {
155- for word in words. into_iter ( ) {
156- nb:: block!( <Self as FullDuplex <W >>:: write( self , word) ) ?;
157128 nb:: block!( <Self as FullDuplex <W >>:: read( self ) ) ?;
158129 }
159130
160131 Ok ( ( ) )
161132 }
162133 }
163134
164- impl < SPI , PINS , W : Copy + ' static > WriteIter < W > for Spi < SPI , PINS , TransferModeBidi >
135+ impl < SPI , PINS , W : Copy + ' static > SpiBusWrite < W > for Spi < SPI , PINS , TransferModeBidi >
165136 where
166137 Self : FullDuplex < W , Error = Error > ,
167138 SPI : Instance ,
168139 {
169- fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
170- where
171- WI : IntoIterator < Item = W > ,
172- {
173- for word in words. into_iter ( ) {
174- nb:: block!( <Self as FullDuplex <W >>:: write( self , word) ) ?;
140+ fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > {
141+ for word in words {
142+ nb:: block!( <Self as FullDuplex <W >>:: write( self , * word) ) ?;
175143 }
176144
177145 Ok ( ( ) )
178146 }
179147 }
180148
181- impl < SPI , PINS , TRANSFER_MODE , W : Copy + Default + ' static > Read < W >
149+ impl < SPI , PINS , TRANSFER_MODE , W : Copy + Default + ' static > SpiBusRead < W >
182150 for Spi < SPI , PINS , TRANSFER_MODE >
183151 where
184152 Self : FullDuplex < W , Error = Error > ,
@@ -193,25 +161,4 @@ mod blocking {
193161 Ok ( ( ) )
194162 }
195163 }
196-
197- impl < SPI , PINS , TRANSFER_MODE , W : Copy + ' static > Transactional < W > for Spi < SPI , PINS , TRANSFER_MODE >
198- where
199- Self : Write < W , Error = Error >
200- + Read < W , Error = Error >
201- + TransferInplace < W , Error = Error >
202- + Transfer < W , Error = Error > ,
203- {
204- fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Error > {
205- for op in operations {
206- match op {
207- Operation :: Write ( w) => self . write ( w) ?,
208- Operation :: TransferInplace ( t) => self . transfer_inplace ( t) ?,
209- Operation :: Read ( r) => self . read ( r) ?,
210- Operation :: Transfer ( w, r) => self . transfer ( w, r) ?,
211- }
212- }
213-
214- Ok ( ( ) )
215- }
216- }
217164}
0 commit comments