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/stm32g0/src/bin/button_exti.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/stm32g0/src/bin/button_exti.rs')
| -rw-r--r-- | examples/stm32g0/src/bin/button_exti.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 34a08bbc6..dbc9e2f50 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs | |||
| @@ -3,16 +3,28 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::bind_interrupts; |
| 7 | use embassy_stm32::exti::{self, ExtiInput}; | ||
| 7 | use embassy_stm32::gpio::Pull; | 8 | use embassy_stm32::gpio::Pull; |
| 9 | use embassy_stm32::interrupt; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 11 | ||
| 12 | bind_interrupts!( | ||
| 13 | pub struct Irqs{ | ||
| 14 | EXTI4_15 => exti::InterruptHandler<interrupt::typelevel::EXTI4_15>; | ||
| 15 | }); | ||
| 16 | |||
| 10 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 14 | 21 | ||
| 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); | 22 | let mut button = ExtiInput::new( |
| 23 | p.PC13, | ||
| 24 | p.EXTI13, | ||
| 25 | Pull::Up, | ||
| 26 | Irqs::as_any::<interrupt::typelevel::EXTI4_15, exti::InterruptHandler<interrupt::typelevel::EXTI4_15>>(), | ||
| 27 | ); | ||
| 16 | 28 | ||
| 17 | info!("Press the USER button..."); | 29 | info!("Press the USER button..."); |
| 18 | 30 | ||
