aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-08-16 15:03:29 -0400
committerBob McWhirter <[email protected]>2021-08-16 15:15:07 -0400
commita93ed2bed6311450b2a8f17a07346eff3c9b6667 (patch)
treeabfbb7c5d952d128277a2b3b3f9d0d381312862e /examples
parentcbff0398bb8d59f881e6649e2b3776d9e00af671 (diff)
Add H7 exti button example using correct EXTI reg block offsets.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/button_exti.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs
new file mode 100644
index 000000000..ee43fa7d9
--- /dev/null
+++ b/examples/stm32h7/src/bin/button_exti.rs
@@ -0,0 +1,36 @@
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::dbgmcu::Dbgmcu;
11use embassy_stm32::exti::ExtiInput;
12use embassy_stm32::gpio::{Input, Pull};
13use embassy_stm32::Peripherals;
14use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
15use example_common::*;
16
17#[embassy::main]
18async fn main(_spawner: Spawner, p: Peripherals) {
19 info!("Hello World!");
20
21 unsafe {
22 Dbgmcu::enable_all();
23 }
24
25 let button = Input::new(p.PC13, Pull::Down);
26 let mut button = ExtiInput::new(button, p.EXTI13);
27
28 info!("Press the USER button...");
29
30 loop {
31 button.wait_for_rising_edge().await;
32 info!("Pressed!");
33 button.wait_for_falling_edge().await;
34 info!("Released!");
35 }
36}