diff options
| author | Timo Kröger <[email protected]> | 2024-03-07 11:17:39 +0100 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2024-03-12 08:14:42 +0100 |
| commit | 4d0e3838168a7447b3580135ef78d65baa578933 (patch) | |
| tree | e012b234d5242b0b089195b8e21f3d19c43045b4 /examples | |
| parent | a3b12226170d6b1a9ded47cc043cc09489cee278 (diff) | |
[UCPD] Prepare for PD communication implementation
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32g4/src/bin/usb_c_pd.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/stm32g4/src/bin/usb_c_pd.rs b/examples/stm32g4/src/bin/usb_c_pd.rs index 7a0065087..1443cb773 100644 --- a/examples/stm32g4/src/bin/usb_c_pd.rs +++ b/examples/stm32g4/src/bin/usb_c_pd.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, Format}; | 4 | use defmt::{info, Format}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::ucpd::{self, CcPull, CcVState, Ucpd}; | 6 | use embassy_stm32::ucpd::{self, CcPull, CcSel, CcVState, Ucpd}; |
| 7 | use embassy_stm32::Config; | 7 | use embassy_stm32::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 _}; |
| @@ -56,5 +56,18 @@ async fn main(_spawner: Spawner) { | |||
| 56 | let cable_orientation = wait_attached(&mut ucpd).await; | 56 | let cable_orientation = wait_attached(&mut ucpd).await; |
| 57 | info!("USB cable connected, orientation: {}", cable_orientation); | 57 | info!("USB cable connected, orientation: {}", cable_orientation); |
| 58 | 58 | ||
| 59 | let cc_sel = match cable_orientation { | ||
| 60 | CableOrientation::Normal => { | ||
| 61 | info!("Starting PD communication on CC1 pin"); | ||
| 62 | CcSel::CC1 | ||
| 63 | } | ||
| 64 | CableOrientation::Flipped => { | ||
| 65 | info!("Starting PD communication on CC2 pin"); | ||
| 66 | CcSel::CC2 | ||
| 67 | } | ||
| 68 | CableOrientation::DebugAccessoryMode => panic!("No PD communication in DAM"), | ||
| 69 | }; | ||
| 70 | let (mut _rx, mut _tx) = ucpd.pd(p.DMA1_CH1, p.DMA1_CH2, cc_sel); | ||
| 71 | |||
| 59 | loop {} | 72 | loop {} |
| 60 | } | 73 | } |
