@@ -206,6 +206,31 @@ macro_rules! gpio {
206
206
}
207
207
}
208
208
209
+ #[ cfg( feature = "unproven" ) ]
210
+ impl InputPin for PXx <Output <OpenDrain >> {
211
+ type Error = Infallible ;
212
+
213
+ fn is_high( & self ) -> Result <bool , Self :: Error > {
214
+ Ok ( !self . is_low( ) ?)
215
+ }
216
+
217
+ fn is_low( & self ) -> Result <bool , Self :: Error > {
218
+ // NOTE(unsafe) atomic read with no side effects
219
+ Ok ( unsafe {
220
+ match & self . gpio {
221
+ $(
222
+ #[ cfg( all( any(
223
+ $( feature = $device, ) +
224
+ ) , not( any(
225
+ $( feature = $device_except, ) *
226
+ ) ) ) ) ]
227
+ Gpio :: $GPIOX => ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << self . i) == 0 ,
228
+ ) +
229
+ }
230
+ } )
231
+ }
232
+ }
233
+
209
234
#[ cfg( feature = "unproven" ) ]
210
235
impl <MODE > StatefulOutputPin for PXx <Output <MODE >> {
211
236
fn is_set_high( & self ) -> Result <bool , Self :: Error > {
@@ -412,6 +437,20 @@ macro_rules! gpio {
412
437
}
413
438
}
414
439
440
+ #[ cfg( feature = "unproven" ) ]
441
+ impl InputPin for $PXx<Output <OpenDrain >> {
442
+ type Error = Infallible ;
443
+
444
+ fn is_high( & self ) -> Result <bool , Self :: Error > {
445
+ Ok ( !self . is_low( ) ?)
446
+ }
447
+
448
+ fn is_low( & self ) -> Result <bool , Self :: Error > {
449
+ // NOTE(unsafe) atomic read with no side effects
450
+ Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << self . i) == 0 } )
451
+ }
452
+ }
453
+
415
454
#[ cfg( feature = "unproven" ) ]
416
455
impl <MODE > StatefulOutputPin for $PXx<Output <MODE >> {
417
456
fn is_set_high( & self ) -> Result <bool , Self :: Error > {
@@ -598,6 +637,20 @@ macro_rules! gpio {
598
637
}
599
638
}
600
639
640
+ #[ cfg( feature = "unproven" ) ]
641
+ impl InputPin for $PXi<Output <OpenDrain >> {
642
+ type Error = Infallible ;
643
+
644
+ fn is_high( & self ) -> Result <bool , Self :: Error > {
645
+ Ok ( !self . is_low( ) ?)
646
+ }
647
+
648
+ fn is_low( & self ) -> Result <bool , Self :: Error > {
649
+ // NOTE(unsafe) atomic read with no side effects
650
+ Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . $idri( ) . is_low( ) } )
651
+ }
652
+ }
653
+
601
654
#[ cfg( feature = "unproven" ) ]
602
655
impl <MODE > StatefulOutputPin for $PXi<Output <MODE >> {
603
656
fn is_set_high( & self ) -> Result <bool , Self :: Error > {
0 commit comments