@@ -3,7 +3,7 @@ pub use f4::*;
3
3
4
4
macro_rules! extipin {
5
5
( $( $( #[ $attr: meta] ) * $PX: ident, ) * ) => {
6
- fn make_interrupt_source( & mut self , _syscfg: & mut SysCfg ) {
6
+ fn make_interrupt_source( & mut self , _syscfg: & mut $crate :: syscfg :: SysCfg ) {
7
7
match self {
8
8
$(
9
9
$( #[ $attr] ) *
@@ -14,7 +14,7 @@ macro_rules! extipin {
14
14
15
15
}
16
16
17
- fn trigger_on_edge( & mut self , _exti: & mut EXTI , _level: Edge ) {
17
+ fn trigger_on_edge( & mut self , _exti: & mut $crate :: pac :: EXTI , _level: $crate :: gpio :: Edge ) {
18
18
match self {
19
19
$(
20
20
$( #[ $attr] ) *
@@ -24,7 +24,7 @@ macro_rules! extipin {
24
24
}
25
25
}
26
26
27
- fn enable_interrupt( & mut self , _exti: & mut EXTI ) {
27
+ fn enable_interrupt( & mut self , _exti: & mut $crate :: pac :: EXTI ) {
28
28
match self {
29
29
$(
30
30
$( #[ $attr] ) *
@@ -33,7 +33,7 @@ macro_rules! extipin {
33
33
_ => { } ,
34
34
}
35
35
}
36
- fn disable_interrupt( & mut self , _exti: & mut EXTI ) {
36
+ fn disable_interrupt( & mut self , _exti: & mut $crate :: pac :: EXTI ) {
37
37
match self {
38
38
$(
39
39
$( #[ $attr] ) *
@@ -78,18 +78,15 @@ macro_rules! pin {
78
78
79
79
$(
80
80
$( #[ $attr] ) *
81
- $PX( gpio:: $PX<Alternate <$A, $Otype>>) ,
81
+ $PX( gpio:: $PX<$crate :: gpio :: Alternate <$A, $Otype>>) ,
82
82
) *
83
83
}
84
84
85
85
impl crate :: Sealed for $name { }
86
86
87
87
#[ allow( unreachable_patterns) ]
88
- impl $name {
89
- pub fn is_high( & self ) -> bool {
90
- !self . is_low( )
91
- }
92
- pub fn is_low( & self ) -> bool {
88
+ impl $crate:: gpio:: ReadPin for $name {
89
+ fn is_low( & self ) -> bool {
93
90
match self {
94
91
$(
95
92
$( #[ $attr] ) *
@@ -99,8 +96,35 @@ macro_rules! pin {
99
96
}
100
97
}
101
98
}
99
+
100
+ #[ allow( unreachable_patterns) ]
101
+ impl $crate:: gpio:: PinSpeed for $name {
102
+ fn set_speed( & mut self , _speed: $crate:: gpio:: Speed ) {
103
+ match self {
104
+ $(
105
+ $( #[ $attr] ) *
106
+ Self :: $PX( p) => p. set_speed( _speed) ,
107
+ ) *
108
+ _ => { }
109
+ }
110
+ }
111
+ }
112
+
113
+ #[ allow( unreachable_patterns) ]
114
+ impl $crate:: gpio:: PinPull for $name {
115
+ fn set_internal_resistor( & mut self , _pull: $crate:: gpio:: Pull ) {
116
+ match self {
117
+ $(
118
+ $( #[ $attr] ) *
119
+ Self :: $PX( p) => p. set_internal_resistor( _pull) ,
120
+ ) *
121
+ _ => { }
122
+ }
123
+ }
124
+ }
125
+
102
126
#[ allow( unreachable_patterns) ]
103
- impl ExtiPin for $name {
127
+ impl $crate :: gpio :: ExtiPin for $name {
104
128
extipin! { $( $( #[ $attr] ) * $PX, ) * }
105
129
}
106
130
@@ -116,16 +140,16 @@ macro_rules! pin {
116
140
$( #[ $attr] ) *
117
141
impl <MODE > From <gpio:: $PX<MODE >> for $name
118
142
where
119
- MODE : marker:: NotAlt + PinMode
143
+ MODE : $crate :: gpio :: marker:: NotAlt + $crate :: gpio :: PinMode
120
144
{
121
145
fn from( p: gpio:: $PX<MODE >) -> Self {
122
146
Self :: $PX( p. into_mode( ) )
123
147
}
124
148
}
125
149
126
150
$( #[ $attr] ) *
127
- impl From <gpio:: $PX<Alternate <$A, $Otype>>> for $name {
128
- fn from( p: gpio:: $PX<Alternate <$A, $Otype>>) -> Self {
151
+ impl From <gpio:: $PX<$crate :: gpio :: Alternate <$A, $Otype>>> for $name {
152
+ fn from( p: gpio:: $PX<$crate :: gpio :: Alternate <$A, $Otype>>) -> Self {
129
153
Self :: $PX( p)
130
154
}
131
155
}
@@ -134,8 +158,8 @@ macro_rules! pin {
134
158
#[ allow( irrefutable_let_patterns) ]
135
159
impl <MODE > TryFrom <$name> for gpio:: $PX<MODE >
136
160
where
137
- MODE : PinMode ,
138
- Alternate <$A, $Otype>: PinMode ,
161
+ MODE : $crate :: gpio :: PinMode ,
162
+ $crate :: gpio :: Alternate <$A, $Otype>: $crate :: gpio :: PinMode ,
139
163
{
140
164
type Error = ( ) ;
141
165
@@ -164,18 +188,15 @@ macro_rules! pin {
164
188
165
189
$(
166
190
$( #[ $attr] ) *
167
- $PX( gpio:: $PX<Alternate <$A, Otype >>) ,
191
+ $PX( gpio:: $PX<$crate :: gpio :: Alternate <$A, Otype >>) ,
168
192
) *
169
193
}
170
194
171
195
impl <Otype > crate :: Sealed for $name<Otype > { }
172
196
173
197
#[ allow( unreachable_patterns) ]
174
- impl <Otype > $name<Otype > {
175
- pub fn is_high( & self ) -> bool {
176
- !self . is_low( )
177
- }
178
- pub fn is_low( & self ) -> bool {
198
+ impl <Otype > $crate:: gpio:: ReadPin for $name<Otype > {
199
+ fn is_low( & self ) -> bool {
179
200
match self {
180
201
$(
181
202
$( #[ $attr] ) *
@@ -185,8 +206,35 @@ macro_rules! pin {
185
206
}
186
207
}
187
208
}
209
+
210
+ #[ allow( unreachable_patterns) ]
211
+ impl <Otype > $crate:: gpio:: PinSpeed for $name<Otype > {
212
+ fn set_speed( & mut self , _speed: $crate:: gpio:: Speed ) {
213
+ match self {
214
+ $(
215
+ $( #[ $attr] ) *
216
+ Self :: $PX( p) => p. set_speed( _speed) ,
217
+ ) *
218
+ _ => { }
219
+ }
220
+ }
221
+ }
222
+
223
+ #[ allow( unreachable_patterns) ]
224
+ impl <Otype > $crate:: gpio:: PinPull for $name<Otype > {
225
+ fn set_internal_resistor( & mut self , _pull: $crate:: gpio:: Pull ) {
226
+ match self {
227
+ $(
228
+ $( #[ $attr] ) *
229
+ Self :: $PX( p) => p. set_internal_resistor( _pull) ,
230
+ ) *
231
+ _ => { }
232
+ }
233
+ }
234
+ }
235
+
188
236
#[ allow( unreachable_patterns) ]
189
- impl <Otype > ExtiPin for $name<Otype > {
237
+ impl <Otype > $crate :: gpio :: ExtiPin for $name<Otype > {
190
238
extipin! { $( $( #[ $attr] ) * $PX, ) * }
191
239
}
192
240
@@ -202,17 +250,17 @@ macro_rules! pin {
202
250
$( #[ $attr] ) *
203
251
impl <MODE , Otype > From <gpio:: $PX<MODE >> for $name<Otype >
204
252
where
205
- MODE : marker:: NotAlt + PinMode ,
206
- Alternate <$A, Otype >: PinMode ,
253
+ MODE : $crate :: gpio :: marker:: NotAlt + $crate :: gpio :: PinMode ,
254
+ $crate :: gpio :: Alternate <$A, Otype >: $crate :: gpio :: PinMode ,
207
255
{
208
256
fn from( p: gpio:: $PX<MODE >) -> Self {
209
257
Self :: $PX( p. into_mode( ) )
210
258
}
211
259
}
212
260
213
261
$( #[ $attr] ) *
214
- impl <Otype > From <gpio:: $PX<Alternate <$A, Otype >>> for $name<Otype > {
215
- fn from( p: gpio:: $PX<Alternate <$A, Otype >>) -> Self {
262
+ impl <Otype > From <gpio:: $PX<$crate :: gpio :: Alternate <$A, Otype >>> for $name<Otype > {
263
+ fn from( p: gpio:: $PX<$crate :: gpio :: Alternate <$A, Otype >>) -> Self {
216
264
Self :: $PX( p)
217
265
}
218
266
}
@@ -221,8 +269,8 @@ macro_rules! pin {
221
269
#[ allow( irrefutable_let_patterns) ]
222
270
impl <MODE , Otype > TryFrom <$name<Otype >> for gpio:: $PX<MODE >
223
271
where
224
- MODE : PinMode ,
225
- Alternate <$A, Otype >: PinMode ,
272
+ MODE : $crate :: gpio :: PinMode ,
273
+ $crate :: gpio :: Alternate <$A, Otype >: $crate :: gpio :: PinMode ,
226
274
{
227
275
type Error = ( ) ;
228
276
@@ -302,7 +350,7 @@ pub trait I2cCommon {
302
350
pub trait I2sCommon {
303
351
type Ck ;
304
352
type Sd ;
305
- type Ws ;
353
+ type Ws : crate :: gpio :: ReadPin + crate :: gpio :: ExtiPin ;
306
354
}
307
355
pub trait I2sMaster {
308
356
type Mck ;
0 commit comments