@@ -587,161 +587,78 @@ where
587
587
}
588
588
}
589
589
590
- // Macro that creates a struct representing a stream on either BDMA controller
590
+ // A struct representing a stream on either BDMA controller
591
591
//
592
592
// The implementation does the heavy lifting of mapping to the right fields on
593
593
// the stream
594
- macro_rules! bdma_stream {
595
- ( $( ( $name: ident, $number: expr,
596
- $ifcr: ident, $tcif: ident, $htif: ident, $teif: ident, $gif: ident,
597
- $isr: ident, $tcisr: ident, $htisr: ident, $teisr: ident, $gisr: ident)
598
- ) ,+$( , ) * ) => {
599
- $(
600
- impl <I : Instance > InstanceStream for StreamX <I , $number> {
601
- #[ inline( always) ]
602
- fn stream_clear_interrupts( & mut self ) {
603
- //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
604
- // that belongs to the StreamX
605
- let dma = unsafe { & * I :: ptr( ) } ;
606
- dma. $ifcr( ) . write( |w| w
607
- . $tcif( ) . set_bit( ) //Clear transfer complete interrupt flag
608
- . $htif( ) . set_bit( ) //Clear half transfer interrupt flag
609
- . $teif( ) . set_bit( ) //Clear transfer error interrupt flag
610
- . $gif( ) . set_bit( ) //Clear global interrupt flag
611
- ) ;
612
- let _ = dma. $isr( ) . read( ) ;
613
- let _ = dma. $isr( ) . read( ) ; // Delay 2 peripheral clocks
614
- }
594
+ impl < I : Instance , const S : u8 > InstanceStream for StreamX < I , S > {
595
+ #[ inline( always) ]
596
+ fn stream_clear_interrupts ( & mut self ) {
597
+ //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
598
+ // that belongs to the StreamX
599
+ let dma = unsafe { & * I :: ptr ( ) } ;
600
+ dma. ifcr ( ) . write ( |w| w
601
+ . ctcif ( S ) . set_bit ( ) //Clear transfer complete interrupt flag
602
+ . chtif ( S ) . set_bit ( ) //Clear half transfer interrupt flag
603
+ . cteif ( S ) . set_bit ( ) //Clear transfer error interrupt flag
604
+ . cgif ( S ) . set_bit ( ) //Clear global interrupt flag
605
+ ) ;
606
+ let _ = dma. isr ( ) . read ( ) ;
607
+ let _ = dma. isr ( ) . read ( ) ; // Delay 2 peripheral clocks
608
+ }
615
609
616
- #[ inline( always) ]
617
- fn stream_clear_transfer_complete_flag( & mut self ) {
618
- //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
619
- // that belongs to the StreamX
620
- let dma = unsafe { & * I :: ptr( ) } ;
621
- dma. $ ifcr( ) . write( |w| w. $tcif ( ) . set_bit( ) ) ;
622
- }
610
+ #[ inline( always) ]
611
+ fn stream_clear_transfer_complete_flag ( & mut self ) {
612
+ //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
613
+ // that belongs to the StreamX
614
+ let dma = unsafe { & * I :: ptr ( ) } ;
615
+ dma. ifcr ( ) . write ( |w| w. ctcif ( S ) . set_bit ( ) ) ;
616
+ }
623
617
624
- #[ inline( always) ]
625
- fn stream_clear_transfer_complete_interrupt( & mut self ) {
626
- self . stream_clear_transfer_complete_flag( ) ;
627
- //NOTE(unsafe) Atomic read with no side-effects.
628
- let dma = unsafe { & * I :: ptr( ) } ;
629
- let _ = dma. $ isr( ) . read( ) ;
630
- let _ = dma. $ isr( ) . read( ) ; // Delay 2 peripheral clocks
631
- }
618
+ #[ inline( always) ]
619
+ fn stream_clear_transfer_complete_interrupt ( & mut self ) {
620
+ self . stream_clear_transfer_complete_flag ( ) ;
621
+ //NOTE(unsafe) Atomic read with no side-effects.
622
+ let dma = unsafe { & * I :: ptr ( ) } ;
623
+ let _ = dma. isr ( ) . read ( ) ;
624
+ let _ = dma. isr ( ) . read ( ) ; // Delay 2 peripheral clocks
625
+ }
632
626
633
- #[ inline( always) ]
634
- fn stream_clear_transfer_error_interrupt( & mut self ) {
635
- //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
636
- // that belongs to the StreamX
637
- let dma = unsafe { & * I :: ptr( ) } ;
638
- dma. $ ifcr( ) . write( |w| w. $teif ( ) . set_bit( ) ) ;
639
- let _ = dma. $ isr( ) . read( ) ;
640
- let _ = dma. $ isr( ) . read( ) ; // Delay 2 peripheral clocks
641
- }
627
+ #[ inline( always) ]
628
+ fn stream_clear_transfer_error_interrupt ( & mut self ) {
629
+ //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
630
+ // that belongs to the StreamX
631
+ let dma = unsafe { & * I :: ptr ( ) } ;
632
+ dma. ifcr ( ) . write ( |w| w. cteif ( S ) . set_bit ( ) ) ;
633
+ let _ = dma. isr ( ) . read ( ) ;
634
+ let _ = dma. isr ( ) . read ( ) ; // Delay 2 peripheral clocks
635
+ }
642
636
643
- #[ inline( always) ]
644
- fn stream_get_transfer_complete_flag( ) -> bool {
645
- //NOTE(unsafe) Atomic read with no side effects
646
- let dma = unsafe { & * I :: ptr( ) } ;
647
- dma. $ isr( ) . read( ) . $tcisr ( ) . bit_is_set( )
648
- }
637
+ #[ inline( always) ]
638
+ fn stream_get_transfer_complete_flag ( ) -> bool {
639
+ //NOTE(unsafe) Atomic read with no side effects
640
+ let dma = unsafe { & * I :: ptr ( ) } ;
641
+ dma. isr ( ) . read ( ) . tcif ( S ) . bit_is_set ( )
642
+ }
649
643
650
- #[ inline( always) ]
651
- fn stream_get_half_transfer_flag( ) -> bool {
652
- //NOTE(unsafe) Atomic read with no side effects
653
- let dma = unsafe { & * I :: ptr( ) } ;
654
- dma. $ isr( ) . read( ) . $htisr ( ) . bit_is_set( )
655
- }
644
+ #[ inline( always) ]
645
+ fn stream_get_half_transfer_flag ( ) -> bool {
646
+ //NOTE(unsafe) Atomic read with no side effects
647
+ let dma = unsafe { & * I :: ptr ( ) } ;
648
+ dma. isr ( ) . read ( ) . htif ( S ) . bit_is_set ( )
649
+ }
656
650
657
- #[ inline( always) ]
658
- fn stream_clear_half_transfer_interrupt( & mut self ) {
659
- //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
660
- // that belongs to the StreamX
661
- let dma = unsafe { & * I :: ptr( ) } ;
662
- dma. $ifcr( ) . write( |w| w. $htif( ) . set_bit( ) ) ;
663
- let _ = dma. $isr( ) . read( ) ;
664
- let _ = dma. $isr( ) . read( ) ; // Delay 2 peripheral clocks
665
- }
666
- }
667
- ) +
668
- } ;
651
+ #[ inline( always) ]
652
+ fn stream_clear_half_transfer_interrupt ( & mut self ) {
653
+ //NOTE(unsafe) Atomic write with no side-effects and we only access the bits
654
+ // that belongs to the StreamX
655
+ let dma = unsafe { & * I :: ptr ( ) } ;
656
+ dma. ifcr ( ) . write ( |w| w. chtif ( S ) . set_bit ( ) ) ;
657
+ let _ = dma. isr ( ) . read ( ) ;
658
+ let _ = dma. isr ( ) . read ( ) ; // Delay 2 peripheral clocks
659
+ }
669
660
}
670
661
671
- #[ cfg( not( feature = "rm0468" ) ) ]
672
- bdma_stream ! (
673
- // Note: the field names start from one, unlike the RM where they start from
674
- // zero. May need updating if it gets fixed upstream.
675
- (
676
- Stream0 , 0 , ifcr, ctcif1, chtif1, cteif1, cgif1, isr, tcif1, htif1,
677
- teif1, gif1
678
- ) ,
679
- (
680
- Stream1 , 1 , ifcr, ctcif2, chtif2, cteif2, cgif2, isr, tcif2, htif2,
681
- teif2, gif2
682
- ) ,
683
- (
684
- Stream2 , 2 , ifcr, ctcif3, chtif3, cteif3, cgif3, isr, tcif3, htif3,
685
- teif3, gif3
686
- ) ,
687
- (
688
- Stream3 , 3 , ifcr, ctcif4, chtif4, cteif4, cgif4, isr, tcif4, htif4,
689
- teif4, gif4
690
- ) ,
691
- (
692
- Stream4 , 4 , ifcr, ctcif5, chtif5, cteif5, cgif5, isr, tcif5, htif5,
693
- teif5, gif5
694
- ) ,
695
- (
696
- Stream5 , 5 , ifcr, ctcif6, chtif6, cteif6, cgif6, isr, tcif6, htif6,
697
- teif6, gif6
698
- ) ,
699
- (
700
- Stream6 , 6 , ifcr, ctcif7, chtif7, cteif7, cgif7, isr, tcif7, htif7,
701
- teif7, gif7
702
- ) ,
703
- (
704
- Stream7 , 7 , ifcr, ctcif8, chtif8, cteif8, cgif8, isr, tcif8, htif8,
705
- teif8, gif8
706
- ) ,
707
- ) ;
708
- #[ cfg( feature = "rm0468" ) ]
709
- bdma_stream ! (
710
- // For this sub-familiy, the field names do match the RM.
711
- (
712
- Stream0 , 0 , ifcr, ctcif0, chtif0, cteif0, cgif0, isr, tcif0, htif0,
713
- teif0, gif0
714
- ) ,
715
- (
716
- Stream1 , 1 , ifcr, ctcif1, chtif1, cteif1, cgif1, isr, tcif1, htif1,
717
- teif1, gif1
718
- ) ,
719
- (
720
- Stream2 , 2 , ifcr, ctcif2, chtif2, cteif2, cgif2, isr, tcif2, htif2,
721
- teif2, gif2
722
- ) ,
723
- (
724
- Stream3 , 3 , ifcr, ctcif3, chtif3, cteif3, cgif3, isr, tcif3, htif3,
725
- teif3, gif3
726
- ) ,
727
- (
728
- Stream4 , 4 , ifcr, ctcif4, chtif4, cteif4, cgif4, isr, tcif4, htif4,
729
- teif4, gif4
730
- ) ,
731
- (
732
- Stream5 , 5 , ifcr, ctcif5, chtif5, cteif5, cgif5, isr, tcif5, htif5,
733
- teif5, gif5
734
- ) ,
735
- (
736
- Stream6 , 6 , ifcr, ctcif6, chtif6, cteif6, cgif6, isr, tcif6, htif6,
737
- teif6, gif6
738
- ) ,
739
- (
740
- Stream7 , 7 , ifcr, ctcif7, chtif7, cteif7, cgif7, isr, tcif7, htif7,
741
- teif7, gif7
742
- ) ,
743
- ) ;
744
-
745
662
/// Type alias for the DMA Request Multiplexer
746
663
///
747
664
pub type DMAReq = pac:: dmamux2:: ccr:: DMAREQ_ID ;
0 commit comments