aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f0/src/bin/button_controlled_blink.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32f0/src/bin/button_controlled_blink.rs')
-rw-r--r--examples/stm32f0/src/bin/button_controlled_blink.rs11
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
8use defmt::info; 8use defmt::info;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_stm32::exti::ExtiInput; 10use embassy_stm32::exti::{self, ExtiInput};
11use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; 11use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed};
12use embassy_stm32::Peri; 12use embassy_stm32::{Peri, bind_interrupts, interrupt};
13use embassy_time::Timer; 13use embassy_time::Timer;
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
16static BLINK_MS: AtomicU32 = AtomicU32::new(0); 16static BLINK_MS: AtomicU32 = AtomicU32::new(0);
17 17
18bind_interrupts!(
19 pub struct Irqs{
20 EXTI4_15 => exti::InterruptHandler<interrupt::typelevel::EXTI4_15>;
21});
22
18#[embassy_executor::task] 23#[embassy_executor::task]
19async fn led_task(led: Peri<'static, AnyPin>) { 24async 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;