diff options
| author | Ulf Lilleengen <[email protected]> | 2021-08-17 14:25:18 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-08-17 16:22:47 +0200 |
| commit | 4df63f5379206ebb5d09d5017e19498f0a1713af (patch) | |
| tree | bfc39f01fe74a3068e50e189375ef6afef846ead /examples | |
| parent | 61409e2fb6798a8474d32df581e1cabfa04ec565 (diff) | |
Add per-core EXTI support
* Generate a core index put into the PAC for the peripherals to use as
index into registers.
* Add EXTI v2 which uses CORE_INDEX to index exti registers
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wl55/src/bin/button_exti.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/stm32wl55/src/bin/button_exti.rs b/examples/stm32wl55/src/bin/button_exti.rs new file mode 100644 index 000000000..2f6e55115 --- /dev/null +++ b/examples/stm32wl55/src/bin/button_exti.rs | |||
| @@ -0,0 +1,34 @@ | |||
| 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 { Dbgmcu::enable_all() }; | ||
| 22 | |||
| 23 | let button = Input::new(p.PA0, Pull::Up); | ||
| 24 | let mut button = ExtiInput::new(button, p.EXTI0); | ||
| 25 | |||
| 26 | info!("Press the USER button..."); | ||
| 27 | |||
| 28 | loop { | ||
| 29 | button.wait_for_falling_edge().await; | ||
| 30 | info!("Pressed!"); | ||
| 31 | button.wait_for_rising_edge().await; | ||
| 32 | info!("Released!"); | ||
| 33 | } | ||
| 34 | } | ||
