diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32g4/src/bin/usb_c_pd.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/stm32g4/src/bin/usb_c_pd.rs b/examples/stm32g4/src/bin/usb_c_pd.rs index fd2400bd5..14abd542f 100644 --- a/examples/stm32g4/src/bin/usb_c_pd.rs +++ b/examples/stm32g4/src/bin/usb_c_pd.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::{info, Format}; | 4 | use defmt::{error, info, Format}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::ucpd::{self, CcPull, CcSel, CcVState, Ucpd}; | 6 | use embassy_stm32::ucpd::{self, CcPull, CcSel, CcVState, Ucpd}; |
| 7 | use embassy_stm32::Config; | 7 | use embassy_stm32::Config; |
| @@ -69,5 +69,12 @@ async fn main(_spawner: Spawner) { | |||
| 69 | }; | 69 | }; |
| 70 | let mut pd_phy = ucpd.pd_phy(p.DMA1_CH1, p.DMA1_CH2, cc_sel); | 70 | let mut pd_phy = ucpd.pd_phy(p.DMA1_CH1, p.DMA1_CH2, cc_sel); |
| 71 | 71 | ||
| 72 | loop {} | 72 | loop { |
| 73 | // Enough space for the longest non-extended data message. | ||
| 74 | let mut buf = [0_u8; 30]; | ||
| 75 | match pd_phy.receive(buf.as_mut()).await { | ||
| 76 | Ok(n) => info!("USB PD RX: {=[u8]:?}", &buf[..n]), | ||
| 77 | Err(e) => error!("USB PD RX: {}", e), | ||
| 78 | } | ||
| 79 | } | ||
| 73 | } | 80 | } |
