diff options
| author | Raul Alimbekov <[email protected]> | 2025-12-16 09:05:22 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-16 09:05:22 +0300 |
| commit | c9a04b4b732b7a3b696eb8223664c1a7942b1875 (patch) | |
| tree | 6dbe5c02e66eed8d8762f13f95afd24f8db2b38c /examples/stm32f0/src/bin/button_controlled_blink.rs | |
| parent | cde24a3ef1117653ba5ed4184102b33f745782fb (diff) | |
| parent | 5ae6e060ec1c90561719aabdc29d5b6e7b8b0a82 (diff) | |
Merge branch 'main' into main
Diffstat (limited to 'examples/stm32f0/src/bin/button_controlled_blink.rs')
| -rw-r--r-- | examples/stm32f0/src/bin/button_controlled_blink.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/stm32f0/src/bin/button_controlled_blink.rs b/examples/stm32f0/src/bin/button_controlled_blink.rs index f232e3290..9c7bf8a95 100644 --- a/examples/stm32f0/src/bin/button_controlled_blink.rs +++ b/examples/stm32f0/src/bin/button_controlled_blink.rs | |||
| @@ -7,14 +7,19 @@ use core::sync::atomic::{AtomicU32, Ordering}; | |||
| 7 | 7 | ||
| 8 | use defmt::info; | 8 | use defmt::info; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::{self, ExtiInput}; |
| 11 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peri; | 12 | use embassy_stm32::{Peri, bind_interrupts, interrupt}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); | 16 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); |
| 17 | 17 | ||
| 18 | bind_interrupts!( | ||
| 19 | pub struct Irqs{ | ||
| 20 | EXTI4_15 => exti::InterruptHandler<interrupt::typelevel::EXTI4_15>; | ||
| 21 | }); | ||
| 22 | |||
| 18 | #[embassy_executor::task] | 23 | #[embassy_executor::task] |
| 19 | async fn led_task(led: Peri<'static, AnyPin>) { | 24 | async fn led_task(led: Peri<'static, AnyPin>) { |
| 20 | // Configure the LED pin as a push pull output and obtain handler. | 25 | // Configure the LED pin as a push pull output and obtain handler. |
| @@ -37,7 +42,7 @@ async fn main(spawner: Spawner) { | |||
| 37 | 42 | ||
| 38 | // Configure the button pin and obtain handler. | 43 | // Configure the button pin and obtain handler. |
| 39 | // On the Nucleo F091RC there is a button connected to pin PC13. | 44 | // On the Nucleo F091RC there is a button connected to pin PC13. |
| 40 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None); | 45 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None, Irqs); |
| 41 | 46 | ||
| 42 | // Create and initialize a delay variable to manage delay loop | 47 | // Create and initialize a delay variable to manage delay loop |
| 43 | let mut del_var = 2000; | 48 | let mut del_var = 2000; |
