aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/ucpd.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/embassy-stm32/src/ucpd.rs b/embassy-stm32/src/ucpd.rs
index 89e2f5d49..cbec85ff3 100644
--- a/embassy-stm32/src/ucpd.rs
+++ b/embassy-stm32/src/ucpd.rs
@@ -169,6 +169,9 @@ impl<'d, T: Instance> Ucpd<'d, T> {
169 // Enable hard reset receive interrupt. 169 // Enable hard reset receive interrupt.
170 r.imr().modify(|w| w.set_rxhrstdetie(true)); 170 r.imr().modify(|w| w.set_rxhrstdetie(true));
171 171
172 // Enable PD packet reception
173 r.cr().modify(|w| w.set_phyrxen(true));
174
172 // Both parts must be dropped before the peripheral can be disabled. 175 // Both parts must be dropped before the peripheral can be disabled.
173 T::state().drop_not_ready.store(true, Ordering::Relaxed); 176 T::state().drop_not_ready.store(true, Ordering::Relaxed);
174 177
@@ -319,6 +322,7 @@ pub struct PdPhy<'d, T: Instance> {
319 322
320impl<'d, T: Instance> Drop for PdPhy<'d, T> { 323impl<'d, T: Instance> Drop for PdPhy<'d, T> {
321 fn drop(&mut self) { 324 fn drop(&mut self) {
325 T::REGS.cr().modify(|w| w.set_phyrxen(false));
322 // Check if the Type-C part was dropped already. 326 // Check if the Type-C part was dropped already.
323 let drop_not_ready = &T::state().drop_not_ready; 327 let drop_not_ready = &T::state().drop_not_ready;
324 if drop_not_ready.load(Ordering::Relaxed) { 328 if drop_not_ready.load(Ordering::Relaxed) {
@@ -350,9 +354,7 @@ impl<'d, T: Instance> PdPhy<'d, T> {
350 w.set_rxmsgendcf(true); 354 w.set_rxmsgendcf(true);
351 }); 355 });
352 356
353 r.cr().modify(|w| w.set_phyrxen(true));
354 let _on_drop = OnDrop::new(|| { 357 let _on_drop = OnDrop::new(|| {
355 r.cr().modify(|w| w.set_phyrxen(false));
356 Self::enable_rx_interrupt(false); 358 Self::enable_rx_interrupt(false);
357 }); 359 });
358 360