@@ -80,56 +80,61 @@ trait PeripheralAccess {
8080
8181    fn  set_input_en ( index :  usize ,  bit :  bool )  { 
8282        let  p = Self :: peripheral ( ) ; 
83-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. input_en ( ) )  } ; 
83+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. input_en ( ) )  } ; 
8484        atomic_set_bit ( r,  index,  bit) ; 
8585    } 
8686
8787    fn  set_output_en ( index :  usize ,  bit :  bool )  { 
8888        let  p = Self :: peripheral ( ) ; 
89-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. output_en ( ) )  } ; 
89+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. output_en ( ) )  } ; 
9090        atomic_set_bit ( r,  index,  bit) ; 
9191    } 
9292
93+     fn  output_value ( index :  usize )  -> bool  { 
94+         let  p = Self :: peripheral ( ) ; 
95+         ( ( p. output_val ( ) . read ( ) . bits ( )  >> ( index &  31 ) )  &  1 )  != 0 
96+     } 
97+ 
9398    fn  set_output_value ( index :  usize ,  bit :  bool )  { 
9499        let  p = Self :: peripheral ( ) ; 
95-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. output_val ( ) )  } ; 
100+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. output_val ( ) )  } ; 
96101        atomic_set_bit ( r,  index,  bit) ; 
97102    } 
98103
99104    fn  toggle_pin ( index :  usize )  { 
100105        let  p = Self :: peripheral ( ) ; 
101-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. output_val ( ) )  } ; 
106+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. output_val ( ) )  } ; 
102107        let  mask = 1  << ( index &  31 ) ; 
103108        r. fetch_xor ( mask,  Ordering :: SeqCst ) ; 
104109    } 
105110
106111    fn  set_pullup ( index :  usize ,  bit :  bool )  { 
107112        let  p = Self :: peripheral ( ) ; 
108-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. pullup ( ) )  } ; 
113+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. pullup ( ) )  } ; 
109114        atomic_set_bit ( r,  index,  bit) ; 
110115    } 
111116
112117    fn  set_drive ( index :  usize ,  bit :  bool )  { 
113118        let  p = Self :: peripheral ( ) ; 
114-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. drive ( ) )  } ; 
119+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. drive ( ) )  } ; 
115120        atomic_set_bit ( r,  index,  bit) ; 
116121    } 
117122
118123    fn  set_out_xor ( index :  usize ,  bit :  bool )  { 
119124        let  p = Self :: peripheral ( ) ; 
120-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. out_xor ( ) )  } ; 
125+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. out_xor ( ) )  } ; 
121126        atomic_set_bit ( r,  index,  bit) ; 
122127    } 
123128
124129    fn  set_iof_en ( index :  usize ,  bit :  bool )  { 
125130        let  p = Self :: peripheral ( ) ; 
126-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. iof_en ( ) )  } ; 
131+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. iof_en ( ) )  } ; 
127132        atomic_set_bit ( r,  index,  bit) ; 
128133    } 
129134
130135    fn  set_iof_sel ( index :  usize ,  bit :  bool )  { 
131136        let  p = Self :: peripheral ( ) ; 
132-         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( & p. iof_sel ( ) )  } ; 
137+         let  r:  & AtomicU32  = unsafe  {  core:: mem:: transmute ( p. iof_sel ( ) )  } ; 
133138        atomic_set_bit ( r,  index,  bit) ; 
134139    } 
135140} 
@@ -310,7 +315,7 @@ macro_rules! gpio {
310315                impl <MODE > StatefulOutputPin  for  $PXi<Output <MODE >> { 
311316                    #[ inline] 
312317                    fn  is_set_high( & mut  self )  -> Result <bool ,  Infallible > { 
313-                         Ok ( $GPIOX:: input_value ( Self :: INDEX ) ) 
318+                         Ok ( $GPIOX:: output_value ( Self :: INDEX ) ) 
314319                    } 
315320
316321                    #[ inline] 
0 commit comments