aboutsummaryrefslogtreecommitdiff
path: root/examples/mcxa/src/bin/button_async.rs
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2025-12-04 18:46:39 +0100
committerJames Munns <[email protected]>2025-12-04 18:47:31 +0100
commitc3bc8fe8c0db112e5f2f66580104fc49b02890d2 (patch)
treeeea7adc15021697ea980289edd6235daaa12d6ee /examples/mcxa/src/bin/button_async.rs
parent5182b2ed54f991b40b45fd2de75f597358ff9c3e (diff)
parent277ab0d2e8714edf37a0ee84cda1059d9944ecef (diff)
Import embassy-mcxa repo
Merge remote-tracking branch 'james-e-mcxa/james/upstream' into james/upstream-mcxa
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}