File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ macro_rules! gpio {
176
176
use core:: marker:: PhantomData ;
177
177
use core:: convert:: Infallible ;
178
178
179
- use crate :: hal:: digital:: v2:: { OutputPin , InputPin } ;
179
+ use crate :: hal:: digital:: v2:: { OutputPin , StatefulOutputPin , toggleable , InputPin } ;
180
180
use crate :: stm32:: { $gpioy, $GPIOX, EXTI , SYSCFG } ;
181
181
182
182
use crate :: rcc:: { AHB2 , APB2 } ;
@@ -668,6 +668,19 @@ macro_rules! gpio {
668
668
}
669
669
}
670
670
671
+ impl <MODE > StatefulOutputPin for $PXi<Output <MODE >> {
672
+ fn is_set_high( & self ) -> Result <bool , Self :: Error > {
673
+ Ok ( !self . is_set_low( ) . unwrap( ) )
674
+ }
675
+
676
+ fn is_set_low( & self ) -> Result <bool , Self :: Error > {
677
+ // NOTE(unsafe) atomic read with no side effects
678
+ Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . odr. read( ) . bits( ) & ( 1 << $i) == 0 } )
679
+ }
680
+ }
681
+
682
+ impl <MODE > toggleable:: Default for $PXi<Output <MODE >> { }
683
+
671
684
impl <MODE > InputPin for $PXi<Input <MODE >> {
672
685
type Error = Infallible ;
673
686
You can’t perform that action at this time.
0 commit comments