aboutsummaryrefslogtreecommitdiff
path: root/examples/mcxa/src/bin/button_async.rs
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-12-11 09:08:50 -0600
committerGitHub <[email protected]>2025-12-11 09:08:50 -0600
commit1aadce76847a7686bf66e3a6532e18e05042f78a (patch)
treeca42d80e784a6746065bd4e0c676db3ef0f10b93 /examples/mcxa/src/bin/button_async.rs
parent52a9b08f0ca13d23bfb039c884a9101997c10567 (diff)
parentf650afc33b2d6b39116f27c6545c5f2d9e3c7d06 (diff)
Merge branch 'main' into main
Diffstat (limited to 'examples/mcxa/src/bin/button_async.rs')
-rw-r--r--examples/mcxa/src/bin/button_async.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/mcxa/src/bin/button_async.rs b/examples/mcxa/src/bin/button_async.rs
new file mode 100644
index 000000000..6cc7b62cd
--- /dev/null
+++ b/examples/mcxa/src/bin/button_async.rs
@@ -0,0 +1,29 @@
1#![no_std]
2#![no_main]
3
4use embassy_executor::Spawner;
5use embassy_time::Timer;
6use hal::gpio::{Input, Pull};
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 // The board already has a 10K pullup
17 let mut pin = Input::new(p.P1_7, Pull::Disabled);
18
19 let mut press_count = 0u32;
20
21 loop {
22 pin.wait_for_falling_edge().await;
23
24 press_count += 1;
25
26 defmt::info!("Button pressed! Count: {}", press_count);
27 Timer::after_millis(50).await;
28 }
29}