aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Salzedo <[email protected]>2021-03-24 12:36:29 -0700
committerJoshua Salzedo <[email protected]>2021-03-24 13:19:36 -0700
commit62009150bd3655f36c3f6247d5d339258212cb2f (patch)
tree77009641f9e92384b42acaa8e794f59bc0ee760c
parenta9e099c2151221f66571ab0001b77fe639c149ee (diff)
Document embassy::util::InterruptFuture
-rw-r--r--embassy/src/util/signal.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs
index 41e27d4ca..e3c5fad1d 100644
--- a/embassy/src/util/signal.rs
+++ b/embassy/src/util/signal.rs
@@ -80,6 +80,25 @@ unsafe impl cortex_m::interrupt::Nr for NrWrap {
80 } 80 }
81} 81}
82 82
83/// Creates a future that completes when the specified Interrupt is triggered.
84///
85/// The input handler is unregistered when this Future is dropped.
86///
87/// Example:
88/// ``` no_compile
89/// use embassy::traits::*;
90/// use embassy::util::InterruptFuture;
91/// use embassy::executor::task;
92/// use embassy_stm32f4::interrupt; // Adjust this to your MCU's embassy HAL.
93/// #[task]
94/// async fn demo_interrupt_future() {
95/// // Using STM32f446 interrupt names, adjust this to your application as necessary.
96/// // Wait for TIM2 to tick.
97/// let mut tim2_interrupt = interrupt::take!(TIM2);
98/// InterruptFuture::new(&mut tim2_interrupt).await;
99/// // TIM2 interrupt went off, do something...
100/// }
101/// ```
83pub struct InterruptFuture<'a, I: Interrupt> { 102pub struct InterruptFuture<'a, I: Interrupt> {
84 interrupt: &'a mut I, 103 interrupt: &'a mut I,
85} 104}