@@ -25,6 +25,8 @@ pub type DMAMUXRegisterBlock = stm32::dmamux::RegisterBlock;
25
25
26
26
/// Trait that represents an instance of a DMA peripheral
27
27
pub trait Instance : Deref < Target = DMARegisterBlock > + Sealed {
28
+ const IS_DMA1 : bool ;
29
+
28
30
/// Gives a pointer to the RegisterBlock.
29
31
fn ptr ( ) -> * const DMARegisterBlock ;
30
32
@@ -33,6 +35,8 @@ pub trait Instance: Deref<Target = DMARegisterBlock> + Sealed {
33
35
}
34
36
35
37
impl Instance for DMA1 {
38
+ const IS_DMA1 : bool = true ;
39
+
36
40
#[ inline( always) ]
37
41
fn ptr ( ) -> * const DMARegisterBlock {
38
42
DMA1 :: ptr ( )
@@ -45,6 +49,8 @@ impl Instance for DMA1 {
45
49
}
46
50
47
51
impl Instance for DMA2 {
52
+ const IS_DMA1 : bool = false ;
53
+
48
54
#[ inline( always) ]
49
55
fn ptr ( ) -> * const DMARegisterBlock {
50
56
DMA2 :: ptr ( )
@@ -178,7 +184,7 @@ macro_rules! dma_stream {
178
184
( $( ( $name: ident, $number: expr,
179
185
regs => $ccr: ident, $cparX: ident, $cmarX: ident, $cndtrX: ident,
180
186
fields => $tcif: ident, $htif: ident, $teif: ident, $gif: ident, $tcisr: ident, $htisr: ident, $teisr: ident, $gisr: ident,
181
- dmamux => $cXcr : ident, )
187
+ dmamux => $dma1_cXcr : ident, $dma2_cXcr : ident , )
182
188
) ,+$( , ) * ) => {
183
189
$(
184
190
impl <I : Instance > Stream for $name<I > {
@@ -294,8 +300,13 @@ macro_rules! dma_stream {
294
300
//NOTE(unsafe) We only access the registers that belongs to the StreamX
295
301
let dmamux = unsafe { & * I :: mux_ptr( ) } ;
296
302
unsafe {
297
- dmamux. $cXcr
298
- . modify( |_, w| w. dmareq_id( ) . bits( request_line) ) ;
303
+ if I :: IS_DMA1 {
304
+ dmamux. $dma1_cXcr
305
+ . modify( |_, w| w. dmareq_id( ) . bits( request_line) ) ;
306
+ } else {
307
+ dmamux. $dma2_cXcr
308
+ . modify( |_, w| w. dmareq_id( ) . bits( request_line) ) ;
309
+ } ;
299
310
}
300
311
}
301
312
@@ -504,55 +515,108 @@ macro_rules! dma_stream {
504
515
} ;
505
516
}
506
517
518
+ // Cat 3 and 4 devices
519
+ #[ cfg( any(
520
+ feature = "stm32g471" ,
521
+ feature = "stm32g473" ,
522
+ feature = "stm32g474" ,
523
+ feature = "stm32g483" ,
524
+ feature = "stm32g484" ,
525
+ feature = "stm32g491" ,
526
+ feature = "stm32g49a" ,
527
+ ) ) ]
507
528
dma_stream ! (
508
529
// Note: the field names start from one, unlike the RM where they start from
509
530
// zero. May need updating if it gets fixed upstream.
510
531
(
511
532
Stream0 , 0 ,
512
533
regs => ccr1, cpar1, cmar1, cndtr1,
513
534
fields => tcif1, htif1, teif1, gif1, tcif1, htif1, teif1, gif1,
514
- dmamux => c0cr,
535
+ dmamux => c0cr, c8cr ,
515
536
) ,
516
537
(
517
538
Stream1 , 1 ,
518
539
regs => ccr2, cpar2, cmar2, cndtr2,
519
540
fields => tcif2, htif2, teif2, gif2, tcif2, htif2, teif2, gif2,
520
- dmamux => c1cr,
541
+ dmamux => c1cr, c9cr ,
521
542
) ,
522
543
(
523
544
Stream2 , 2 ,
524
545
regs => ccr3, cpar3, cmar3, cndtr3,
525
546
fields => tcif3, htif3, teif3, gif3, tcif3, htif3, teif3, gif3,
526
- dmamux => c2cr,
547
+ dmamux => c2cr, c10cr ,
527
548
) ,
528
549
(
529
550
Stream3 , 3 ,
530
551
regs => ccr4, cpar4, cmar4, cndtr4,
531
552
fields => tcif4, htif4, teif4, gif4, tcif4, htif4, teif4, gif4,
532
- dmamux => c3cr,
553
+ dmamux => c3cr, c11cr ,
533
554
) ,
534
555
(
535
556
Stream4 , 4 ,
536
557
regs => ccr5, cpar5, cmar5, cndtr5,
537
558
fields => tcif5, htif5, teif5, gif5, tcif5, htif5, teif5, gif5,
538
- dmamux => c4cr,
559
+ dmamux => c4cr, c12cr ,
539
560
) ,
540
561
(
541
562
Stream5 , 5 ,
542
563
regs => ccr6, cpar6, cmar6, cndtr6,
543
564
fields => tcif6, htif6, teif6, gif6, tcif6, htif6, teif6, gif6,
544
- dmamux => c5cr,
565
+ dmamux => c5cr, c13cr ,
545
566
) ,
546
567
(
547
568
Stream6 , 6 ,
548
569
regs => ccr7, cpar7, cmar7, cndtr7,
549
570
fields => tcif7, htif7, teif7, gif7, tcif7, htif7, teif7, gif7,
550
- dmamux => c6cr,
571
+ dmamux => c6cr, c14cr ,
551
572
) ,
552
573
(
553
574
Stream7 , 7 ,
554
575
regs => ccr8, cpar8, cmar8, cndtr8,
555
576
fields => tcif8, htif8, teif8, gif8, tcif8, htif8, teif8, gif8,
556
- dmamux => c7cr,
577
+ dmamux => c7cr, c15cr,
578
+ ) ,
579
+ ) ;
580
+
581
+ // Cat 2 devices
582
+ #[ cfg( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ]
583
+ dma_stream ! (
584
+ // Note: the field names start from one, unlike the RM where they start from
585
+ // zero. May need updating if it gets fixed upstream.
586
+ (
587
+ Stream0 , 0 ,
588
+ regs => ccr1, cpar1, cmar1, cndtr1,
589
+ fields => tcif1, htif1, teif1, gif1, tcif1, htif1, teif1, gif1,
590
+ dmamux => c0cr, c6cr,
591
+ ) ,
592
+ (
593
+ Stream1 , 1 ,
594
+ regs => ccr2, cpar2, cmar2, cndtr2,
595
+ fields => tcif2, htif2, teif2, gif2, tcif2, htif2, teif2, gif2,
596
+ dmamux => c1cr, c7cr,
597
+ ) ,
598
+ (
599
+ Stream2 , 2 ,
600
+ regs => ccr3, cpar3, cmar3, cndtr3,
601
+ fields => tcif3, htif3, teif3, gif3, tcif3, htif3, teif3, gif3,
602
+ dmamux => c2cr, c8cr,
603
+ ) ,
604
+ (
605
+ Stream3 , 3 ,
606
+ regs => ccr4, cpar4, cmar4, cndtr4,
607
+ fields => tcif4, htif4, teif4, gif4, tcif4, htif4, teif4, gif4,
608
+ dmamux => c3cr, c9cr,
609
+ ) ,
610
+ (
611
+ Stream4 , 4 ,
612
+ regs => ccr5, cpar5, cmar5, cndtr5,
613
+ fields => tcif5, htif5, teif5, gif5, tcif5, htif5, teif5, gif5,
614
+ dmamux => c4cr, c10cr,
615
+ ) ,
616
+ (
617
+ Stream5 , 5 ,
618
+ regs => ccr6, cpar6, cmar6, cndtr6,
619
+ fields => tcif6, htif6, teif6, gif6, tcif6, htif6, teif6, gif6,
620
+ dmamux => c5cr, c11cr,
557
621
) ,
558
622
) ;
0 commit comments