@@ -7,149 +7,149 @@ macro_rules! pin {
7
7
( $( $( #[ $docs: meta] ) * <$name: ident> for $( no: $NoPin: ty, ) ? [ $(
8
8
$( #[ $attr: meta] ) * $PX: ident<$A: literal $( , $Otype: ident) ?>,
9
9
) * ] , ) * ) => {
10
- $(
11
- #[ derive( Debug ) ]
12
- $( #[ $docs] ) *
13
- pub enum $name {
14
- $(
15
- None ( $NoPin) ,
16
- ) ?
17
-
18
- $(
19
- $( #[ $attr] ) *
20
- $PX( gpio:: $PX<Alternate <$A $( , $Otype) ?>>) ,
21
- ) *
22
- }
10
+ $(
11
+ #[ derive( Debug ) ]
12
+ $( #[ $docs] ) *
13
+ pub enum $name {
14
+ $(
15
+ None ( $NoPin) ,
16
+ ) ?
23
17
24
- impl crate :: Sealed for $name { }
18
+ $(
19
+ $( #[ $attr] ) *
20
+ $PX( gpio:: $PX<Alternate <$A $( , $Otype) ?>>) ,
21
+ ) *
22
+ }
25
23
26
- #[ allow( unreachable_patterns) ]
27
- impl $name {
28
- pub fn is_high( & self ) -> bool {
29
- !self . is_low( )
30
- }
31
- pub fn is_low( & self ) -> bool {
32
- match self {
33
- $(
34
- $( #[ $attr] ) *
35
- Self :: $PX( p) => p. is_low( ) ,
36
- ) *
37
- _ => false ,
38
- }
24
+ impl crate :: Sealed for $name { }
25
+
26
+ #[ allow( unreachable_patterns) ]
27
+ impl $name {
28
+ pub fn is_high( & self ) -> bool {
29
+ !self . is_low( )
30
+ }
31
+ pub fn is_low( & self ) -> bool {
32
+ match self {
33
+ $(
34
+ $( #[ $attr] ) *
35
+ Self :: $PX( p) => p. is_low( ) ,
36
+ ) *
37
+ _ => false ,
39
38
}
40
39
}
41
- #[ allow( unreachable_patterns) ]
42
- impl ExtiPin for $name {
43
- fn make_interrupt_source( & mut self , _syscfg: & mut SysCfg ) {
44
- match self {
45
- $(
46
- $( #[ $attr] ) *
47
- Self :: $PX( p) => p. make_interrupt_source( _syscfg) ,
48
- ) *
49
- _ => { } ,
50
- }
51
-
40
+ }
41
+ #[ allow( unreachable_patterns) ]
42
+ impl ExtiPin for $name {
43
+ fn make_interrupt_source( & mut self , _syscfg: & mut SysCfg ) {
44
+ match self {
45
+ $(
46
+ $( #[ $attr] ) *
47
+ Self :: $PX( p) => p. make_interrupt_source( _syscfg) ,
48
+ ) *
49
+ _ => { } ,
52
50
}
53
51
54
- fn trigger_on_edge( & mut self , _exti: & mut EXTI , _level: Edge ) {
55
- match self {
56
- $(
57
- $( #[ $attr] ) *
58
- Self :: $PX( p) => p. trigger_on_edge( _exti, _level) ,
59
- ) *
60
- _ => { } ,
61
- }
52
+ }
53
+
54
+ fn trigger_on_edge( & mut self , _exti: & mut EXTI , _level: Edge ) {
55
+ match self {
56
+ $(
57
+ $( #[ $attr] ) *
58
+ Self :: $PX( p) => p. trigger_on_edge( _exti, _level) ,
59
+ ) *
60
+ _ => { } ,
62
61
}
62
+ }
63
63
64
- fn enable_interrupt( & mut self , _exti: & mut EXTI ) {
65
- match self {
66
- $(
67
- $( #[ $attr] ) *
68
- Self :: $PX( p) => p. enable_interrupt( _exti) ,
69
- ) *
70
- _ => { } ,
71
- }
64
+ fn enable_interrupt( & mut self , _exti: & mut EXTI ) {
65
+ match self {
66
+ $(
67
+ $( #[ $attr] ) *
68
+ Self :: $PX( p) => p. enable_interrupt( _exti) ,
69
+ ) *
70
+ _ => { } ,
72
71
}
73
- fn disable_interrupt ( & mut self , _exti : & mut EXTI ) {
74
- match self {
75
- $ (
76
- $ ( # [ $attr ] ) *
77
- Self :: $PX ( p ) => p . disable_interrupt ( _exti ) ,
78
- ) *
79
- _ => { } ,
80
- }
72
+ }
73
+ fn disable_interrupt ( & mut self , _exti : & mut EXTI ) {
74
+ match self {
75
+ $ (
76
+ $ ( # [ $attr ] ) *
77
+ Self :: $PX ( p ) => p . disable_interrupt ( _exti ) ,
78
+ ) *
79
+ _ => { } ,
81
80
}
82
- fn clear_interrupt_pending_bit ( & mut self ) {
83
- match self {
84
- $ (
85
- $ ( # [ $attr ] ) *
86
- Self :: $PX ( p ) => p . clear_interrupt_pending_bit ( ) ,
87
- ) *
88
- _ => { } ,
89
- }
81
+ }
82
+ fn clear_interrupt_pending_bit ( & mut self ) {
83
+ match self {
84
+ $ (
85
+ $ ( # [ $attr ] ) *
86
+ Self :: $PX ( p ) => p . clear_interrupt_pending_bit ( ) ,
87
+ ) *
88
+ _ => { } ,
90
89
}
91
- fn check_interrupt ( & self ) -> bool {
92
- match self {
93
- $ (
94
- $ ( # [ $attr ] ) *
95
- Self :: $PX ( p ) => p . check_interrupt ( ) ,
96
- ) *
97
- _ => false ,
98
- }
90
+ }
91
+ fn check_interrupt ( & self ) -> bool {
92
+ match self {
93
+ $ (
94
+ $ ( # [ $attr ] ) *
95
+ Self :: $PX ( p ) => p . check_interrupt ( ) ,
96
+ ) *
97
+ _ => false ,
99
98
}
100
99
}
100
+ }
101
101
102
- $(
103
- impl From <$NoPin> for $name {
104
- fn from( p: $NoPin) -> Self {
105
- Self :: None ( p)
106
- }
102
+ $(
103
+ impl From <$NoPin> for $name {
104
+ fn from( p: $NoPin) -> Self {
105
+ Self :: None ( p)
107
106
}
107
+ }
108
108
109
- #[ allow( irrefutable_let_patterns) ]
110
- impl TryFrom <$name> for $NoPin {
111
- type Error = ( ) ;
109
+ #[ allow( irrefutable_let_patterns) ]
110
+ impl TryFrom <$name> for $NoPin {
111
+ type Error = ( ) ;
112
112
113
- fn try_from( a: $name) -> Result <Self , Self :: Error > {
114
- if let $name:: None ( p) = a {
115
- Ok ( p)
116
- } else {
117
- Err ( ( ) )
118
- }
113
+ fn try_from( a: $name) -> Result <Self , Self :: Error > {
114
+ if let $name:: None ( p) = a {
115
+ Ok ( p)
116
+ } else {
117
+ Err ( ( ) )
119
118
}
120
119
}
121
- ) ?
120
+ }
121
+ ) ?
122
122
123
- $(
124
- $( #[ $attr] ) *
125
- impl From <gpio:: $PX> for $name {
126
- fn from( p: gpio:: $PX) -> Self {
127
- Self :: $PX( p. into_mode( ) )
128
- }
123
+ $(
124
+ $( #[ $attr] ) *
125
+ impl From <gpio:: $PX> for $name {
126
+ fn from( p: gpio:: $PX) -> Self {
127
+ Self :: $PX( p. into_mode( ) )
129
128
}
129
+ }
130
130
131
- $( #[ $attr] ) *
132
- impl From <gpio:: $PX<Alternate <$A $( , $Otype) ?>>> for $name {
133
- fn from( p: gpio:: $PX<Alternate <$A $( , $Otype) ?>>) -> Self {
134
- Self :: $PX( p)
135
- }
131
+ $( #[ $attr] ) *
132
+ impl From <gpio:: $PX<Alternate <$A $( , $Otype) ?>>> for $name {
133
+ fn from( p: gpio:: $PX<Alternate <$A $( , $Otype) ?>>) -> Self {
134
+ Self :: $PX( p)
136
135
}
136
+ }
137
137
138
- $( #[ $attr] ) *
139
- #[ allow( irrefutable_let_patterns) ]
140
- impl <MODE : PinMode > TryFrom <$name> for gpio:: $PX<MODE > {
141
- type Error = ( ) ;
142
-
143
- fn try_from( a: $name) -> Result <Self , Self :: Error > {
144
- if let $name:: $PX( p) = a {
145
- Ok ( p. into_mode( ) )
146
- } else {
147
- Err ( ( ) )
148
- }
138
+ $( #[ $attr] ) *
139
+ #[ allow( irrefutable_let_patterns) ]
140
+ impl <MODE : PinMode > TryFrom <$name> for gpio:: $PX<MODE > {
141
+ type Error = ( ) ;
142
+
143
+ fn try_from( a: $name) -> Result <Self , Self :: Error > {
144
+ if let $name:: $PX( p) = a {
145
+ Ok ( p. into_mode( ) )
146
+ } else {
147
+ Err ( ( ) )
149
148
}
150
149
}
151
- ) *
150
+ }
152
151
) *
152
+ ) *
153
153
} ;
154
154
}
155
155
0 commit comments