aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32g0/src/bin/button_exti.rs
diff options
context:
space:
mode:
authorBen Gamari <[email protected]>2021-07-31 10:01:32 -0400
committerDario Nieuwenhuis <[email protected]>2021-08-20 01:28:50 +0200
commitee841499ee8ee4d073930b2645eb70a0e652b383 (patch)
treefe44a0b81be02994c5d0d9db8a0e74fd5001a3e8 /examples/stm32g0/src/bin/button_exti.rs
parente2f71ffbbdeac4f64b0468fc7e93452388c16eee (diff)
Add STM32G0 examples
Diffstat (limited to 'examples/stm32g0/src/bin/button_exti.rs')
-rw-r--r--examples/stm32g0/src/bin/button_exti.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs
new file mode 100644
index 000000000..c55d6408c
--- /dev/null
+++ b/examples/stm32g0/src/bin/button_exti.rs
@@ -0,0 +1,31 @@
1#![no_std]
2#![no_main]
3#![feature(trait_alias)]
4#![feature(type_alias_impl_trait)]
5#![allow(incomplete_features)]
6
7#[path = "../example_common.rs"]
8mod example_common;
9use embassy::executor::Spawner;
10use embassy_stm32::exti::ExtiInput;
11use embassy_stm32::gpio::{Input, Pull};
12use embassy_stm32::Peripherals;
13use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
14use example_common::*;
15
16#[embassy::main]
17async fn main(_spawner: Spawner, p: Peripherals) {
18 info!("Hello World!");
19
20 let button = Input::new(p.PC13, Pull::Up);
21 let mut button = ExtiInput::new(button, p.EXTI13);
22
23 info!("Press the USER button...");
24
25 loop {
26 button.wait_for_falling_edge().await;
27 info!("Pressed!");
28 button.wait_for_rising_edge().await;
29 info!("Released!");
30 }
31}