@@ -145,7 +145,7 @@ macro_rules! gpio {
145
145
pub mod $gpiox {
146
146
use core:: marker:: PhantomData ;
147
147
148
- use embedded_hal:: digital:: v2:: { InputPin , OutputPin ,
148
+ use embedded_hal:: digital:: v2:: { InputPin , OutputPin , IoPin , PinState ,
149
149
StatefulOutputPin , toggleable} ;
150
150
151
151
use crate :: rcc:: { rec, ResetEnable } ;
@@ -761,6 +761,46 @@ macro_rules! gpio {
761
761
}
762
762
}
763
763
764
+ impl IoPin <Self , Self >
765
+ for $PXi<Output <OpenDrain >>
766
+ {
767
+ type Error = Never ;
768
+ fn into_input_pin( self ) -> Result <Self , Self :: Error > {
769
+ Ok ( self )
770
+ }
771
+ fn into_output_pin( mut self , state: PinState ) -> Result <Self , Self :: Error > {
772
+ self . set_state( state) ?;
773
+ Ok ( self )
774
+ }
775
+ }
776
+
777
+ impl IoPin <$PXi<Input <Floating >>, Self >
778
+ for $PXi<Output <PushPull >>
779
+ {
780
+ type Error = Never ;
781
+ fn into_input_pin( self ) -> Result <$PXi<Input <Floating >>, Self :: Error > {
782
+ Ok ( self . into_floating_input( ) )
783
+ }
784
+ fn into_output_pin( mut self , state: PinState ) -> Result <Self , Self :: Error > {
785
+ self . set_state( state) ?;
786
+ Ok ( self )
787
+ }
788
+ }
789
+
790
+ impl IoPin <Self , $PXi<Output <PushPull >>>
791
+ for $PXi<Input <Floating >>
792
+ {
793
+ type Error = Never ;
794
+ fn into_input_pin( self ) -> Result <Self , Self :: Error > {
795
+ Ok ( self )
796
+ }
797
+ fn into_output_pin( self , state: PinState ) -> Result <$PXi<Output <PushPull >>, Self :: Error > {
798
+ let mut pin = self . into_push_pull_output( ) ;
799
+ pin. set_state( state) ?;
800
+ Ok ( pin)
801
+ }
802
+ }
803
+
764
804
impl <MODE > ExtiPin for $PXi<Input <MODE >> {
765
805
/// Configure EXTI Line $i to trigger from this pin.
766
806
fn make_interrupt_source( & mut self , syscfg: & mut SYSCFG ) {
0 commit comments