aboutsummaryrefslogtreecommitdiff
path: root/examples/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src')
-rw-r--r--examples/src/bin/button_async.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/src/bin/button_async.rs b/examples/src/bin/button_async.rs
new file mode 100644
index 000000000..1ecec2e48
--- /dev/null
+++ b/examples/src/bin/button_async.rs
@@ -0,0 +1,28 @@
1#![no_std]
2#![no_main]
3
4use embassy_executor::Spawner;
5use embassy_time::Timer;
6use hal::gpio::{DriveStrength, Input, Pull, SlewRate};
7use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
8
9#[embassy_executor::main]
10async fn main(_spawner: Spawner) {
11 let p = hal::init(hal::config::Config::default());
12
13 defmt::info!("GPIO interrupt example");
14
15 // This button is labeled "WAKEUP" on the FRDM-MCXA276
16 let mut pin = Input::new(p.P1_7, Pull::Up, DriveStrength::Normal, SlewRate::Fast);
17
18 let mut press_count = 0u32;
19
20 loop {
21 pin.wait_for_falling_edge().await;
22
23 press_count += 1;
24
25 defmt::info!("Button pressed! Count: {}", press_count);
26 Timer::after_millis(50).await;
27 }
28}