diff options
| author | Timo Kröger <[email protected]> | 2021-07-27 15:03:18 +0200 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2021-07-27 15:03:18 +0200 |
| commit | dd1ec8ebec3e02af803c8d06b5c18aeda5b8cff6 (patch) | |
| tree | f747a487ebdccef872bcb6e03c81a582697dcfe9 /examples/stm32f4/src/bin/button_exti.rs | |
| parent | d83cd3fffdafd8bd5773daa9374eb56e474e32e3 (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.rs | 30 |
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"] |
| 10 | mod example_common; | 10 | mod example_common; |
| 11 | use embassy::executor::Executor; | 11 | use defmt::panic; |
| 12 | use embassy::util::Forever; | 12 | use embassy::executor::Spawner; |
| 13 | use embassy_stm32::dbgmcu::Dbgmcu; | 13 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 14 | use embassy_stm32::exti::ExtiInput; | 14 | use embassy_stm32::exti::ExtiInput; |
| 15 | use embassy_stm32::gpio::{Input, Pull}; | 15 | use embassy_stm32::gpio::{Input, Pull}; |
| 16 | use embassy_stm32::Peripherals; | ||
| 16 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | 17 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; |
| 17 | use example_common::*; | 18 | use example_common::*; |
| 18 | 19 | ||
| 19 | use cortex_m_rt::entry; | 20 | #[embassy::main] |
| 21 | async fn main(_spawner: Spawner, p: Peripherals) { | ||
| 22 | info!("Hello World!"); | ||
| 20 | 23 | ||
| 21 | #[embassy::task] | 24 | unsafe { |
| 22 | async 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 | |||
| 38 | static EXECUTOR: Forever<Executor> = Forever::new(); | ||
| 39 | |||
| 40 | #[entry] | ||
| 41 | fn 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 | } | ||
