diff options
| author | Sjoerd Simons <[email protected]> | 2024-06-16 11:00:56 +0200 |
|---|---|---|
| committer | Sjoerd Simons <[email protected]> | 2024-06-16 11:00:56 +0200 |
| commit | 9e8035cfb922d1b85f020e31bee2d3f815ba6f28 (patch) | |
| tree | 93ee30d52842a2a0af281ccb4a884f43841f0023 /embassy-stm32/src | |
| parent | 84cbf1d198d035471965232e89b4650c54edcfb1 (diff) | |
[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 <[email protected]>
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/ucpd.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/embassy-stm32/src/ucpd.rs b/embassy-stm32/src/ucpd.rs index cbec85ff3..40aea75cb 100644 --- a/embassy-stm32/src/ucpd.rs +++ b/embassy-stm32/src/ucpd.rs | |||
| @@ -347,15 +347,14 @@ impl<'d, T: Instance> PdPhy<'d, T> { | |||
| 347 | .read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default()) | 347 | .read(r.rxdr().as_ptr() as *mut u8, buf, TransferOptions::default()) |
| 348 | }; | 348 | }; |
| 349 | 349 | ||
| 350 | // Clear interrupt flags (possibly set from last receive). | ||
| 351 | r.icr().write(|w| { | ||
| 352 | w.set_rxorddetcf(true); | ||
| 353 | w.set_rxovrcf(true); | ||
| 354 | w.set_rxmsgendcf(true); | ||
| 355 | }); | ||
| 356 | |||
| 357 | let _on_drop = OnDrop::new(|| { | 350 | let _on_drop = OnDrop::new(|| { |
| 358 | Self::enable_rx_interrupt(false); | 351 | Self::enable_rx_interrupt(false); |
| 352 | // Clear interrupt flags | ||
| 353 | r.icr().write(|w| { | ||
| 354 | w.set_rxorddetcf(true); | ||
| 355 | w.set_rxovrcf(true); | ||
| 356 | w.set_rxmsgendcf(true); | ||
| 357 | }); | ||
| 359 | }); | 358 | }); |
| 360 | 359 | ||
| 361 | poll_fn(|cx| { | 360 | poll_fn(|cx| { |
