@@ -22,27 +22,57 @@ pub enum TriggerEdge {
22
22
23
23
/// Extension trait providing a high-level API for the EXTI controller.
24
24
pub trait ExtiExt {
25
+ /// Starts listening to a GPIO interrupt line.
26
+ ///
27
+ /// GPIO interrupt lines are "configurable" lines, meaning that the edges
28
+ /// that should trigger the interrupt can be configured. However, they
29
+ /// require more setup than ordinary "configurable" lines, which requires
30
+ /// access to the `SYSCFG` peripheral.
25
31
fn listen_gpio ( & mut self , syscfg : & mut SYSCFG , port : gpio:: Port , line : GpioLine , edge : TriggerEdge ) ;
32
+
33
+ /// Starts listening to a configurable interrupt line.
34
+ ///
35
+ /// The edges that should trigger the interrupt can be configured with
36
+ /// `edge`.
26
37
fn listen_configurable ( & mut self , line : ConfigurableLine , edge : TriggerEdge ) ;
38
+
39
+ /// Starts listening to a "direct" interrupt line.
27
40
fn listen_direct ( & mut self , line : DirectLine ) ;
28
41
42
+ /// Disables the interrupt on `line`.
29
43
fn unlisten < L : ExtiLine > ( & mut self , line : L ) ;
30
44
45
+ /// Marks `line` as "pending".
46
+ ///
47
+ /// This will cause an interrupt if the EXTI was previously configured to
48
+ /// listen on `line`.
49
+ ///
50
+ /// If `line` is already pending, this does nothing.
31
51
fn pend < L : ExtiLine > ( line : L ) ;
52
+
53
+ /// Marks `line` as "not pending".
54
+ ///
55
+ /// This should be called from an interrupt handler to ensure that the
56
+ /// interrupt doesn't continuously fire.
32
57
fn unpend < L : ExtiLine > ( line : L ) ;
58
+
59
+ /// Returns whether `line` is currently marked as pending.
33
60
fn is_pending < L : ExtiLine > ( line : L ) -> bool ;
34
61
62
+ /// Enters a low-power mode until an EXTI interrupt occurs.
63
+ ///
64
+ /// Please note that this method will return after _any_ interrupt that can
65
+ /// wake up the microcontroller from the given power mode.
66
+ ///
67
+ /// # Panics
68
+ ///
69
+ /// Panics, if `line` is an invalid EXTI line (reserved or not defined).
70
+ /// Check the Reference Manual for a list of valid lines.
35
71
fn wait_for_irq < L , M > ( & mut self , line : L , power_mode : M )
36
72
where L : ExtiLine , M : PowerMode ;
37
73
}
38
74
39
75
impl ExtiExt for EXTI {
40
- /// Starts listening to a GPIO interrupt line.
41
- ///
42
- /// GPIO interrupt lines are "configurable" lines, meaning that the edges
43
- /// that should trigger the interrupt can be configured. However, they
44
- /// require more setup than ordinary "configurable" lines, which requires
45
- /// access to the `SYSCFG` peripheral.
46
76
// `port` and `line` are almost always constants, so make sure they can get constant-propagated
47
77
// by inlining the method. Saves ~600 Bytes in the `lptim.rs` example.
48
78
#[ inline]
@@ -122,10 +152,6 @@ impl ExtiExt for EXTI {
122
152
}
123
153
}
124
154
125
- /// Starts listening to a configurable interrupt line.
126
- ///
127
- /// The edges that should trigger the interrupt can be configured with
128
- /// `edge`.
129
155
#[ inline]
130
156
fn listen_configurable ( & mut self , line : ConfigurableLine , edge : TriggerEdge ) {
131
157
let bm: u32 = 1 << line. raw_line ( ) ;
@@ -144,7 +170,6 @@ impl ExtiExt for EXTI {
144
170
}
145
171
}
146
172
147
- /// Starts listening to a "direct" interrupt line.
148
173
#[ inline]
149
174
fn listen_direct ( & mut self , line : DirectLine ) {
150
175
let bm: u32 = 1 << line. raw_line ( ) ;
@@ -154,7 +179,6 @@ impl ExtiExt for EXTI {
154
179
}
155
180
}
156
181
157
- /// Disables the interrupt on `line`.
158
182
fn unlisten < L : ExtiLine > ( & mut self , line : L ) {
159
183
let bm = 1 << line. raw_line ( ) ;
160
184
@@ -166,12 +190,6 @@ impl ExtiExt for EXTI {
166
190
}
167
191
}
168
192
169
- /// Marks `line` as "pending".
170
- ///
171
- /// This will cause an interrupt if the EXTI was previously configured to
172
- /// listen on `line`.
173
- ///
174
- /// If `line` is already pending, this does nothing.
175
193
fn pend < L : ExtiLine > ( line : L ) {
176
194
let line = line. raw_line ( ) ;
177
195
@@ -186,7 +204,6 @@ impl ExtiExt for EXTI {
186
204
}
187
205
}
188
206
189
- /// Marks `line` as "not pending".
190
207
fn unpend < L : ExtiLine > ( line : L ) {
191
208
let line = line. raw_line ( ) ;
192
209
@@ -201,7 +218,6 @@ impl ExtiExt for EXTI {
201
218
}
202
219
}
203
220
204
- /// Returns whether `line` is currently marked as pending.
205
221
fn is_pending < L : ExtiLine > ( line : L ) -> bool {
206
222
let bm: u32 = 1 << line. raw_line ( ) ;
207
223
@@ -212,15 +228,6 @@ impl ExtiExt for EXTI {
212
228
pr & bm != 0
213
229
}
214
230
215
- /// Enters a low-power mode until an interrupt occurs.
216
- ///
217
- /// Please note that this method will return after _any_ interrupt that can
218
- /// wake up the microcontroller from the given power mode.
219
- ///
220
- /// # Panics
221
- ///
222
- /// Panics, if `line` is an invalid EXTI line (reserved or not defined).
223
- /// Check the Reference Manual for a list of valid lines.
224
231
fn wait_for_irq < L , M > ( & mut self , line : L , mut power_mode : M )
225
232
where L : ExtiLine , M : PowerMode ,
226
233
{
0 commit comments