1
1
use core:: convert:: Infallible ;
2
2
3
- use super :: { ErasedPin , Input , OpenDrain , Output , PartiallyErasedPin , Pin , PushPull } ;
3
+ use super :: { ErasedPin , Input , OpenDrain , Output , PartiallyErasedPin , Pin , PinMode } ;
4
4
5
5
pub use embedded_hal_one:: digital:: PinState ;
6
6
use embedded_hal_one:: digital:: {
@@ -89,7 +89,10 @@ impl<const P: char, const N: u8> IoPin<Self, Self> for Pin<P, N, Output<OpenDrai
89
89
}
90
90
}
91
91
92
- impl < const P : char , const N : u8 > IoPin < Pin < P , N , Input > , Self > for Pin < P , N , Output < OpenDrain > > {
92
+ impl < const P : char , const N : u8 , Otype > IoPin < Pin < P , N , Input > , Self > for Pin < P , N , Output < Otype > >
93
+ where
94
+ Output < Otype > : PinMode ,
95
+ {
93
96
type Error = Infallible ;
94
97
fn into_input_pin ( self ) -> Result < Pin < P , N , Input > , Self :: Error > {
95
98
Ok ( self . into_input ( ) )
@@ -100,34 +103,17 @@ impl<const P: char, const N: u8> IoPin<Pin<P, N, Input>, Self> for Pin<P, N, Out
100
103
}
101
104
}
102
105
103
- impl < const P : char , const N : u8 > IoPin < Self , Pin < P , N , Output < OpenDrain > > > for Pin < P , N , Input > {
106
+ impl < const P : char , const N : u8 , Otype > IoPin < Self , Pin < P , N , Output < Otype > > > for Pin < P , N , Input >
107
+ where
108
+ Output < Otype > : PinMode ,
109
+ {
104
110
type Error = Infallible ;
105
111
fn into_input_pin ( self ) -> Result < Self , Self :: Error > {
106
112
Ok ( self )
107
113
}
108
- fn into_output_pin ( self , state : PinState ) -> Result < Pin < P , N , Output < OpenDrain > > , Self :: Error > {
109
- Ok ( self . into_open_drain_output_in_state ( into_state ( state) ) )
110
- }
111
- }
112
-
113
- impl < const P : char , const N : u8 > IoPin < Pin < P , N , Input > , Self > for Pin < P , N , Output < PushPull > > {
114
- type Error = Infallible ;
115
- fn into_input_pin ( self ) -> Result < Pin < P , N , Input > , Self :: Error > {
116
- Ok ( self . into_input ( ) )
117
- }
118
- fn into_output_pin ( mut self , state : PinState ) -> Result < Self , Self :: Error > {
119
- self . set_state ( into_state ( state) ) ;
120
- Ok ( self )
121
- }
122
- }
123
-
124
- impl < const P : char , const N : u8 > IoPin < Self , Pin < P , N , Output < PushPull > > > for Pin < P , N , Input > {
125
- type Error = Infallible ;
126
- fn into_input_pin ( self ) -> Result < Self , Self :: Error > {
127
- Ok ( self )
128
- }
129
- fn into_output_pin ( self , state : PinState ) -> Result < Pin < P , N , Output < PushPull > > , Self :: Error > {
130
- Ok ( self . into_push_pull_output_in_state ( into_state ( state) ) )
114
+ fn into_output_pin ( mut self , state : PinState ) -> Result < Pin < P , N , Output < Otype > > , Self :: Error > {
115
+ self . _set_state ( into_state ( state) ) ;
116
+ Ok ( self . into_mode ( ) )
131
117
}
132
118
}
133
119
0 commit comments