aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2024-03-07 19:54:55 +0100
committerTimo Kröger <[email protected]>2024-03-12 08:14:42 +0100
commitb7972048a1642679392b2a1dfc976881205fd23b (patch)
tree7ea8b90e5177070130430eb5c05c98d0c62f30d9 /examples
parent5e271ff31b55b339d4321af4b2c8a096bf153d4b (diff)
[UCPD] Improve example and defmt Format for enums
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32g4/src/bin/usb_c_pd.rs11
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
4use defmt::{info, Format}; 4use defmt::{error, info, Format};
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::ucpd::{self, CcPull, CcSel, CcVState, Ucpd}; 6use embassy_stm32::ucpd::{self, CcPull, CcSel, CcVState, Ucpd};
7use embassy_stm32::Config; 7use 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}