12
12
13
13
#![ deny( missing_docs) ]
14
14
15
- use cast;
16
15
pub use i2cdev;
17
16
pub use nb;
18
17
pub use serial_core;
@@ -25,13 +24,10 @@ pub use sysfs_gpio;
25
24
#[ cfg( feature = "gpio_cdev" ) ]
26
25
pub use gpio_cdev;
27
26
28
- use core:: convert:: Infallible ;
29
27
use std:: io:: { self , Write } ;
28
+ use std:: ops;
30
29
use std:: path:: Path ;
31
- use std:: time:: Duration ;
32
- use std:: { ops, thread} ;
33
30
34
- use cast:: { u32, u64} ;
35
31
use spidev:: SpidevTransfer ;
36
32
37
33
mod serial;
@@ -55,86 +51,8 @@ pub use cdev_pin::CdevPin;
55
51
/// Sysfs pin re-export
56
52
pub use sysfs_pin:: SysfsPin ;
57
53
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 ;
138
56
139
57
mod i2c;
140
58
pub use crate :: i2c:: I2cdev ;
0 commit comments