mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
[UCPD] Don't disable ucpd rx after each reception
When disabling the UCPD RX after every reception it's relatively easy to drop packets. This seems to happen in particular with GoodCRC packets which can be sent very quickly by a receiver. To avoid this enable reception as soon as the pd phy get split out (preparing for packet processing) and only disable again when the pd phy gets dropped.
This commit is contained in:
parent
c818125c22
commit
84cbf1d198
@ -169,6 +169,9 @@ impl<'d, T: Instance> Ucpd<'d, T> {
|
|||||||
// Enable hard reset receive interrupt.
|
// Enable hard reset receive interrupt.
|
||||||
r.imr().modify(|w| w.set_rxhrstdetie(true));
|
r.imr().modify(|w| w.set_rxhrstdetie(true));
|
||||||
|
|
||||||
|
// Enable PD packet reception
|
||||||
|
r.cr().modify(|w| w.set_phyrxen(true));
|
||||||
|
|
||||||
// Both parts must be dropped before the peripheral can be disabled.
|
// Both parts must be dropped before the peripheral can be disabled.
|
||||||
T::state().drop_not_ready.store(true, Ordering::Relaxed);
|
T::state().drop_not_ready.store(true, Ordering::Relaxed);
|
||||||
|
|
||||||
@ -319,6 +322,7 @@ pub struct PdPhy<'d, T: Instance> {
|
|||||||
|
|
||||||
impl<'d, T: Instance> Drop for PdPhy<'d, T> {
|
impl<'d, T: Instance> Drop for PdPhy<'d, T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
T::REGS.cr().modify(|w| w.set_phyrxen(false));
|
||||||
// Check if the Type-C part was dropped already.
|
// Check if the Type-C part was dropped already.
|
||||||
let drop_not_ready = &T::state().drop_not_ready;
|
let drop_not_ready = &T::state().drop_not_ready;
|
||||||
if drop_not_ready.load(Ordering::Relaxed) {
|
if drop_not_ready.load(Ordering::Relaxed) {
|
||||||
@ -350,9 +354,7 @@ impl<'d, T: Instance> PdPhy<'d, T> {
|
|||||||
w.set_rxmsgendcf(true);
|
w.set_rxmsgendcf(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
r.cr().modify(|w| w.set_phyrxen(true));
|
|
||||||
let _on_drop = OnDrop::new(|| {
|
let _on_drop = OnDrop::new(|| {
|
||||||
r.cr().modify(|w| w.set_phyrxen(false));
|
|
||||||
Self::enable_rx_interrupt(false);
|
Self::enable_rx_interrupt(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user