File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,38 @@ use defmt_03 as defmt;
18
18
19
19
pub mod i2c;
20
20
pub mod spi;
21
+
22
+ /// This adapter will [panic] if the inner device encounters an error.
23
+ ///
24
+ /// It currently supports [embedded_hal::digital::OutputPin], but other traits may be added in the future.
25
+ ///
26
+ /// TODO: add usage example
27
+ #[ repr( transparent) ]
28
+ pub struct UnwrappingAdapter < T > ( pub T ) ;
29
+
30
+ impl < T > embedded_hal:: digital:: ErrorType for UnwrappingAdapter < T > {
31
+ type Error = core:: convert:: Infallible ;
32
+ }
33
+
34
+ impl < T > embedded_hal:: digital:: OutputPin for UnwrappingAdapter < T >
35
+ where
36
+ T : embedded_hal:: digital:: OutputPin ,
37
+ {
38
+ #[ inline]
39
+ fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
40
+ self . 0 . set_low ( ) . unwrap ( ) ;
41
+ Ok ( ( ) )
42
+ }
43
+
44
+ #[ inline]
45
+ fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
46
+ self . 0 . set_high ( ) . unwrap ( ) ;
47
+ Ok ( ( ) )
48
+ }
49
+
50
+ #[ inline]
51
+ fn set_state ( & mut self , state : embedded_hal:: digital:: PinState ) -> Result < ( ) , Self :: Error > {
52
+ self . 0 . set_state ( state) . unwrap ( ) ;
53
+ Ok ( ( ) )
54
+ }
55
+ }
You can’t perform that action at this time.
0 commit comments