File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,10 @@ pub fn runner() -> Result<()> {
104
104
}
105
105
/// Use `esp_idf_hal` as an example for advanced used of Traits and trait objects
106
106
mod lesson_3 {
107
- use crate :: into_ref;
107
+ use crate :: {
108
+ into_ref,
109
+ traits:: lesson_3:: peripheral:: { Peripheral , PeripheralRef } ,
110
+ } ;
108
111
use anyhow:: Result ;
109
112
110
113
mod core {
@@ -623,19 +626,23 @@ mod lesson_3 {
623
626
}
624
627
625
628
pub fn run ( ) -> Result < ( ) > {
626
- use self :: core:: * ;
627
629
use gpio:: * ;
628
- use peripheral :: { Peripheral , PeripheralRef } ;
630
+ use std :: ops :: Deref ;
629
631
630
632
gpio:: pin!( Gpio0 : 0 , IO ) ;
631
633
gpio:: pin!( Gpio34 : 34 , Input ) ;
632
634
633
635
unsafe {
634
636
let pin = Gpio0 :: new ( ) ;
635
- gpio:: PinDriver :: output ( pin) ;
637
+ gpio:: PinDriver :: output ( pin) ? ;
636
638
637
- let pin2 = Gpio34 :: new ( ) ;
638
- gpio:: PinDriver :: input ( pin2) ;
639
+ let mut pin2 = Gpio34 :: new ( ) ;
640
+ let pin2_ref = pin2. into_ref ( ) ;
641
+
642
+ let driver = gpio:: PinDriver :: input ( pin2_ref) ?;
643
+ driver. into_input ( ) ?;
644
+
645
+ // let pin2_d = pin2_ref.deref();
639
646
}
640
647
641
648
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments