File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,20 @@ impl<MODE> Pin<MODE> {
236
236
237
237
pin
238
238
}
239
+
240
+ /// Disconnects the pin.
241
+ ///
242
+ /// In disconnected mode the pin cannot be used as input or output.
243
+ /// It is primarily useful to reduce power usage.
244
+ pub fn into_disconnected ( self ) -> Pin < Disconnected > {
245
+ // Reset value is disconnected.
246
+ self . block ( ) . pin_cnf [ self . pin ( ) as usize ] . reset ( ) ;
247
+
248
+ Pin {
249
+ _mode : PhantomData ,
250
+ pin_port : self . pin_port ,
251
+ }
252
+ }
239
253
}
240
254
241
255
impl < MODE > InputPin for Pin < Input < MODE > > {
@@ -489,6 +503,19 @@ macro_rules! gpio {
489
503
pin
490
504
}
491
505
506
+ /// Disconnects the pin.
507
+ ///
508
+ /// In disconnected mode the pin cannot be used as input or output.
509
+ /// It is primarily useful to reduce power usage.
510
+ pub fn into_disconnected( self ) -> $PXi<Disconnected > {
511
+ // Reset value is disconnected.
512
+ unsafe { & ( * $PX:: ptr( ) ) . pin_cnf[ $i] } . reset( ) ;
513
+
514
+ $PXi {
515
+ _mode: PhantomData ,
516
+ }
517
+ }
518
+
492
519
/// Degrade to a generic pin struct, which can be used with peripherals
493
520
pub fn degrade( self ) -> Pin <MODE > {
494
521
Pin :: new( $port_value, $i)
You can’t perform that action at this time.
0 commit comments