Skip to content

Commit 9a488ec

Browse files
committed
Add check_interrupt method for GPIO pins
1 parent 7db793f commit 9a488ec

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- Reexport PAC as `pac` for consistency with other crates, consider `stm32` virtually deprecated
1313
- Added external interrupt (EXTI) support for output pins
14+
- Added `check_interrupt` method for GPIO pins
1415

1516
## [v0.8.3] - 2020-06-12
1617

src/gpio.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub trait ExtiPin {
9090
fn enable_interrupt(&mut self, exti: &mut EXTI);
9191
fn disable_interrupt(&mut self, exti: &mut EXTI);
9292
fn clear_interrupt_pending_bit(&mut self);
93+
fn check_interrupt(&self) -> bool;
9394
}
9495

9596
macro_rules! exti_erased {
@@ -163,6 +164,11 @@ macro_rules! exti_erased {
163164
fn clear_interrupt_pending_bit(&mut self) {
164165
unsafe { (*EXTI::ptr()).pr.write(|w| w.bits(1 << self.i)) };
165166
}
167+
168+
/// Reads the interrupt pending bit for this pin
169+
fn check_interrupt(&self) -> bool {
170+
unsafe { ((*EXTI::ptr()).pr.read().bits() & (1 << self.i)) != 0 }
171+
}
166172
}
167173
};
168174
}
@@ -220,6 +226,11 @@ macro_rules! exti {
220226
fn clear_interrupt_pending_bit(&mut self) {
221227
unsafe { (*EXTI::ptr()).pr.write(|w| w.bits(1 << $i)) };
222228
}
229+
230+
/// Reads the interrupt pending bit for this pin
231+
fn check_interrupt(&self) -> bool {
232+
unsafe { ((*EXTI::ptr()).pr.read().bits() & (1 << $i)) != 0 }
233+
}
223234
}
224235
};
225236
}

0 commit comments

Comments
 (0)