1212
1313#![ deny( missing_docs) ]
1414
15- use cast;
1615pub use i2cdev;
1716pub use nb;
1817pub use serial_core;
@@ -25,13 +24,10 @@ pub use sysfs_gpio;
2524#[ cfg( feature = "gpio_cdev" ) ]
2625pub use gpio_cdev;
2726
28- use core:: convert:: Infallible ;
2927use std:: io:: { self , Write } ;
28+ use std:: ops;
3029use std:: path:: Path ;
31- use std:: time:: Duration ;
32- use std:: { ops, thread} ;
3330
34- use cast:: { u32, u64} ;
3531use spidev:: SpidevTransfer ;
3632
3733mod serial;
@@ -55,86 +51,8 @@ pub use cdev_pin::CdevPin;
5551/// Sysfs pin re-export
5652pub use sysfs_pin:: SysfsPin ;
5753
58- /// Empty struct that provides delay functionality on top of `thread::sleep`
59- pub struct Delay ;
60-
61- impl embedded_hal:: blocking:: delay:: DelayUs < u8 > for Delay {
62- type Error = Infallible ;
63-
64- fn try_delay_us ( & mut self , n : u8 ) -> Result < ( ) , Self :: Error > {
65- thread:: sleep ( Duration :: new ( 0 , u32 ( n) * 1000 ) ) ;
66- Ok ( ( ) )
67- }
68- }
69-
70- impl embedded_hal:: blocking:: delay:: DelayUs < u16 > for Delay {
71- type Error = Infallible ;
72-
73- fn try_delay_us ( & mut self , n : u16 ) -> Result < ( ) , Self :: Error > {
74- thread:: sleep ( Duration :: new ( 0 , u32 ( n) * 1000 ) ) ;
75- Ok ( ( ) )
76- }
77- }
78-
79- impl embedded_hal:: blocking:: delay:: DelayUs < u32 > for Delay {
80- type Error = Infallible ;
81-
82- fn try_delay_us ( & mut self , n : u32 ) -> Result < ( ) , Self :: Error > {
83- let secs = n / 1_000_000 ;
84- let nsecs = ( n % 1_000_000 ) * 1_000 ;
85-
86- thread:: sleep ( Duration :: new ( u64 ( secs) , nsecs) ) ;
87- Ok ( ( ) )
88- }
89- }
90-
91- impl embedded_hal:: blocking:: delay:: DelayUs < u64 > for Delay {
92- type Error = Infallible ;
93-
94- fn try_delay_us ( & mut self , n : u64 ) -> Result < ( ) , Self :: Error > {
95- let secs = n / 1_000_000 ;
96- let nsecs = ( ( n % 1_000_000 ) * 1_000 ) as u32 ;
97-
98- thread:: sleep ( Duration :: new ( secs, nsecs) ) ;
99- Ok ( ( ) )
100- }
101- }
102-
103- impl embedded_hal:: blocking:: delay:: DelayMs < u8 > for Delay {
104- type Error = Infallible ;
105-
106- fn try_delay_ms ( & mut self , n : u8 ) -> Result < ( ) , Self :: Error > {
107- thread:: sleep ( Duration :: from_millis ( u64 ( n) ) ) ;
108- Ok ( ( ) )
109- }
110- }
111-
112- impl embedded_hal:: blocking:: delay:: DelayMs < u16 > for Delay {
113- type Error = Infallible ;
114-
115- fn try_delay_ms ( & mut self , n : u16 ) -> Result < ( ) , Self :: Error > {
116- thread:: sleep ( Duration :: from_millis ( u64 ( n) ) ) ;
117- Ok ( ( ) )
118- }
119- }
120-
121- impl embedded_hal:: blocking:: delay:: DelayMs < u32 > for Delay {
122- type Error = Infallible ;
123-
124- fn try_delay_ms ( & mut self , n : u32 ) -> Result < ( ) , Self :: Error > {
125- thread:: sleep ( Duration :: from_millis ( u64 ( n) ) ) ;
126- Ok ( ( ) )
127- }
128- }
129-
130- impl embedded_hal:: blocking:: delay:: DelayMs < u64 > for Delay {
131- type Error = Infallible ;
132-
133- fn try_delay_ms ( & mut self , n : u64 ) -> Result < ( ) , Self :: Error > {
134- thread:: sleep ( Duration :: from_millis ( n) ) ;
135- Ok ( ( ) )
136- }
137- }
54+ mod delay;
55+ pub use crate :: delay:: Delay ;
13856
13957mod i2c;
14058pub use crate :: i2c:: I2cdev ;
0 commit comments