@@ -159,21 +159,11 @@ pub mod marker {
159
159
/// Marker trait for active pin modes
160
160
pub trait Active { }
161
161
162
- macro_rules! af_marker_trait {
163
- ( [ $( $i: literal) ,+ $( , ) ?] ) => {
164
- paste:: paste! {
165
- $(
166
- #[ doc = "Marker trait for pins with alternate function " $i " mapping" ]
167
- pub trait [ <IntoAf $i>] {
168
- /// Associated AFR register
169
- type AFR : super :: Afr ;
170
- }
171
- ) +
172
- }
173
- } ;
162
+ /// Marker trait for pins with alternate function `A` mapping
163
+ pub trait IntoAf < const A : u8 > {
164
+ /// Associated AFR register
165
+ type AFR : super :: Afr ;
174
166
}
175
-
176
- af_marker_trait ! ( [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] ) ;
177
167
}
178
168
179
169
/// Runtime defined GPIO port (type state)
@@ -674,15 +664,15 @@ where
674
664
}
675
665
676
666
macro_rules! af {
677
- ( $i: literal, $AFi: ident, $IntoAfi : ident , $ into_afi_push_pull: ident, $into_afi_open_drain: ident) => {
667
+ ( $i: literal, $AFi: ident, $into_afi_push_pull: ident, $into_afi_open_drain: ident) => {
678
668
paste:: paste! {
679
669
#[ doc = "Alternate function " $i " (type state)" ]
680
670
pub type $AFi<Otype > = Alternate <Otype , $i>;
681
671
}
682
672
683
673
impl <Gpio , Index , Mode > Pin <Gpio , Index , Mode >
684
674
where
685
- Self : marker:: $IntoAfi ,
675
+ Self : marker:: IntoAf <$i> ,
686
676
Gpio : marker:: GpioStatic ,
687
677
Index : marker:: Index ,
688
678
{
@@ -691,7 +681,7 @@ macro_rules! af {
691
681
self ,
692
682
moder: & mut Gpio :: MODER ,
693
683
otyper: & mut Gpio :: OTYPER ,
694
- afr: & mut <Self as marker:: $IntoAfi >:: AFR ,
684
+ afr: & mut <Self as marker:: IntoAf <$i> >:: AFR ,
695
685
) -> Pin <Gpio , Index , $AFi<PushPull >> {
696
686
moder. alternate( self . index. index( ) ) ;
697
687
otyper. push_pull( self . index. index( ) ) ;
@@ -704,7 +694,7 @@ macro_rules! af {
704
694
self ,
705
695
moder: & mut Gpio :: MODER ,
706
696
otyper: & mut Gpio :: OTYPER ,
707
- afr: & mut <Self as marker:: $IntoAfi >:: AFR ,
697
+ afr: & mut <Self as marker:: IntoAf <$i> >:: AFR ,
708
698
) -> Pin <Gpio , Index , $AFi<OpenDrain >> {
709
699
moder. alternate( self . index. index( ) ) ;
710
700
otyper. open_drain( self . index. index( ) ) ;
@@ -717,7 +707,7 @@ macro_rules! af {
717
707
( [ $( $i: literal) ,+ $( , ) ?] ) => {
718
708
paste:: paste! {
719
709
$(
720
- af!( $i, [ <AF $i>] , [ < IntoAf $i> ] , [ <into_af $i _push_pull>] , [ <into_af $i _open_drain>] ) ;
710
+ af!( $i, [ <AF $i>] , [ <into_af $i _push_pull>] , [ <into_af $i _open_drain>] ) ;
721
711
) +
722
712
}
723
713
} ;
@@ -787,7 +777,7 @@ macro_rules! gpio {
787
777
partially_erased_pin: $PXx: ident,
788
778
pins: [ $(
789
779
$i: literal => (
790
- $PXi: ident, $pxi: ident, $MODE: ty, $AFR: ident, [ $( $IntoAfi : ident ) ,* ] ,
780
+ $PXi: ident, $pxi: ident, $MODE: ty, $AFR: ident, [ $( $af : literal ) ,* ] ,
791
781
) ,
792
782
) +] ,
793
783
} ) => {
@@ -825,7 +815,7 @@ macro_rules! gpio {
825
815
pub type $PXi<Mode > = Pin <$Gpiox, U <$i>, Mode >;
826
816
827
817
$(
828
- impl <Mode > marker:: $IntoAfi for $PXi<Mode > {
818
+ impl <Mode > marker:: IntoAf <$af> for $PXi<Mode > {
829
819
type AFR = $gpiox:: $AFR;
830
820
}
831
821
) *
@@ -1003,7 +993,7 @@ macro_rules! gpio {
1003
993
partially_erased_pin: [ <P $X x>] ,
1004
994
pins: [ $(
1005
995
$i => (
1006
- [ <P $X $i>] , [ <p $x $i>] , $MODE, [ <AFR $LH>] , [ $( [ < IntoAf $af> ] ) ,* ] ,
996
+ [ <P $X $i>] , [ <p $x $i>] , $MODE, [ <AFR $LH>] , [ $( $af) ,* ] ,
1007
997
) ,
1008
998
) +] ,
1009
999
} ) ;
0 commit comments