diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-04-13 02:13:41 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-04-14 22:29:07 +0200 |
| commit | 65c085ce910f50903bc5c41ca82eda989810f855 (patch) | |
| tree | 2dde97f356234411a1c5d780eba9e55a7f90f8ff /examples/stm32u0/src/bin/button_exti.rs | |
| parent | 87b79d449916b26d0d29b6247ae366a80c02cfa5 (diff) | |
Add stm32u0 support.
Diffstat (limited to 'examples/stm32u0/src/bin/button_exti.rs')
| -rw-r--r-- | examples/stm32u0/src/bin/button_exti.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/stm32u0/src/bin/button_exti.rs b/examples/stm32u0/src/bin/button_exti.rs new file mode 100644 index 000000000..34a08bbc6 --- /dev/null +++ b/examples/stm32u0/src/bin/button_exti.rs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_stm32::exti::ExtiInput; | ||
| 7 | use embassy_stm32::gpio::Pull; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async fn main(_spawner: Spawner) { | ||
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | info!("Hello World!"); | ||
| 14 | |||
| 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); | ||
| 16 | |||
| 17 | info!("Press the USER button..."); | ||
| 18 | |||
| 19 | loop { | ||
| 20 | button.wait_for_falling_edge().await; | ||
| 21 | info!("Pressed!"); | ||
| 22 | button.wait_for_rising_edge().await; | ||
| 23 | info!("Released!"); | ||
| 24 | } | ||
| 25 | } | ||
