@@ -3,7 +3,7 @@ pub use f4::*;
33
44macro_rules! extipin {
55 ( $( $( #[ $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 ) {
77 match self {
88 $(
99 $( #[ $attr] ) *
@@ -14,7 +14,7 @@ macro_rules! extipin {
1414
1515 }
1616
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 ) {
1818 match self {
1919 $(
2020 $( #[ $attr] ) *
@@ -24,7 +24,7 @@ macro_rules! extipin {
2424 }
2525 }
2626
27- fn enable_interrupt( & mut self , _exti: & mut EXTI ) {
27+ fn enable_interrupt( & mut self , _exti: & mut $crate :: pac :: EXTI ) {
2828 match self {
2929 $(
3030 $( #[ $attr] ) *
@@ -33,7 +33,7 @@ macro_rules! extipin {
3333 _ => { } ,
3434 }
3535 }
36- fn disable_interrupt( & mut self , _exti: & mut EXTI ) {
36+ fn disable_interrupt( & mut self , _exti: & mut $crate :: pac :: EXTI ) {
3737 match self {
3838 $(
3939 $( #[ $attr] ) *
@@ -78,18 +78,15 @@ macro_rules! pin {
7878
7979 $(
8080 $( #[ $attr] ) *
81- $PX( gpio:: $PX<Alternate <$A, $Otype>>) ,
81+ $PX( gpio:: $PX<$crate :: gpio :: Alternate <$A, $Otype>>) ,
8282 ) *
8383 }
8484
8585 impl crate :: Sealed for $name { }
8686
8787 #[ 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 {
9390 match self {
9491 $(
9592 $( #[ $attr] ) *
@@ -99,8 +96,35 @@ macro_rules! pin {
9996 }
10097 }
10198 }
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+
102126 #[ allow( unreachable_patterns) ]
103- impl ExtiPin for $name {
127+ impl $crate :: gpio :: ExtiPin for $name {
104128 extipin! { $( $( #[ $attr] ) * $PX, ) * }
105129 }
106130
@@ -116,16 +140,16 @@ macro_rules! pin {
116140 $( #[ $attr] ) *
117141 impl <MODE > From <gpio:: $PX<MODE >> for $name
118142 where
119- MODE : marker:: NotAlt + PinMode
143+ MODE : $crate :: gpio :: marker:: NotAlt + $crate :: gpio :: PinMode
120144 {
121145 fn from( p: gpio:: $PX<MODE >) -> Self {
122146 Self :: $PX( p. into_mode( ) )
123147 }
124148 }
125149
126150 $( #[ $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 {
129153 Self :: $PX( p)
130154 }
131155 }
@@ -134,8 +158,8 @@ macro_rules! pin {
134158 #[ allow( irrefutable_let_patterns) ]
135159 impl <MODE > TryFrom <$name> for gpio:: $PX<MODE >
136160 where
137- MODE : PinMode ,
138- Alternate <$A, $Otype>: PinMode ,
161+ MODE : $crate :: gpio :: PinMode ,
162+ $crate :: gpio :: Alternate <$A, $Otype>: $crate :: gpio :: PinMode ,
139163 {
140164 type Error = ( ) ;
141165
@@ -164,18 +188,15 @@ macro_rules! pin {
164188
165189 $(
166190 $( #[ $attr] ) *
167- $PX( gpio:: $PX<Alternate <$A, Otype >>) ,
191+ $PX( gpio:: $PX<$crate :: gpio :: Alternate <$A, Otype >>) ,
168192 ) *
169193 }
170194
171195 impl <Otype > crate :: Sealed for $name<Otype > { }
172196
173197 #[ 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 {
179200 match self {
180201 $(
181202 $( #[ $attr] ) *
@@ -185,8 +206,35 @@ macro_rules! pin {
185206 }
186207 }
187208 }
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+
188236 #[ allow( unreachable_patterns) ]
189- impl <Otype > ExtiPin for $name<Otype > {
237+ impl <Otype > $crate :: gpio :: ExtiPin for $name<Otype > {
190238 extipin! { $( $( #[ $attr] ) * $PX, ) * }
191239 }
192240
@@ -202,17 +250,17 @@ macro_rules! pin {
202250 $( #[ $attr] ) *
203251 impl <MODE , Otype > From <gpio:: $PX<MODE >> for $name<Otype >
204252 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 ,
207255 {
208256 fn from( p: gpio:: $PX<MODE >) -> Self {
209257 Self :: $PX( p. into_mode( ) )
210258 }
211259 }
212260
213261 $( #[ $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 {
216264 Self :: $PX( p)
217265 }
218266 }
@@ -221,8 +269,8 @@ macro_rules! pin {
221269 #[ allow( irrefutable_let_patterns) ]
222270 impl <MODE , Otype > TryFrom <$name<Otype >> for gpio:: $PX<MODE >
223271 where
224- MODE : PinMode ,
225- Alternate <$A, Otype >: PinMode ,
272+ MODE : $crate :: gpio :: PinMode ,
273+ $crate :: gpio :: Alternate <$A, Otype >: $crate :: gpio :: PinMode ,
226274 {
227275 type Error = ( ) ;
228276
@@ -302,7 +350,7 @@ pub trait I2cCommon {
302350pub trait I2sCommon {
303351 type Ck ;
304352 type Sd ;
305- type Ws ;
353+ type Ws : crate :: gpio :: ReadPin + crate :: gpio :: ExtiPin ;
306354}
307355pub trait I2sMaster {
308356 type Mck ;
0 commit comments