1
- use core:: { marker:: PhantomData , mem:: transmute, ops :: Deref } ;
1
+ use core:: { marker:: PhantomData , mem:: transmute} ;
2
2
3
3
use super :: { Instance , RegisterBlockImpl , Serial } ;
4
4
use crate :: dma:: {
@@ -67,12 +67,7 @@ pub trait SerialHandleIT {
67
67
fn handle_error_interrupt ( & mut self ) ;
68
68
}
69
69
70
- impl < Serial_ > Serial < Serial_ >
71
- where
72
- Serial_ : Instance ,
73
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
74
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
75
- {
70
+ impl < Serial_ : Instance > Serial < Serial_ > {
76
71
/// Converts blocking [Serial] to non-blocking [SerialDma] that use `tx_stream` and `rx_stream` to send/receive data
77
72
pub fn use_dma < TX_STREAM , const TX_CH : u8 , RX_STREAM , const RX_CH : u8 > (
78
73
self ,
@@ -152,10 +147,7 @@ where
152
147
///
153
148
/// The struct can be also used to send/receive bytes in blocking mode with methods:
154
149
/// [`write`](Self::write()), [`read`](Self::read()), [`write_read`](Self::write_read()).
155
- pub struct SerialDma < Serial_ , TX_TRANSFER , RX_TRANSFER >
156
- where
157
- Serial_ : Instance ,
158
- {
150
+ pub struct SerialDma < Serial_ : Instance , TX_TRANSFER , RX_TRANSFER > {
159
151
hal_serial : Serial < Serial_ > ,
160
152
callback : Option < SerialCompleteCallback > ,
161
153
tx : TX_TRANSFER ,
@@ -338,11 +330,8 @@ where
338
330
}
339
331
340
332
/// Common implementation
341
- impl < Serial_ , TX_TRANSFER , RX_TRANSFER > SerialDma < Serial_ , TX_TRANSFER , RX_TRANSFER >
333
+ impl < Serial_ : Instance , TX_TRANSFER , RX_TRANSFER > SerialDma < Serial_ , TX_TRANSFER , RX_TRANSFER >
342
334
where
343
- Serial_ : Instance ,
344
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
345
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
346
335
TX_TRANSFER : DMATransfer < & ' static [ u8 ] > ,
347
336
RX_TRANSFER : DMATransfer < & ' static mut [ u8 ] > ,
348
337
{
@@ -386,13 +375,9 @@ where
386
375
}
387
376
}
388
377
389
- impl < Serial_ , TX_STREAM , const TX_CH : u8 > SerialHandleIT
378
+ impl < Serial_ : Instance , TX_STREAM , const TX_CH : u8 > SerialHandleIT
390
379
for SerialDma < Serial_ , TxDMA < Serial_ , TX_STREAM , TX_CH > , NoDMA >
391
380
where
392
- Serial_ : Instance ,
393
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
394
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
395
-
396
381
TX_STREAM : Stream ,
397
382
ChannelX < TX_CH > : Channel ,
398
383
Tx < Serial_ > : DMASet < TX_STREAM , TX_CH , MemoryToPeripheral > ,
@@ -428,13 +413,9 @@ where
428
413
}
429
414
}
430
415
431
- impl < Serial_ , RX_STREAM , const RX_CH : u8 > SerialHandleIT
416
+ impl < Serial_ : Instance , RX_STREAM , const RX_CH : u8 > SerialHandleIT
432
417
for SerialDma < Serial_ , NoDMA , RxDMA < Serial_ , RX_STREAM , RX_CH > >
433
418
where
434
- Serial_ : Instance ,
435
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
436
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
437
-
438
419
RX_STREAM : Stream ,
439
420
ChannelX < RX_CH > : Channel ,
440
421
Rx < Serial_ > : DMASet < RX_STREAM , RX_CH , PeripheralToMemory > ,
@@ -471,13 +452,9 @@ where
471
452
}
472
453
473
454
/// Only for both TX and RX DMA
474
- impl < Serial_ , TX_STREAM , const TX_CH : u8 , RX_STREAM , const RX_CH : u8 > SerialHandleIT
455
+ impl < Serial_ : Instance , TX_STREAM , const TX_CH : u8 , RX_STREAM , const RX_CH : u8 > SerialHandleIT
475
456
for SerialDma < Serial_ , TxDMA < Serial_ , TX_STREAM , TX_CH > , RxDMA < Serial_ , RX_STREAM , RX_CH > >
476
457
where
477
- Serial_ : Instance ,
478
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
479
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
480
-
481
458
TX_STREAM : Stream ,
482
459
ChannelX < TX_CH > : Channel ,
483
460
Tx < Serial_ > : DMASet < TX_STREAM , TX_CH , MemoryToPeripheral > ,
@@ -550,13 +527,9 @@ where
550
527
}
551
528
552
529
// Write DMA implementations for TX only and TX/RX Serial DMA
553
- impl < Serial_ , TX_STREAM , const TX_CH : u8 , RX_TRANSFER > SerialWriteDMA
530
+ impl < Serial_ : Instance , TX_STREAM , const TX_CH : u8 , RX_TRANSFER > SerialWriteDMA
554
531
for SerialDma < Serial_ , TxDMA < Serial_ , TX_STREAM , TX_CH > , RX_TRANSFER >
555
532
where
556
- Serial_ : Instance ,
557
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
558
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
559
-
560
533
TX_STREAM : Stream ,
561
534
ChannelX < TX_CH > : Channel ,
562
535
Tx < Serial_ > : DMASet < TX_STREAM , TX_CH , MemoryToPeripheral > ,
@@ -581,13 +554,9 @@ where
581
554
}
582
555
583
556
// Read DMA implementations for RX only and TX/RX Serial DMA
584
- impl < Serial_ , TX_TRANSFER , RX_STREAM , const RX_CH : u8 > SerialReadDMA
557
+ impl < Serial_ : Instance , TX_TRANSFER , RX_STREAM , const RX_CH : u8 > SerialReadDMA
585
558
for SerialDma < Serial_ , TX_TRANSFER , RxDMA < Serial_ , RX_STREAM , RX_CH > >
586
559
where
587
- Serial_ : Instance ,
588
- Serial_ : Deref < Target = <Serial_ as Instance >:: RegisterBlock > ,
589
- <Serial_ as Instance >:: RegisterBlock : RegisterBlockImpl ,
590
-
591
560
RX_STREAM : Stream ,
592
561
ChannelX < RX_CH > : Channel ,
593
562
Rx < Serial_ > : DMASet < RX_STREAM , RX_CH , PeripheralToMemory > ,
0 commit comments