@@ -161,6 +161,22 @@ pub mod marker {
161
161
162
162
/// Marker trait for active pin modes
163
163
pub trait Active { }
164
+
165
+ macro_rules! af_marker_trait {
166
+ ( [ $( $i: literal) ,+ $( , ) ?] ) => {
167
+ paste:: paste! {
168
+ $(
169
+ #[ doc = "Marker trait for pins with alternate function " $i " mapping" ]
170
+ pub trait [ <IntoAf $i>] {
171
+ /// Associated AFR register
172
+ type AFR : super :: Afr ;
173
+ }
174
+ ) +
175
+ }
176
+ } ;
177
+ }
178
+
179
+ af_marker_trait ! ( [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] ) ;
164
180
}
165
181
166
182
/// Runtime defined GPIO port (type state)
@@ -618,22 +634,14 @@ where
618
634
619
635
macro_rules! af {
620
636
( $i: literal, $Ui: ty, $AFi: ident, $IntoAfi: ident, $into_afi_push_pull: ident, $into_afi_open_drain: ident) => {
621
- paste:: paste! {
622
- #[ doc = "Marker trait for pins with alternate function " $i " mapping" ]
623
- pub trait $IntoAfi {
624
- /// Associated AFR register
625
- type AFR : Afr ;
626
- }
627
- }
628
-
629
637
paste:: paste! {
630
638
#[ doc = "Alternate function " $i " (type state)" ]
631
639
pub type $AFi<Otype > = Alternate <$Ui, Otype >;
632
640
}
633
641
634
642
impl <Gpio , Index , Mode > Pin <Gpio , Index , Mode >
635
643
where
636
- Self : $IntoAfi,
644
+ Self : marker :: $IntoAfi,
637
645
Gpio : marker:: GpioStatic ,
638
646
Index : marker:: Index ,
639
647
{
@@ -642,7 +650,7 @@ macro_rules! af {
642
650
self ,
643
651
moder: & mut Gpio :: MODER ,
644
652
otyper: & mut Gpio :: OTYPER ,
645
- afr: & mut <Self as $IntoAfi>:: AFR ,
653
+ afr: & mut <Self as marker :: $IntoAfi>:: AFR ,
646
654
) -> Pin <Gpio , Index , $AFi<PushPull >> {
647
655
moder. alternate( self . index. index( ) ) ;
648
656
otyper. push_pull( self . index. index( ) ) ;
@@ -655,7 +663,7 @@ macro_rules! af {
655
663
self ,
656
664
moder: & mut Gpio :: MODER ,
657
665
otyper: & mut Gpio :: OTYPER ,
658
- afr: & mut <Self as $IntoAfi>:: AFR ,
666
+ afr: & mut <Self as marker :: $IntoAfi>:: AFR ,
659
667
) -> Pin <Gpio , Index , $AFi<OpenDrain >> {
660
668
moder. alternate( self . index. index( ) ) ;
661
669
otyper. open_drain( self . index. index( ) ) ;
@@ -706,6 +714,7 @@ macro_rules! gpio_trait {
706
714
} ;
707
715
}
708
716
717
+ /// Implement private::{Moder, Ospeedr, Otyper, Pupdr} traits for each opaque register structs
709
718
macro_rules! r_trait {
710
719
(
711
720
( $GPIOX: ident, $gpioy: ident:: $xr: ident:: $enum: ident, $bitwidth: expr) ;
@@ -781,13 +790,11 @@ macro_rules! gpio {
781
790
rcc:: AHB ,
782
791
} ;
783
792
784
- use super :: { Afr , $Gpiox, GpioExt , Moder , Ospeedr , Otyper , Pin , Pupdr , Ux } ;
793
+ use super :: { marker , Afr , $Gpiox, GpioExt , Moder , Ospeedr , Otyper , Pin , Pupdr , Ux } ;
785
794
786
795
#[ allow( unused_imports) ]
787
796
use super :: {
788
797
Input , Output , Analog , PushPull , OpenDrain ,
789
- IntoAf0 , IntoAf1 , IntoAf2 , IntoAf3 , IntoAf4 , IntoAf5 , IntoAf6 , IntoAf7 ,
790
- IntoAf8 , IntoAf9 , IntoAf10 , IntoAf11 , IntoAf12 , IntoAf13 , IntoAf14 , IntoAf15 ,
791
798
AF0 , AF1 , AF2 , AF3 , AF4 , AF5 , AF6 , AF7 , AF8 , AF9 , AF10 , AF11 , AF12 , AF13 , AF14 , AF15 ,
792
799
} ;
793
800
@@ -920,7 +927,7 @@ macro_rules! gpio {
920
927
pub type $PXi<Mode > = Pin <$Gpiox, $Ui, Mode >;
921
928
922
929
$(
923
- impl <Mode > $IntoAfi for $PXi<Mode > {
930
+ impl <Mode > marker :: $IntoAfi for $PXi<Mode > {
924
931
type AFR = $AFR;
925
932
}
926
933
) *
0 commit comments