diff options
| author | WillaWillNot <[email protected]> | 2025-11-20 16:24:15 -0500 |
|---|---|---|
| committer | WillaWillNot <[email protected]> | 2025-11-21 16:36:15 -0500 |
| commit | 623623a25f213f76de932eaf4458c3120823d205 (patch) | |
| tree | a1039bcdb29488180f4fe669f16ac0b33370404e /examples/stm32f0/src/bin/button_controlled_blink.rs | |
| parent | de4d7f56473df58d9b3fa8ec4917ab86550005ae (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.rs | 16 |
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}; | |||
| 8 | use defmt::info; | 8 | use defmt::info; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::Peri; | 10 | use embassy_stm32::Peri; |
| 11 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::bind_interrupts; |
| 12 | use embassy_stm32::exti::{self, ExtiInput}; | ||
| 12 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; | 13 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; |
| 14 | use embassy_stm32::interrupt; | ||
| 13 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 17 | ||
| 16 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); | 18 | static BLINK_MS: AtomicU32 = AtomicU32::new(0); |
| 17 | 19 | ||
| 20 | bind_interrupts!( | ||
| 21 | pub struct Irqs{ | ||
| 22 | EXTI4_15 => exti::InterruptHandler<interrupt::typelevel::EXTI4_15>; | ||
| 23 | }); | ||
| 24 | |||
| 18 | #[embassy_executor::task] | 25 | #[embassy_executor::task] |
| 19 | async fn led_task(led: Peri<'static, AnyPin>) { | 26 | async 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; |
