diff options
| author | Timo Kröger <[email protected]> | 2024-03-12 20:38:37 +0100 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2024-03-14 21:55:05 +0100 |
| commit | e95e95ac7a00ca014b23f6ac57ecffce7fc6ffa0 (patch) | |
| tree | ade463c0e01e34f828724e415830553d097f20ad /examples/stm32g4 | |
| parent | 30cdc6c9c53837e91f92d24e9861b525f54bc65b (diff) | |
[UCPD] Take interrupt in constructor and enable it
Diffstat (limited to 'examples/stm32g4')
| -rw-r--r-- | examples/stm32g4/src/bin/usb_c_pd.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/stm32g4/src/bin/usb_c_pd.rs b/examples/stm32g4/src/bin/usb_c_pd.rs index 0e80840df..c850b2753 100644 --- a/examples/stm32g4/src/bin/usb_c_pd.rs +++ b/examples/stm32g4/src/bin/usb_c_pd.rs | |||
| @@ -4,10 +4,14 @@ | |||
| 4 | use defmt::{error, info, Format}; | 4 | use defmt::{error, info, Format}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; | 6 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; |
| 7 | use embassy_stm32::Config; | 7 | use embassy_stm32::{bind_interrupts, peripherals, Config}; |
| 8 | use embassy_time::{with_timeout, Duration}; | 8 | use embassy_time::{with_timeout, Duration}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | ||
| 12 | UCPD1 => ucpd::InterruptHandler<peripherals::UCPD1>; | ||
| 13 | }); | ||
| 14 | |||
| 11 | #[derive(Debug, Format)] | 15 | #[derive(Debug, Format)] |
| 12 | enum CableOrientation { | 16 | enum CableOrientation { |
| 13 | Normal, | 17 | Normal, |
| @@ -50,7 +54,7 @@ async fn main(_spawner: Spawner) { | |||
| 50 | 54 | ||
| 51 | info!("Hello World!"); | 55 | info!("Hello World!"); |
| 52 | 56 | ||
| 53 | let mut ucpd = Ucpd::new(p.UCPD1, p.PB6, p.PB4); | 57 | let mut ucpd = Ucpd::new(p.UCPD1, Irqs {}, p.PB6, p.PB4); |
| 54 | ucpd.cc_phy().set_pull(CcPull::Sink); | 58 | ucpd.cc_phy().set_pull(CcPull::Sink); |
| 55 | 59 | ||
| 56 | info!("Waiting for USB connection..."); | 60 | info!("Waiting for USB connection..."); |
