@@ -101,7 +101,7 @@ macro_rules! gpio {
101101 use core:: marker:: PhantomData ;
102102 use core:: convert:: Infallible ;
103103
104- use embedded_hal:: digital:: v2 :: { InputPin , OutputPin , StatefulOutputPin , toggleable} ;
104+ use embedded_hal:: digital:: { InputPin , OutputPin , StatefulOutputPin , toggleable} ;
105105 use crate :: stm32:: $GPIOX;
106106
107107 use crate :: stm32:: { RCC , EXTI , SYSCFG } ;
@@ -150,25 +150,25 @@ macro_rules! gpio {
150150 impl <MODE > OutputPin for $PXx<Output <MODE >> {
151151 type Error = Infallible ;
152152
153- fn set_high ( & mut self ) -> Result <( ) , Self :: Error > {
153+ fn try_set_high ( & mut self ) -> Result <( ) , Self :: Error > {
154154 // NOTE(unsafe) atomic write to a stateless register
155155 unsafe { ( * $GPIOX:: ptr( ) ) . bsrr. write( |w| w. bits( 1 << self . i) ) } ;
156156 Ok ( ( ) )
157157 }
158158
159- fn set_low ( & mut self ) -> Result <( ) , Self :: Error > {
159+ fn try_set_low ( & mut self ) -> Result <( ) , Self :: Error > {
160160 // NOTE(unsafe) atomic write to a stateless register
161161 unsafe { ( * $GPIOX:: ptr( ) ) . bsrr. write( |w| w. bits( 1 << ( self . i + 16 ) ) ) } ;
162162 Ok ( ( ) )
163163 }
164164 }
165165
166166 impl <MODE > StatefulOutputPin for $PXx<Output <MODE >> {
167- fn is_set_high ( & self ) -> Result <bool , Self :: Error > {
168- self . is_set_low ( ) . map( |v| !v)
167+ fn try_is_set_high ( & self ) -> Result <bool , Self :: Error > {
168+ self . try_is_set_low ( ) . map( |v| !v)
169169 }
170170
171- fn is_set_low ( & self ) -> Result <bool , Self :: Error > {
171+ fn try_is_set_low ( & self ) -> Result <bool , Self :: Error > {
172172 // NOTE(unsafe) atomic read with no side effects
173173 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . odr. read( ) . bits( ) & ( 1 << self . i) == 0 } )
174174 }
@@ -179,11 +179,11 @@ macro_rules! gpio {
179179 impl <MODE > InputPin for $PXx<Output <MODE >> {
180180 type Error = Infallible ;
181181
182- fn is_high ( & self ) -> Result <bool , Self :: Error > {
183- self . is_low ( ) . map( |v| !v)
182+ fn try_is_high ( & self ) -> Result <bool , Self :: Error > {
183+ self . try_is_low ( ) . map( |v| !v)
184184 }
185185
186- fn is_low ( & self ) -> Result <bool , Self :: Error > {
186+ fn try_is_low ( & self ) -> Result <bool , Self :: Error > {
187187 // NOTE(unsafe) atomic read with no side effects
188188 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << self . i) == 0 } )
189189 }
@@ -192,11 +192,11 @@ macro_rules! gpio {
192192 impl <MODE > InputPin for $PXx<Input <MODE >> {
193193 type Error = Infallible ;
194194
195- fn is_high ( & self ) -> Result <bool , Self :: Error > {
196- self . is_low ( ) . map( |v| !v)
195+ fn try_is_high ( & self ) -> Result <bool , Self :: Error > {
196+ self . try_is_low ( ) . map( |v| !v)
197197 }
198198
199- fn is_low ( & self ) -> Result <bool , Self :: Error > {
199+ fn try_is_low ( & self ) -> Result <bool , Self :: Error > {
200200 // NOTE(unsafe) atomic read with no side effects
201201 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << self . i) == 0 } )
202202 }
@@ -670,25 +670,25 @@ macro_rules! gpio {
670670 impl <MODE > OutputPin for $PXi<Output <MODE >> {
671671 type Error = Infallible ;
672672
673- fn set_high ( & mut self ) -> Result <( ) , Self :: Error > {
673+ fn try_set_high ( & mut self ) -> Result <( ) , Self :: Error > {
674674 // NOTE(unsafe) atomic write to a stateless register
675675 unsafe { ( * $GPIOX:: ptr( ) ) . bsrr. write( |w| w. bits( 1 << $i) ) } ;
676676 Ok ( ( ) )
677677 }
678678
679- fn set_low ( & mut self ) -> Result <( ) , Self :: Error > {
679+ fn try_set_low ( & mut self ) -> Result <( ) , Self :: Error > {
680680 // NOTE(unsafe) atomic write to a stateless register
681681 unsafe { ( * $GPIOX:: ptr( ) ) . bsrr. write( |w| w. bits( 1 << ( $i + 16 ) ) ) } ;
682682 Ok ( ( ) )
683683 }
684684 }
685685
686686 impl <MODE > StatefulOutputPin for $PXi<Output <MODE >> {
687- fn is_set_high ( & self ) -> Result <bool , Self :: Error > {
688- self . is_set_low ( ) . map( |v| !v)
687+ fn try_is_set_high ( & self ) -> Result <bool , Self :: Error > {
688+ self . try_is_set_low ( ) . map( |v| !v)
689689 }
690690
691- fn is_set_low ( & self ) -> Result <bool , Self :: Error > {
691+ fn try_is_set_low ( & self ) -> Result <bool , Self :: Error > {
692692 // NOTE(unsafe) atomic read with no side effects
693693 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . odr. read( ) . bits( ) & ( 1 << $i) == 0 } )
694694 }
@@ -699,11 +699,11 @@ macro_rules! gpio {
699699 impl <MODE > InputPin for $PXi<Output <MODE >> {
700700 type Error = Infallible ;
701701
702- fn is_high ( & self ) -> Result <bool , Self :: Error > {
703- self . is_low ( ) . map( |v| !v)
702+ fn try_is_high ( & self ) -> Result <bool , Self :: Error > {
703+ self . try_is_low ( ) . map( |v| !v)
704704 }
705705
706- fn is_low ( & self ) -> Result <bool , Self :: Error > {
706+ fn try_is_low ( & self ) -> Result <bool , Self :: Error > {
707707 // NOTE(unsafe) atomic read with no side effects
708708 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << $i) == 0 } )
709709 }
@@ -712,11 +712,11 @@ macro_rules! gpio {
712712 impl <MODE > InputPin for $PXi<Input <MODE >> {
713713 type Error = Infallible ;
714714
715- fn is_high ( & self ) -> Result <bool , Self :: Error > {
716- self . is_low ( ) . map( |v| !v)
715+ fn try_is_high ( & self ) -> Result <bool , Self :: Error > {
716+ self . try_is_low ( ) . map( |v| !v)
717717 }
718718
719- fn is_low ( & self ) -> Result <bool , Self :: Error > {
719+ fn try_is_low ( & self ) -> Result <bool , Self :: Error > {
720720 // NOTE(unsafe) atomic read with no side effects
721721 Ok ( unsafe { ( * $GPIOX:: ptr( ) ) . idr. read( ) . bits( ) & ( 1 << $i) == 0 } )
722722 }
0 commit comments