@@ -119,8 +119,13 @@ pub trait GpioExt {
119
119
/// The to split the GPIO into
120
120
type Parts ;
121
121
122
- /// Splits the GPIO block into independent pins and registers
122
+ /// Splits the GPIO block into independent pins and registers.
123
+ ///
124
+ /// This resets the state of the GPIO block.
123
125
fn split ( self ) -> Self :: Parts ;
126
+
127
+ /// Splits the GPIO block into independent pins and registers without resetting its state.
128
+ unsafe fn split_without_reset ( self ) -> Self :: Parts ;
124
129
}
125
130
126
131
/// Marker trait for active states.
@@ -391,6 +396,19 @@ macro_rules! gpio {
391
396
) +
392
397
}
393
398
}
399
+
400
+ unsafe fn split_without_reset( self ) -> Parts {
401
+ let rcc = unsafe { & ( * RCC :: ptr( ) ) } ;
402
+ $GPIOX:: enable( rcc) ;
403
+
404
+ Parts {
405
+ crl: Cr :: <$port_id, false >( ( ) ) ,
406
+ crh: Cr :: <$port_id, true >( ( ) ) ,
407
+ $(
408
+ $pxi: $PXi:: new( ) ,
409
+ ) +
410
+ }
411
+ }
394
412
}
395
413
396
414
impl <MODE > PartiallyErasedPin <$port_id, MODE > {
@@ -802,6 +820,17 @@ where
802
820
Pin :: new ( )
803
821
}
804
822
823
+ /// Configures the pin to operate as an push-pull output pin.
824
+ /// The state will not be changed.
825
+ #[ inline]
826
+ pub fn into_push_pull_output_with_current_state (
827
+ mut self ,
828
+ cr : & mut <Self as HL >:: Cr ,
829
+ ) -> Pin < P , N , Output < PushPull > > {
830
+ self . mode :: < Output < PushPull > > ( cr) ;
831
+ Pin :: new ( )
832
+ }
833
+
805
834
/// Configures the pin to operate as an analog input pin
806
835
#[ inline]
807
836
pub fn into_analog ( mut self , cr : & mut <Self as HL >:: Cr ) -> Pin < P , N , Analog > {
0 commit comments