@@ -55,6 +55,10 @@ impl generics::Sealed for Input {}
55
55
pub enum Output { }
56
56
impl generics:: Sealed for Output { }
57
57
58
+ /// Type indicating that the [`Pin`] is an open drain
59
+ pub enum OpenDrain { }
60
+ impl generics:: Sealed for OpenDrain { }
61
+
58
62
//================================================================================
59
63
// Peripheral configurations
60
64
//================================================================================
@@ -117,6 +121,10 @@ impl PinMode for Output {
117
121
const DYN : DynPinMode = DynPinMode :: Output ;
118
122
}
119
123
124
+ impl PinMode for OpenDrain {
125
+ const DYN : DynPinMode = DynPinMode :: OpenDrain ;
126
+ }
127
+
120
128
impl PinMode for Input {
121
129
const DYN : DynPinMode = DynPinMode :: Input ;
122
130
}
@@ -207,6 +215,15 @@ where
207
215
pin
208
216
}
209
217
218
+ /// Configures tis pin to operate as an [`OpenDrain`] [`Pin`].
219
+ #[ inline]
220
+ pub fn into_opendrain ( self , cfg : PullDir ) -> Pin < I , OpenDrain > {
221
+ let mut pin: Pin < I , OpenDrain > = self . into_mode ( ) ;
222
+ pin. set_pull_dir ( cfg) ;
223
+
224
+ pin
225
+ }
226
+
210
227
/// Configures this [`Pin`] to operate as an [`Input`] [`Pin`].
211
228
#[ inline]
212
229
pub fn into_input ( self , cfg : PullDir ) -> Pin < I , Input > {
@@ -423,6 +440,25 @@ where
423
440
}
424
441
}
425
442
443
+ impl < I > OutputPin for Pin < I , OpenDrain >
444
+ where
445
+ I : PinId ,
446
+ {
447
+ type Error = Infallible ;
448
+
449
+ #[ inline]
450
+ fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
451
+ self . set_pull_dir ( PullDir :: PullUp ) ;
452
+ Ok ( ( ) )
453
+ }
454
+
455
+ #[ inline]
456
+ fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
457
+ self . set_pull_dir ( PullDir :: Floating ) ;
458
+ Ok ( ( ) )
459
+ }
460
+ }
461
+
426
462
#[ cfg( feature = "unproven" ) ]
427
463
impl < I > ToggleableOutputPin for Pin < I , Output >
428
464
where
0 commit comments