diff options
| author | Timo Kröger <[email protected]> | 2024-03-07 19:54:55 +0100 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2024-03-12 08:14:42 +0100 |
| commit | b7972048a1642679392b2a1dfc976881205fd23b (patch) | |
| tree | 7ea8b90e5177070130430eb5c05c98d0c62f30d9 /examples | |
| parent | 5e271ff31b55b339d4321af4b2c8a096bf153d4b (diff) | |
[UCPD] Improve example and defmt Format for enums
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 | } |
