diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-08-19 22:17:17 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-08-19 22:17:17 +0200 |
| commit | ec51880e28d48269ae1ce8b037305f4f7f182c84 (patch) | |
| tree | b9283065cbaf692c17dddba587a862003dc266ce /examples | |
| parent | dd62790f3630335b905743627a9d2e3c40cb6e4f (diff) | |
stm32/exti: unify all versions into single impl
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wb55/src/bin/button_exti.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/stm32wb55/src/bin/button_exti.rs b/examples/stm32wb55/src/bin/button_exti.rs new file mode 100644 index 000000000..92a310c7a --- /dev/null +++ b/examples/stm32wb55/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"] | ||
| 8 | mod example_common; | ||
| 9 | use embassy::executor::Spawner; | ||
| 10 | use embassy_stm32::dbgmcu::Dbgmcu; | ||
| 11 | use embassy_stm32::exti::ExtiInput; | ||
| 12 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 13 | use embassy_stm32::Peripherals; | ||
| 14 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 15 | use example_common::*; | ||
| 16 | |||
| 17 | #[embassy::main] | ||
| 18 | async 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.PC4, Pull::Up); | ||
| 26 | let mut button = ExtiInput::new(button, p.EXTI4); | ||
| 27 | |||
| 28 | info!("Press the USER button..."); | ||
| 29 | |||
| 30 | loop { | ||
| 31 | button.wait_for_falling_edge().await; | ||
| 32 | info!("Pressed!"); | ||
| 33 | button.wait_for_rising_edge().await; | ||
| 34 | info!("Released!"); | ||
| 35 | } | ||
| 36 | } | ||
