aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2024-03-12 22:43:36 +0100
committerTimo Kröger <[email protected]>2024-03-14 21:55:05 +0100
commit88d1d38be787ff7e742dfde53cf8b527a6a07dad (patch)
treef9a4fe66a3bc1ff56b4cb0f3e9c013ad75cf101d
parentb634f8f5111001a51a8a80559aeab11e8209d65f (diff)
[UCPD] RXORDSETEN can only be modified when disabled
-rw-r--r--embassy-stm32/src/ucpd.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/embassy-stm32/src/ucpd.rs b/embassy-stm32/src/ucpd.rs
index 54d4bb132..d251b1c72 100644
--- a/embassy-stm32/src/ucpd.rs
+++ b/embassy-stm32/src/ucpd.rs
@@ -124,6 +124,14 @@ impl<'d, T: Instance> Ucpd<'d, T> {
124 // 1.75us * 17 = ~30us 124 // 1.75us * 17 = ~30us
125 w.set_ifrgap(17 - 1); 125 w.set_ifrgap(17 - 1);
126 126
127 // TODO: Currently only hard reset and SOP messages can be received.
128 // UNDOCUMENTED: This register can only be written while UCPDEN=0 (found by testing).
129 w.set_rxordseten(0b1001);
130
131 // Enable DMA
132 w.set_txdmaen(true);
133 w.set_rxdmaen(true);
134
127 w.set_ucpden(true); 135 w.set_ucpden(true);
128 }); 136 });
129 137
@@ -150,15 +158,6 @@ impl<'d, T: Instance> Ucpd<'d, T> {
150 // TODO: Currently only SOP messages are supported. 158 // TODO: Currently only SOP messages are supported.
151 r.tx_ordsetr().write(|w| w.set_txordset(0b10001_11000_11000_11000)); 159 r.tx_ordsetr().write(|w| w.set_txordset(0b10001_11000_11000_11000));
152 160
153 r.cfgr1().modify(|w| {
154 // TODO: Currently only hard reset and SOP messages can be received.
155 w.set_rxordseten(0b1001);
156
157 // Enable DMA
158 w.set_txdmaen(true);
159 w.set_rxdmaen(true);
160 });
161
162 // Enable the receiver on one of the two CC lines. 161 // Enable the receiver on one of the two CC lines.
163 r.cr().modify(|w| { 162 r.cr().modify(|w| {
164 w.set_phyccsel(cc_sel); 163 w.set_phyccsel(cc_sel);
@@ -216,7 +215,7 @@ impl<'d, T: Instance> Drop for CcPhy<'d, T> {
216impl<'d, T: Instance> CcPhy<'d, T> { 215impl<'d, T: Instance> CcPhy<'d, T> {
217 /// Sets the pull-up/pull-down resistor values exposed on the CC pins. 216 /// Sets the pull-up/pull-down resistor values exposed on the CC pins.
218 pub fn set_pull(&mut self, cc_pull: CcPull) { 217 pub fn set_pull(&mut self, cc_pull: CcPull) {
219 T::REGS.cr().write(|w| { 218 T::REGS.cr().modify(|w| {
220 w.set_anamode(if cc_pull == CcPull::Sink { 219 w.set_anamode(if cc_pull == CcPull::Sink {
221 Anamode::SINK 220 Anamode::SINK
222 } else { 221 } else {