File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,20 @@ macro_rules! gpio {
398
398
}
399
399
}
400
400
401
+ #[ cfg( feature = "unproven" ) ]
402
+ impl <MODE > InputPin for $PXx<Output <MODE >> {
403
+ type Error = Infallible ;
404
+
405
+ fn is_high( & self ) -> Result <bool , Self :: Error > {
406
+ Ok ( !self . is_low( ) ?)
407
+ }
408
+
409
+ fn is_low( & self ) -> Result <bool , Self :: Error > {
410
+ // NOTE(unsafe) atomic read with no side effects
411
+ Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << self . i) == 0 } )
412
+ }
413
+ }
414
+
401
415
#[ cfg( feature = "unproven" ) ]
402
416
impl <MODE > InputPin for $PXx<Input <MODE >> {
403
417
type Error = Infallible ;
@@ -584,6 +598,20 @@ macro_rules! gpio {
584
598
}
585
599
}
586
600
601
+ #[ cfg( feature = "unproven" ) ]
602
+ impl <MODE > InputPin for $PXi<Output <MODE >> {
603
+ type Error = Infallible ;
604
+
605
+ fn is_high( & self ) -> Result <bool , Self :: Error > {
606
+ Ok ( !self . is_low( ) ?)
607
+ }
608
+
609
+ fn is_low( & self ) -> Result <bool , Self :: Error > {
610
+ // NOTE(unsafe) atomic read with no side effects
611
+ Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << $i) == 0 } )
612
+ }
613
+ }
614
+
587
615
#[ cfg( feature = "unproven" ) ]
588
616
impl <MODE > InputPin for $PXi<Input <MODE >> {
589
617
type Error = Infallible ;
You can’t perform that action at this time.
0 commit comments