diff options
| author | Ben Gamari <[email protected]> | 2021-07-31 10:01:32 -0400 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-08-20 01:28:50 +0200 |
| commit | ee841499ee8ee4d073930b2645eb70a0e652b383 (patch) | |
| tree | fe44a0b81be02994c5d0d9db8a0e74fd5001a3e8 /examples/stm32g0/src/bin/button_exti.rs | |
| parent | e2f71ffbbdeac4f64b0468fc7e93452388c16eee (diff) | |
Add STM32G0 examples
Diffstat (limited to 'examples/stm32g0/src/bin/button_exti.rs')
| -rw-r--r-- | examples/stm32g0/src/bin/button_exti.rs | 31 |
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"] | ||
| 8 | mod example_common; | ||
| 9 | use embassy::executor::Spawner; | ||
| 10 | use embassy_stm32::exti::ExtiInput; | ||
| 11 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 12 | use embassy_stm32::Peripherals; | ||
| 13 | use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge}; | ||
| 14 | use example_common::*; | ||
| 15 | |||
| 16 | #[embassy::main] | ||
| 17 | async 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 | } | ||
