aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4/src/bin/button_exti.rs
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2021-07-27 15:03:18 +0200
committerTimo Kröger <[email protected]>2021-07-27 15:03:18 +0200
commitdd1ec8ebec3e02af803c8d06b5c18aeda5b8cff6 (patch)
treef747a487ebdccef872bcb6e03c81a582697dcfe9 /examples/stm32f4/src/bin/button_exti.rs
parentd83cd3fffdafd8bd5773daa9374eb56e474e32e3 (diff)
Use `embassy::main` macro for stm32f4 examples
Diffstat (limited to 'examples/stm32f4/src/bin/button_exti.rs')
-rw-r--r--examples/stm32f4/src/bin/button_exti.rs30
1 files changed, 9 insertions, 21 deletions
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs
index bc48c2b12..d685b6608 100644
--- a/examples/stm32f4/src/bin/button_exti.rs
+++ b/examples/stm32f4/src/bin/button_exti.rs
@@ -8,19 +8,22 @@
8 8
9#[path = "../example_common.rs"] 9#[path = "../example_common.rs"]
10mod example_common; 10mod example_common;
11use embassy::executor::Executor; 11use defmt::panic;
12use embassy::util::Forever; 12use embassy::executor::Spawner;
13use embassy_stm32::dbgmcu::Dbgmcu; 13use embassy_stm32::dbgmcu::Dbgmcu;
14use embassy_stm32::exti::ExtiInput; 14use embassy_stm32::exti::ExtiInput;
15use embassy_stm32::gpio::{Input, Pull}; 15use embassy_stm32::gpio::{Input, Pull};
16use embassy_stm32::Peripherals;
16use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; 17use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
17use example_common::*; 18use example_common::*;
18 19
19use cortex_m_rt::entry; 20#[embassy::main]
21async fn main(_spawner: Spawner, p: Peripherals) {
22 info!("Hello World!");
20 23
21#[embassy::task] 24 unsafe {
22async fn main_task() { 25 Dbgmcu::enable_all();
23 let p = embassy_stm32::init(Default::default()); 26 }
24 27
25 let button = Input::new(p.PC13, Pull::Down); 28 let button = Input::new(p.PC13, Pull::Down);
26 let mut button = ExtiInput::new(button, p.EXTI13); 29 let mut button = ExtiInput::new(button, p.EXTI13);
@@ -34,18 +37,3 @@ async fn main_task() {
34 info!("Released!"); 37 info!("Released!");
35 } 38 }
36} 39}
37
38static EXECUTOR: Forever<Executor> = Forever::new();
39
40#[entry]
41fn main() -> ! {
42 info!("Hello World!");
43
44 unsafe { Dbgmcu::enable_all() }
45
46 let executor = EXECUTOR.put(Executor::new());
47
48 executor.run(|spawner| {
49 unwrap!(spawner.spawn(main_task()));
50 })
51}