@@ -10,31 +10,33 @@ use std::sync::{Arc, Mutex};
10
10
/// [`FtHal::ad0`]: crate::FtHal::ad0
11
11
/// [`FtHal::ad7`]: crate::FtHal::ad7
12
12
#[ derive( Debug ) ]
13
- pub struct OutputPin < ' a , Device : MpsseCmdExecutor > {
13
+ pub struct OutputPin < Device : MpsseCmdExecutor > {
14
14
/// Parent FTDI device.
15
- mtx : & ' a Arc < Mutex < FtInner < Device > > > ,
15
+ mtx : Arc < Mutex < FtInner < Device > > > ,
16
16
/// GPIO pin index. 0-7 for the FT232H.
17
17
idx : u8 ,
18
18
}
19
19
20
- impl < ' a , Device , E > OutputPin < ' a , Device >
20
+ impl < Device , E > OutputPin < Device >
21
21
where
22
22
Device : MpsseCmdExecutor < Error = E > ,
23
23
E : std:: error:: Error ,
24
24
Error < E > : From < E > ,
25
25
{
26
26
pub ( crate ) fn new (
27
- mtx : & ' a Arc < Mutex < FtInner < Device > > > ,
27
+ mtx : Arc < Mutex < FtInner < Device > > > ,
28
28
idx : u8 ,
29
- ) -> Result < OutputPin < ' a , Device > , Error < E > > {
30
- let mut lock = mtx. lock ( ) . expect ( "Failed to aquire FTDI mutex" ) ;
31
-
32
- lock. direction |= 1 << idx;
33
- lock. allocate_pin ( idx, PinUse :: Output ) ;
34
- let cmd: MpsseCmdBuilder = MpsseCmdBuilder :: new ( )
35
- . set_gpio_lower ( lock. value , lock. direction )
36
- . send_immediate ( ) ;
37
- lock. ft . send ( cmd. as_slice ( ) ) ?;
29
+ ) -> Result < OutputPin < Device > , Error < E > > {
30
+ {
31
+ let mut lock = mtx. lock ( ) . expect ( "Failed to aquire FTDI mutex" ) ;
32
+
33
+ lock. direction |= 1 << idx;
34
+ lock. allocate_pin ( idx, PinUse :: Output ) ;
35
+ let cmd: MpsseCmdBuilder = MpsseCmdBuilder :: new ( )
36
+ . set_gpio_lower ( lock. value , lock. direction )
37
+ . send_immediate ( ) ;
38
+ lock. ft . send ( cmd. as_slice ( ) ) ?;
39
+ }
38
40
Ok ( OutputPin { mtx, idx } )
39
41
}
40
42
@@ -56,14 +58,14 @@ where
56
58
}
57
59
}
58
60
59
- impl < ' a , Device : MpsseCmdExecutor > OutputPin < ' a , Device > {
61
+ impl < Device : MpsseCmdExecutor > OutputPin < Device > {
60
62
/// Convert the GPIO pin index to a pin mask
61
63
pub ( crate ) fn mask ( & self ) -> u8 {
62
64
1 << self . idx
63
65
}
64
66
}
65
67
66
- impl < ' a , Device , E > eh1:: digital:: ErrorType for OutputPin < ' a , Device >
68
+ impl < Device , E > eh1:: digital:: ErrorType for OutputPin < Device >
67
69
where
68
70
Device : MpsseCmdExecutor < Error = E > ,
69
71
E : std:: error:: Error ,
72
74
type Error = Error < E > ;
73
75
}
74
76
75
- impl < ' a , Device , E > eh1:: digital:: OutputPin for OutputPin < ' a , Device >
77
+ impl < Device , E > eh1:: digital:: OutputPin for OutputPin < Device >
76
78
where
77
79
Device : MpsseCmdExecutor < Error = E > ,
78
80
E : std:: error:: Error ,
87
89
}
88
90
}
89
91
90
- impl < ' a , Device , E > eh0:: digital:: v2:: OutputPin for OutputPin < ' a , Device >
92
+ impl < Device , E > eh0:: digital:: v2:: OutputPin for OutputPin < Device >
91
93
where
92
94
Device : MpsseCmdExecutor < Error = E > ,
93
95
E : std:: error:: Error ,
@@ -111,31 +113,33 @@ where
111
113
/// [`FtHal::adi0`]: crate::FtHal::adi0
112
114
/// [`FtHal::adi7`]: crate::FtHal::adi7
113
115
#[ derive( Debug ) ]
114
- pub struct InputPin < ' a , Device : MpsseCmdExecutor > {
116
+ pub struct InputPin < Device : MpsseCmdExecutor > {
115
117
/// Parent FTDI device.
116
- mtx : & ' a Arc < Mutex < FtInner < Device > > > ,
118
+ mtx : Arc < Mutex < FtInner < Device > > > ,
117
119
/// GPIO pin index. 0-7 for the FT232H.
118
120
idx : u8 ,
119
121
}
120
122
121
- impl < ' a , Device , E > InputPin < ' a , Device >
123
+ impl < Device , E > InputPin < Device >
122
124
where
123
125
Device : MpsseCmdExecutor < Error = E > ,
124
126
E : std:: error:: Error ,
125
127
Error < E > : From < E > ,
126
128
{
127
129
pub ( crate ) fn new (
128
- mtx : & ' a Arc < Mutex < FtInner < Device > > > ,
130
+ mtx : Arc < Mutex < FtInner < Device > > > ,
129
131
idx : u8 ,
130
- ) -> Result < InputPin < ' a , Device > , Error < E > > {
131
- let mut lock = mtx. lock ( ) . expect ( "Failed to aquire FTDI mutex" ) ;
132
-
133
- lock. direction &= !( 1 << idx) ;
134
- lock. allocate_pin ( idx, PinUse :: Input ) ;
135
- let cmd: MpsseCmdBuilder = MpsseCmdBuilder :: new ( )
136
- . set_gpio_lower ( lock. value , lock. direction )
137
- . send_immediate ( ) ;
138
- lock. ft . send ( cmd. as_slice ( ) ) ?;
132
+ ) -> Result < InputPin < Device > , Error < E > > {
133
+ {
134
+ let mut lock = mtx. lock ( ) . expect ( "Failed to aquire FTDI mutex" ) ;
135
+
136
+ lock. direction &= !( 1 << idx) ;
137
+ lock. allocate_pin ( idx, PinUse :: Input ) ;
138
+ let cmd: MpsseCmdBuilder = MpsseCmdBuilder :: new ( )
139
+ . set_gpio_lower ( lock. value , lock. direction )
140
+ . send_immediate ( ) ;
141
+ lock. ft . send ( cmd. as_slice ( ) ) ?;
142
+ }
139
143
Ok ( InputPin { mtx, idx } )
140
144
}
141
145
@@ -151,14 +155,14 @@ where
151
155
}
152
156
}
153
157
154
- impl < ' a , Device : MpsseCmdExecutor > InputPin < ' a , Device > {
158
+ impl < Device : MpsseCmdExecutor > InputPin < Device > {
155
159
/// Convert the GPIO pin index to a pin mask
156
160
pub ( crate ) fn mask ( & self ) -> u8 {
157
161
1 << self . idx
158
162
}
159
163
}
160
164
161
- impl < ' a , Device , E > eh1:: digital:: ErrorType for InputPin < ' a , Device >
165
+ impl < Device , E > eh1:: digital:: ErrorType for InputPin < Device >
162
166
where
163
167
Device : MpsseCmdExecutor < Error = E > ,
164
168
E : std:: error:: Error ,
@@ -167,7 +171,7 @@ where
167
171
type Error = Error < E > ;
168
172
}
169
173
170
- impl < ' a , Device , E > eh1:: digital:: InputPin for InputPin < ' a , Device >
174
+ impl < Device , E > eh1:: digital:: InputPin for InputPin < Device >
171
175
where
172
176
Device : MpsseCmdExecutor < Error = E > ,
173
177
E : std:: error:: Error ,
@@ -182,7 +186,7 @@ where
182
186
}
183
187
}
184
188
185
- impl < ' a , Device , E > eh0:: digital:: v2:: InputPin for InputPin < ' a , Device >
189
+ impl < Device , E > eh0:: digital:: v2:: InputPin for InputPin < Device >
186
190
where
187
191
Device : MpsseCmdExecutor < Error = E > ,
188
192
E : std:: error:: Error ,
0 commit comments