[USPD] clear interrupt flags right after reception

Clearing the interrupt flags at beginning of reception will masks
overruns and cause corrupted packets to be received. Instead clear the
flags right after disabling the interrupt/after reception, so overruns
on the next receive can be caught.

Tested by forcing overruns due to explicit sleeps

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
This commit is contained in:
Sjoerd Simons 2024-06-16 11:00:56 +02:00
parent 84cbf1d198
commit 9e8035cfb9

View file

@ -347,15 +347,14 @@ impl<'d, T: Instance> PdPhy<'d, T> {
.read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default())
};
// Clear interrupt flags (possibly set from last receive).
r.icr().write(|w| {
w.set_rxorddetcf(true);
w.set_rxovrcf(true);
w.set_rxmsgendcf(true);
});
let _on_drop = OnDrop::new(|| {
Self::enable_rx_interrupt(false);
// Clear interrupt flags
r.icr().write(|w| {
w.set_rxorddetcf(true);
w.set_rxovrcf(true);
w.set_rxmsgendcf(true);
});
});
poll_fn(|cx| {