aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wl/src/bin/button_exti.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32wl/src/bin/button_exti.rs')
-rw-r--r--examples/stm32wl/src/bin/button_exti.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs
new file mode 100644
index 000000000..9a427c2d3
--- /dev/null
+++ b/examples/stm32wl/src/bin/button_exti.rs
@@ -0,0 +1,28 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use defmt_rtt as _; // global logger
7use embassy::executor::Spawner;
8use embassy_stm32::exti::ExtiInput;
9use embassy_stm32::gpio::{Input, Pull};
10use embassy_stm32::Peripherals;
11use panic_probe as _;
12
13#[embassy::main]
14async fn main(_spawner: Spawner, p: Peripherals) {
15 info!("Hello World!");
16
17 let button = Input::new(p.PA0, Pull::Up);
18 let mut button = ExtiInput::new(button, p.EXTI0);
19
20 info!("Press the USER button...");
21
22 loop {
23 button.wait_for_falling_edge().await;
24 info!("Pressed!");
25 button.wait_for_rising_edge().await;
26 info!("Released!");
27 }
28}