1
1
use core:: {
2
- future:: Future ,
2
+ future:: { Future , IntoFuture } ,
3
3
ops:: { Deref , DerefMut } ,
4
4
pin:: Pin ,
5
5
task:: { Context , Poll } ,
@@ -208,8 +208,7 @@ where
208
208
pub fn start_dma_read < ' a > (
209
209
& ' a mut self ,
210
210
words : & ' a mut [ W ] ,
211
- ) -> Result < DmaTransfer < ' a , impl DmaChannel + use < ' a , SPI , W , MODE > > , Error >
212
- {
211
+ ) -> Result < DmaTransfer < ' a , <MODE as Rx < W > >:: CH > , Error > {
213
212
let config = DmaConfig :: new ( ) . with_request ( SPI :: rx_dma_request ( ) ) ;
214
213
215
214
self . spi . inner . set_transfer_word_count ( words. len ( ) as u16 ) ;
@@ -229,7 +228,7 @@ where
229
228
}
230
229
231
230
async fn read_dma ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Error > {
232
- let result = self . start_dma_read ( words) ?. to_async ( ) . await ;
231
+ let result = self . start_dma_read ( words) ?. await ;
233
232
self . finish_transfer_async ( result) . await
234
233
}
235
234
}
@@ -243,8 +242,7 @@ where
243
242
pub fn start_dma_write < ' a > (
244
243
& ' a mut self ,
245
244
words : & ' a [ W ] ,
246
- ) -> Result < DmaTransfer < ' a , impl DmaChannel + use < ' a , SPI , W , MODE > > , Error >
247
- {
245
+ ) -> Result < DmaTransfer < ' a , <MODE as Tx < W > >:: CH > , Error > {
248
246
let config = DmaConfig :: new ( ) . with_request ( SPI :: tx_dma_request ( ) ) ;
249
247
250
248
self . inner . set_transfer_word_count ( words. len ( ) as u16 ) ;
@@ -263,28 +261,23 @@ where
263
261
}
264
262
265
263
async fn write_dma ( & mut self , words : & [ W ] ) -> Result < ( ) , Error > {
266
- let result = self . start_dma_write ( words) ?. to_async ( ) . await ;
264
+ let result = self . start_dma_write ( words) ?. await ;
267
265
self . finish_transfer_async ( result) . await
268
266
}
269
267
}
270
268
271
- impl < SPI , MODE , W > SpiDma < SPI , MODE , W >
269
+ impl < SPI , TX , RX , W > SpiDma < SPI , DmaDuplex < SPI , W , TX , RX > , W >
272
270
where
273
271
SPI : Instance ,
274
272
W : Word + DmaWord ,
275
- MODE : Tx < W > + Rx < W > ,
273
+ TX : DmaChannel ,
274
+ RX : DmaChannel ,
276
275
{
277
276
pub fn start_dma_duplex_transfer < ' a > (
278
277
& ' a mut self ,
279
278
read : & ' a mut [ W ] ,
280
279
write : & ' a [ W ] ,
281
- ) -> Result <
282
- (
283
- DmaTransfer < ' a , impl DmaChannel + use < ' a , SPI , W , MODE > > ,
284
- DmaTransfer < ' a , impl DmaChannel + use < ' a , SPI , W , MODE > > ,
285
- ) ,
286
- Error ,
287
- > {
280
+ ) -> Result < ( DmaTransfer < ' a , TX > , DmaTransfer < ' a , RX > ) , Error > {
288
281
let tx_config = DmaConfig :: new ( ) . with_request ( SPI :: tx_dma_request ( ) ) ;
289
282
let rx_config = DmaConfig :: new ( ) . with_request ( SPI :: rx_dma_request ( ) ) ;
290
283
@@ -311,7 +304,7 @@ where
311
304
write : & [ W ] ,
312
305
) -> Result < ( ) , Error > {
313
306
let ( tx, rx) = self . start_dma_duplex_transfer ( read, write) ?;
314
- let ( tx, rx) = ( tx. to_async ( ) , rx. to_async ( ) ) ;
307
+ let ( tx, rx) = ( tx. into_future ( ) , rx. into_future ( ) ) ;
315
308
let results = join ! ( tx, rx) ;
316
309
let result = results. 0 . and ( results. 1 ) ;
317
310
0 commit comments