7878//! To make a pin dynamic, use the `into_dynamic` function, and then use the `make_<mode>` functions to
7979//! change the mode
8080
81- #![ allow( missing_docs) ]
82-
8381use core:: marker:: PhantomData ;
8482
8583use crate :: pac:: { Interrupt , EXTI } ;
@@ -89,9 +87,9 @@ use crate::Switch;
8987mod convert;
9088use convert:: PinMode ;
9189mod partially_erased;
92- pub use partially_erased:: { PEPin , PartiallyErasedPin } ;
90+ pub use partially_erased:: PartiallyErasedPin ;
9391mod erased;
94- pub use erased:: { EPin , ErasedPin } ;
92+ pub use erased:: ErasedPin ;
9593mod dynamic;
9694pub use dynamic:: { Dynamic , DynamicPin } ;
9795mod hal_02;
@@ -114,11 +112,13 @@ pub trait GpioExt {
114112 fn split ( self , ahb : & mut AHB ) -> Self :: Parts ;
115113}
116114
115+ /// Id, port and mode for any pin
117116pub trait PinExt {
117+ /// Current pin mode
118118 type Mode ;
119- /// Return pin number
119+ /// Pin number
120120 fn pin_id ( & self ) -> u8 ;
121- /// Return port number
121+ /// Port number starting from 0
122122 fn port_id ( & self ) -> u8 ;
123123}
124124
@@ -154,6 +154,7 @@ pub struct PushPull;
154154/// Analog mode (type state)
155155pub struct Analog ;
156156
157+ /// JTAG/SWD mote (type state)
157158pub type Debugger = Alternate < 0 , PushPull > ;
158159
159160mod sealed {
@@ -184,16 +185,23 @@ impl sealed::NotAlt for Analog {}
184185#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
185186#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
186187pub enum Speed {
188+ /// Low speed
187189 Low = 0 ,
190+ /// Medium speed
188191 Medium = 1 ,
192+ /// High speed
189193 High = 3 ,
190194}
191195
196+ /// GPIO interrupt trigger edge selection
192197#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
193198#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
194199pub enum Edge {
200+ /// Rising edge of voltage
195201 Rising ,
202+ /// Falling edge of voltage
196203 Falling ,
204+ /// Rising and falling edge of voltage
197205 RisingFalling ,
198206}
199207
@@ -474,16 +482,16 @@ impl<const P: char, const N: u8, MODE> Pin<P, N, MODE> {
474482 ///
475483 /// This is useful when you want to collect the pins into an array where you
476484 /// need all the elements to have the same type
477- pub fn erase_number ( self ) -> PEPin < P , MODE > {
478- PEPin :: new ( N )
485+ pub fn erase_number ( self ) -> PartiallyErasedPin < P , MODE > {
486+ PartiallyErasedPin :: new ( N )
479487 }
480488
481489 /// Erases the pin number and the port from the type
482490 ///
483491 /// This is useful when you want to collect the pins into an array where you
484492 /// need all the elements to have the same type
485- pub fn erase ( self ) -> EPin < MODE > {
486- EPin :: new ( P as u8 - b'A' , N )
493+ pub fn erase ( self ) -> ErasedPin < MODE > {
494+ ErasedPin :: new ( P as u8 - b'A' , N )
487495 }
488496}
489497
@@ -522,16 +530,19 @@ impl<const P: char, const N: u8, MODE> Pin<P, N, MODE> {
522530}
523531
524532impl < const P : char , const N : u8 , MODE > Pin < P , N , Output < MODE > > {
533+ /// Drives the pin high
525534 #[ inline( always) ]
526535 pub fn set_high ( & mut self ) {
527536 self . _set_high ( )
528537 }
529538
539+ /// Drives the pin low
530540 #[ inline( always) ]
531541 pub fn set_low ( & mut self ) {
532542 self . _set_low ( )
533543 }
534544
545+ /// Is the pin in drive high or low mode?
535546 #[ inline( always) ]
536547 pub fn get_state ( & self ) -> PinState {
537548 if self . is_set_low ( ) {
@@ -541,6 +552,7 @@ impl<const P: char, const N: u8, MODE> Pin<P, N, Output<MODE>> {
541552 }
542553 }
543554
555+ /// Drives the pin high or low depending on the provided value
544556 #[ inline( always) ]
545557 pub fn set_state ( & mut self , state : PinState ) {
546558 match state {
@@ -549,16 +561,19 @@ impl<const P: char, const N: u8, MODE> Pin<P, N, Output<MODE>> {
549561 }
550562 }
551563
564+ /// Is the pin in drive high mode?
552565 #[ inline( always) ]
553566 pub fn is_set_high ( & self ) -> bool {
554567 !self . is_set_low ( )
555568 }
556569
570+ /// Is the pin in drive low mode?
557571 #[ inline( always) ]
558572 pub fn is_set_low ( & self ) -> bool {
559573 self . _is_set_low ( )
560574 }
561575
576+ /// Toggle pin output
562577 #[ inline( always) ]
563578 pub fn toggle ( & mut self ) {
564579 if self . is_set_low ( ) {
@@ -573,11 +588,13 @@ impl<const P: char, const N: u8, MODE> Pin<P, N, MODE>
573588where
574589 MODE : sealed:: Readable ,
575590{
591+ /// Is the input pin high?
576592 #[ inline( always) ]
577593 pub fn is_high ( & self ) -> bool {
578594 !self . is_low ( )
579595 }
580596
597+ /// Is the input pin low?
581598 #[ inline( always) ]
582599 pub fn is_low ( & self ) -> bool {
583600 self . _is_low ( )
@@ -635,9 +652,14 @@ macro_rules! gpio {
635652 }
636653 }
637654
638- pub type $PXn<MODE > = super :: PEPin <$port_id, MODE >;
655+ #[ doc="Common type for " ]
656+ #[ doc=stringify!( $GPIOX) ]
657+ #[ doc=" related pins" ]
658+ pub type $PXn<MODE > = super :: PartiallyErasedPin <$port_id, MODE >;
639659
640660 $(
661+ #[ doc=stringify!( $PXi) ]
662+ #[ doc=" pin" ]
641663 pub type $PXi<MODE = Input > = super :: Pin <$port_id, $i, MODE >;
642664
643665 $(
@@ -722,7 +744,6 @@ gpio!(GPIOF, gpiof, PF, 'F', PFn, [
722744 PF1 : ( pf1, 1 , [ 4 , 5 ] ) ,
723745] ) ;
724746
725-
726747#[ cfg( feature = "gpio-f303e" ) ]
727748gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
728749 PA0 : ( pa0, 0 , [ 1 , 3 , 7 , 8 , 9 , 10 , 15 ] ) ,
@@ -870,7 +891,6 @@ gpio!(GPIOH, gpioh, PH, 'H', PHn, [
870891 PH2 : ( ph2, 2 , [ 1 ] ) ,
871892] ) ;
872893
873-
874894#[ cfg( feature = "gpio-f303" ) ]
875895gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
876896 PA0 : ( pa0, 0 , [ 1 , 3 , 7 , 8 , 9 , 10 , 15 ] ) ,
@@ -982,7 +1002,6 @@ gpio!(GPIOF, gpiof, PF, 'F', PFn, [
9821002 PF10 : ( pf10, 10 , [ 1 , 3 , 5 ] ) ,
9831003] ) ;
9841004
985-
9861005#[ cfg( feature = "gpio-f333" ) ]
9871006gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
9881007 PA0 : ( pa0, 0 , [ 1 , 3 , 7 , 15 ] ) ,
@@ -1054,7 +1073,6 @@ gpio!(GPIOF, gpiof, PF, 'F', PFn, [
10541073 PF1 : ( pf1, 1 , [ ] ) ,
10551074] ) ;
10561075
1057-
10581076#[ cfg( feature = "gpio-f373" ) ]
10591077gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
10601078 PA0 : ( pa0, 0 , [ 1 , 2 , 3 , 7 , 8 , 11 , 15 ] ) ,
0 commit comments