@@ -99,7 +99,7 @@ pub trait PinExt {
99
99
}
100
100
101
101
/// Some alternate mode (type state)
102
- pub struct Alternate < Otype , const A : u8 > ( PhantomData < Otype > ) ;
102
+ pub struct Alternate < const A : u8 , Otype > ( PhantomData < Otype > ) ;
103
103
104
104
/// Input mode (type state)
105
105
pub struct Input < MODE > {
@@ -129,7 +129,7 @@ pub struct PushPull;
129
129
/// Analog mode (type state)
130
130
pub struct Analog ;
131
131
132
- pub type Debugger = Alternate < PushPull , 0 > ;
132
+ pub type Debugger = Alternate < 0 , PushPull > ;
133
133
134
134
/// GPIO Pin speed selection
135
135
#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
@@ -262,16 +262,16 @@ where
262
262
/// - `MODE` is one of the pin modes (see [Modes](crate::gpio#modes) section).
263
263
/// - `P` is port name: `A` for GPIOA, `B` for GPIOB, etc.
264
264
/// - `N` is pin number: from `0` to `15`.
265
- pub struct Pin < MODE , const P : char , const N : u8 > {
265
+ pub struct Pin < const P : char , const N : u8 , MODE > {
266
266
_mode : PhantomData < MODE > ,
267
267
}
268
- impl < MODE , const P : char , const N : u8 > Pin < MODE , P , N > {
268
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , MODE > {
269
269
const fn new ( ) -> Self {
270
270
Self { _mode : PhantomData }
271
271
}
272
272
}
273
273
274
- impl < MODE , const P : char , const N : u8 > fmt:: Debug for Pin < MODE , P , N > {
274
+ impl < const P : char , const N : u8 , MODE > fmt:: Debug for Pin < P , N , MODE > {
275
275
fn fmt ( & self , formatter : & mut fmt:: Formatter ) -> fmt:: Result {
276
276
formatter. write_fmt ( format_args ! (
277
277
"P{}{}<{}>" ,
@@ -283,13 +283,13 @@ impl<MODE, const P: char, const N: u8> fmt::Debug for Pin<MODE, P, N> {
283
283
}
284
284
285
285
#[ cfg( feature = "defmt" ) ]
286
- impl < MODE , const P : char , const N : u8 > defmt:: Format for Pin < MODE , P , N > {
286
+ impl < const P : char , const N : u8 , MODE > defmt:: Format for Pin < P , N , MODE > {
287
287
fn format ( & self , f : defmt:: Formatter ) {
288
288
defmt:: write!( f, "P{}{}<{}>" , P , N , crate :: stripped_type_name:: <MODE >( ) ) ;
289
289
}
290
290
}
291
291
292
- impl < MODE , const P : char , const N : u8 > PinExt for Pin < MODE , P , N > {
292
+ impl < const P : char , const N : u8 , MODE > PinExt for Pin < P , N , MODE > {
293
293
type Mode = MODE ;
294
294
295
295
#[ inline( always) ]
@@ -302,7 +302,7 @@ impl<MODE, const P: char, const N: u8> PinExt for Pin<MODE, P, N> {
302
302
}
303
303
}
304
304
305
- impl < MODE , const P : char , const N : u8 > Pin < Output < MODE > , P , N > {
305
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , Output < MODE > > {
306
306
/// Set pin speed
307
307
pub fn set_speed ( self , speed : Speed ) -> Self {
308
308
let offset = 2 * { N } ;
@@ -317,7 +317,7 @@ impl<MODE, const P: char, const N: u8> Pin<Output<MODE>, P, N> {
317
317
}
318
318
}
319
319
320
- impl < const P : char , const N : u8 > Pin < Output < OpenDrain > , P , N > {
320
+ impl < const P : char , const N : u8 > Pin < P , N , Output < OpenDrain > > {
321
321
/// Enables / disables the internal pull up
322
322
pub fn internal_pull_up ( self , on : bool ) -> Self {
323
323
let offset = 2 * { N } ;
@@ -345,7 +345,7 @@ impl<const P: char, const N: u8> Pin<Output<OpenDrain>, P, N> {
345
345
}
346
346
}
347
347
348
- impl < const P : char , const N : u8 , const A : u8 > Pin < Alternate < PushPull , A > , P , N > {
348
+ impl < const P : char , const N : u8 , const A : u8 > Pin < P , N , Alternate < A , PushPull > > {
349
349
/// Set pin speed
350
350
pub fn set_speed ( self , speed : Speed ) -> Self {
351
351
let offset = 2 * { N } ;
@@ -386,9 +386,9 @@ impl<const P: char, const N: u8, const A: u8> Pin<Alternate<PushPull, A>, P, N>
386
386
}
387
387
}
388
388
389
- impl < const P : char , const N : u8 , const A : u8 > Pin < Alternate < PushPull , A > , P , N > {
389
+ impl < const P : char , const N : u8 , const A : u8 > Pin < P , N , Alternate < A , PushPull > > {
390
390
/// Turns pin alternate configuration pin into open drain
391
- pub fn set_open_drain ( self ) -> Pin < Alternate < OpenDrain , A > , P , N > {
391
+ pub fn set_open_drain ( self ) -> Pin < P , N , Alternate < A , OpenDrain > > {
392
392
let offset = { N } ;
393
393
unsafe {
394
394
( * Gpio :: < P > :: ptr ( ) )
@@ -400,12 +400,12 @@ impl<const P: char, const N: u8, const A: u8> Pin<Alternate<PushPull, A>, P, N>
400
400
}
401
401
}
402
402
403
- impl < MODE , const P : char , const N : u8 > Pin < MODE , P , N > {
403
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , MODE > {
404
404
/// Erases the pin number from the type
405
405
///
406
406
/// This is useful when you want to collect the pins into an array where you
407
407
/// need all the elements to have the same type
408
- pub fn erase_number ( self ) -> PEPin < MODE , P > {
408
+ pub fn erase_number ( self ) -> PEPin < P , MODE > {
409
409
PEPin :: new ( N )
410
410
}
411
411
@@ -418,7 +418,7 @@ impl<MODE, const P: char, const N: u8> Pin<MODE, P, N> {
418
418
}
419
419
}
420
420
421
- impl < MODE , const P : char , const N : u8 > Pin < MODE , P , N > {
421
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , MODE > {
422
422
/// Set the output of the pin regardless of its mode.
423
423
/// Primarily used to set the output value of the pin
424
424
/// before changing its mode to an output to avoid
@@ -452,7 +452,7 @@ impl<MODE, const P: char, const N: u8> Pin<MODE, P, N> {
452
452
}
453
453
}
454
454
455
- impl < MODE , const P : char , const N : u8 > Pin < Output < MODE > , P , N > {
455
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , Output < MODE > > {
456
456
#[ inline( always) ]
457
457
pub fn set_high ( & mut self ) {
458
458
self . _set_high ( )
@@ -500,7 +500,7 @@ impl<MODE, const P: char, const N: u8> Pin<Output<MODE>, P, N> {
500
500
}
501
501
}
502
502
503
- impl < const P : char , const N : u8 > Pin < Output < OpenDrain > , P , N > {
503
+ impl < const P : char , const N : u8 > Pin < P , N , Output < OpenDrain > > {
504
504
#[ inline( always) ]
505
505
pub fn is_high ( & self ) -> bool {
506
506
!self . is_low ( )
@@ -512,7 +512,7 @@ impl<const P: char, const N: u8> Pin<Output<OpenDrain>, P, N> {
512
512
}
513
513
}
514
514
515
- impl < MODE , const P : char , const N : u8 > Pin < Input < MODE > , P , N > {
515
+ impl < const P : char , const N : u8 , MODE > Pin < P , N , Input < MODE > > {
516
516
#[ inline( always) ]
517
517
pub fn is_high ( & self ) -> bool {
518
518
!self . is_low ( )
@@ -564,10 +564,10 @@ macro_rules! gpio {
564
564
}
565
565
}
566
566
567
- pub type $PXn<MODE > = super :: PEPin <MODE , $port_id>;
567
+ pub type $PXn<MODE > = super :: PEPin <$port_id, MODE >;
568
568
569
569
$(
570
- pub type $PXi<MODE > = super :: Pin <MODE , $port_id, $i>;
570
+ pub type $PXi<MODE > = super :: Pin <$port_id, $i, MODE >;
571
571
) +
572
572
573
573
}
0 commit comments