Merge pull request #3084 from sjoerdsimons/ucpd-missing-packets
Improve stm32 ucpd packet reception
This commit is contained in:
commit
1e268a4d3d
@ -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) {
|
||||||
@ -343,17 +347,14 @@ impl<'d, T: Instance> PdPhy<'d, T> {
|
|||||||
.read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default())
|
.read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default())
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear interrupt flags (possibly set from last receive).
|
let _on_drop = OnDrop::new(|| {
|
||||||
|
Self::enable_rx_interrupt(false);
|
||||||
|
// Clear interrupt flags
|
||||||
r.icr().write(|w| {
|
r.icr().write(|w| {
|
||||||
w.set_rxorddetcf(true);
|
w.set_rxorddetcf(true);
|
||||||
w.set_rxovrcf(true);
|
w.set_rxovrcf(true);
|
||||||
w.set_rxmsgendcf(true);
|
w.set_rxmsgendcf(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
r.cr().modify(|w| w.set_phyrxen(true));
|
|
||||||
let _on_drop = OnDrop::new(|| {
|
|
||||||
r.cr().modify(|w| w.set_phyrxen(false));
|
|
||||||
Self::enable_rx_interrupt(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user