@@ -663,6 +663,44 @@ where
663
663
}
664
664
}
665
665
666
+ impl < Gpio , Index , Mode > Pin < Gpio , Index , Mode >
667
+ where
668
+ Gpio : marker:: GpioStatic ,
669
+ Index : marker:: Index ,
670
+ {
671
+ /// Configures the pin to operate as an alternate function push-pull output pin
672
+ pub fn into_af_push_pull < const A : u8 > (
673
+ self ,
674
+ moder : & mut Gpio :: MODER ,
675
+ otyper : & mut Gpio :: OTYPER ,
676
+ afr : & mut <Self as marker:: IntoAf < A > >:: AFR ,
677
+ ) -> Pin < Gpio , Index , Alternate < PushPull , A > >
678
+ where
679
+ Self : marker:: IntoAf < A > ,
680
+ {
681
+ moder. alternate ( self . index . index ( ) ) ;
682
+ otyper. push_pull ( self . index . index ( ) ) ;
683
+ afr. afx ( self . index . index ( ) , A ) ;
684
+ self . into_mode ( )
685
+ }
686
+
687
+ /// Configures the pin to operate as an alternate function open-drain output pin
688
+ pub fn into_af_open_drain < const A : u8 > (
689
+ self ,
690
+ moder : & mut Gpio :: MODER ,
691
+ otyper : & mut Gpio :: OTYPER ,
692
+ afr : & mut <Self as marker:: IntoAf < A > >:: AFR ,
693
+ ) -> Pin < Gpio , Index , Alternate < OpenDrain , A > >
694
+ where
695
+ Self : marker:: IntoAf < A > ,
696
+ {
697
+ moder. alternate ( self . index . index ( ) ) ;
698
+ otyper. open_drain ( self . index . index ( ) ) ;
699
+ afr. afx ( self . index . index ( ) , A ) ;
700
+ self . into_mode ( )
701
+ }
702
+ }
703
+
666
704
macro_rules! af {
667
705
( $i: literal, $AFi: ident, $into_afi_push_pull: ident, $into_afi_open_drain: ident) => {
668
706
paste:: paste! {
@@ -683,10 +721,7 @@ macro_rules! af {
683
721
otyper: & mut Gpio :: OTYPER ,
684
722
afr: & mut <Self as marker:: IntoAf <$i>>:: AFR ,
685
723
) -> Pin <Gpio , Index , $AFi<PushPull >> {
686
- moder. alternate( self . index. index( ) ) ;
687
- otyper. push_pull( self . index. index( ) ) ;
688
- afr. afx( self . index. index( ) , $i) ;
689
- self . into_mode( )
724
+ self . into_af_push_pull:: <$i>( moder, otyper, afr)
690
725
}
691
726
692
727
/// Configures the pin to operate as an alternate function open-drain output pin
@@ -696,10 +731,7 @@ macro_rules! af {
696
731
otyper: & mut Gpio :: OTYPER ,
697
732
afr: & mut <Self as marker:: IntoAf <$i>>:: AFR ,
698
733
) -> Pin <Gpio , Index , $AFi<OpenDrain >> {
699
- moder. alternate( self . index. index( ) ) ;
700
- otyper. open_drain( self . index. index( ) ) ;
701
- afr. afx( self . index. index( ) , $i) ;
702
- self . into_mode( )
734
+ self . into_af_open_drain:: <$i>( moder, otyper, afr)
703
735
}
704
736
}
705
737
} ;
0 commit comments