aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f0/src/bin/button_controlled_blink.rs
diff options
context:
space:
mode:
authorWillaWillNot <[email protected]>2025-11-20 16:24:15 -0500
committerWillaWillNot <[email protected]>2025-11-21 16:36:15 -0500
commit623623a25f213f76de932eaf4458c3120823d205 (patch)
treea1039bcdb29488180f4fe669f16ac0b33370404e /examples/stm32f0/src/bin/button_controlled_blink.rs
parentde4d7f56473df58d9b3fa8ec4917ab86550005ae (diff)
Updated documentation, fixed EXTI definition issues with chips that have touch sensing, updated examples, added generation of convenience method to bind_interrupts for easier type erasure
Diffstat (limited to 'examples/stm32f0/src/bin/button_controlled_blink.rs')
-rw-r--r--examples/stm32f0/src/bin/button_controlled_blink.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/stm32f0/src/bin/button_controlled_blink.rs b/examples/stm32f0/src/bin/button_controlled_blink.rs
index 0b678af01..f57d5d200 100644
--- a/examples/stm32f0/src/bin/button_controlled_blink.rs
+++ b/examples/stm32f0/src/bin/button_controlled_blink.rs
@@ -8,13 +8,20 @@ use core::sync::atomic::{AtomicU32, Ordering};
8use defmt::info; 8use defmt::info;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_stm32::Peri; 10use embassy_stm32::Peri;
11use embassy_stm32::exti::ExtiInput; 11use embassy_stm32::bind_interrupts;
12use embassy_stm32::exti::{self, ExtiInput};
12use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; 13use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed};
14use embassy_stm32::interrupt;
13use embassy_time::Timer; 15use embassy_time::Timer;
14use {defmt_rtt as _, panic_probe as _}; 16use {defmt_rtt as _, panic_probe as _};
15 17
16static BLINK_MS: AtomicU32 = AtomicU32::new(0); 18static BLINK_MS: AtomicU32 = AtomicU32::new(0);
17 19
20bind_interrupts!(
21 pub struct Irqs{
22 EXTI4_15 => exti::InterruptHandler<interrupt::typelevel::EXTI4_15>;
23});
24
18#[embassy_executor::task] 25#[embassy_executor::task]
19async fn led_task(led: Peri<'static, AnyPin>) { 26async fn led_task(led: Peri<'static, AnyPin>) {
20 // Configure the LED pin as a push pull output and obtain handler. 27 // Configure the LED pin as a push pull output and obtain handler.
@@ -37,7 +44,12 @@ async fn main(spawner: Spawner) {
37 44
38 // Configure the button pin and obtain handler. 45 // Configure the button pin and obtain handler.
39 // On the Nucleo F091RC there is a button connected to pin PC13. 46 // On the Nucleo F091RC there is a button connected to pin PC13.
40 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None); 47 let mut button = ExtiInput::new(
48 p.PC13,
49 p.EXTI13,
50 Pull::None,
51 Irqs::as_any::<interrupt::typelevel::EXTI4_15, exti::InterruptHandler<interrupt::typelevel::EXTI4_15>>(),
52 );
41 53
42 // Create and initialize a delay variable to manage delay loop 54 // Create and initialize a delay variable to manage delay loop
43 let mut del_var = 2000; 55 let mut del_var = 2000;