diff options
| author | Ulf Lilleengen <[email protected]> | 2024-07-02 18:51:50 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-02 18:51:50 +0000 |
| commit | 5223923bd2f8d02d53f02329836a42f2d5ccc746 (patch) | |
| tree | d81024aa594729397f281546d0b0b0ab47e345c9 /examples | |
| parent | 14435d095f70cc25f592332ddc194dfa15117486 (diff) | |
| parent | d3f8905e938eecfe7789841c6232cb34b5f43a20 (diff) | |
Merge pull request #3111 from Eekle/feature/async_tsc
Add async API to TSC
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32u5/src/bin/tsc.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/stm32u5/src/bin/tsc.rs b/examples/stm32u5/src/bin/tsc.rs index f5593d1c4..eb15d275a 100644 --- a/examples/stm32u5/src/bin/tsc.rs +++ b/examples/stm32u5/src/bin/tsc.rs | |||
| @@ -2,10 +2,15 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::bind_interrupts; | ||
| 5 | use embassy_stm32::tsc::{self, *}; | 6 | use embassy_stm32::tsc::{self, *}; |
| 6 | use embassy_time::Timer; | 7 | use embassy_time::Timer; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 9 | ||
| 10 | bind_interrupts!(struct Irqs { | ||
| 11 | TSC => InterruptHandler<embassy_stm32::peripherals::TSC>; | ||
| 12 | }); | ||
| 13 | |||
| 9 | #[cortex_m_rt::exception] | 14 | #[cortex_m_rt::exception] |
| 10 | unsafe fn HardFault(_: &cortex_m_rt::ExceptionFrame) -> ! { | 15 | unsafe fn HardFault(_: &cortex_m_rt::ExceptionFrame) -> ! { |
| 11 | cortex_m::peripheral::SCB::sys_reset(); | 16 | cortex_m::peripheral::SCB::sys_reset(); |
| @@ -45,7 +50,7 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 45 | g7.set_io2(context.PE3, PinType::Sample); | 50 | g7.set_io2(context.PE3, PinType::Sample); |
| 46 | g7.set_io3(context.PE4, PinType::Channel); | 51 | g7.set_io3(context.PE4, PinType::Channel); |
| 47 | 52 | ||
| 48 | let mut touch_controller = tsc::Tsc::new( | 53 | let mut touch_controller = tsc::Tsc::new_async( |
| 49 | context.TSC, | 54 | context.TSC, |
| 50 | Some(g1), | 55 | Some(g1), |
| 51 | Some(g2), | 56 | Some(g2), |
| @@ -56,6 +61,7 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 56 | Some(g7), | 61 | Some(g7), |
| 57 | None, | 62 | None, |
| 58 | config, | 63 | config, |
| 64 | Irqs, | ||
| 59 | ); | 65 | ); |
| 60 | 66 | ||
| 61 | touch_controller.discharge_io(true); | 67 | touch_controller.discharge_io(true); |
| @@ -67,7 +73,7 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 67 | let mut group_seven_val = 0; | 73 | let mut group_seven_val = 0; |
| 68 | info!("Starting touch_controller interface"); | 74 | info!("Starting touch_controller interface"); |
| 69 | loop { | 75 | loop { |
| 70 | touch_controller.poll_for_acquisition(); | 76 | touch_controller.pend_for_acquisition().await; |
| 71 | touch_controller.discharge_io(true); | 77 | touch_controller.discharge_io(true); |
| 72 | Timer::after_millis(1).await; | 78 | Timer::after_millis(1).await; |
| 73 | 79 | ||
