@@ -27,33 +27,35 @@ impl<TIM, PIN: TimerPin<TIM>> TriggerPin<TIM, PIN> {
27
27
}
28
28
}
29
29
30
- macro_rules! timer_pins {
31
- ( $TIMX: ident, [ $ ( ( $ ch: ty, $pin: tt, $af_mode: expr) , ) + ] ) => {
30
+ macro_rules! timer_pin_impl {
31
+ ( $TIMX: ident, $ ch: ty, $pin: tt, $af_mode: expr, [ $ ( ( $mode : ty , $release : ident ) , ) +] ) => {
32
32
$(
33
- impl TimerPin <$TIMX> for $pin<Analog > {
34
- type Channel = $ch;
35
-
36
- fn setup( & self ) {
37
- self . set_alt_mode( $af_mode) ;
38
- }
39
-
40
- fn release( self ) -> Self {
41
- self . into_analog( )
42
- }
43
- }
44
-
45
- impl TimerPin <$TIMX> for $pin<Output <OpenDrain >> {
33
+ impl TimerPin <$TIMX> for $pin<$mode> {
46
34
type Channel = $ch;
47
35
48
36
fn setup( & self ) {
49
37
self . set_alt_mode( $af_mode) ;
50
38
}
51
39
52
40
fn release( self ) -> Self {
53
- self . into_open_drain_output ( )
41
+ self . $release ( )
54
42
}
55
43
}
44
+ ) +
45
+ } ;
46
+ }
56
47
48
+ macro_rules! timer_pins {
49
+ ( $TIMX: ident, [ $( ( $ch: ty, $pin: tt, $af_mode: expr) , ) + ] ) => {
50
+ $(
51
+ timer_pin_impl!( $TIMX, $ch, $pin, $af_mode, [
52
+ ( Analog , into_analog) ,
53
+ ( Output <OpenDrain >, into_open_drain_output) ,
54
+ ( Output <PushPull >, into_push_pull_output) ,
55
+ ( Input <Floating >, into_floating_input) ,
56
+ ( Input <PullUp >, into_pull_up_input) ,
57
+ ( Input <PullDown >, into_pull_down_input) ,
58
+ ] ) ;
57
59
) +
58
60
} ;
59
61
}
0 commit comments