summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2022-10-03 18:50:03 -0700
committerJeremy Fitzhardinge <jeremy@goop.org>2022-10-03 18:50:03 -0700
commit4fd831e4a88fdba14751c8a71ae45fc0eac92c66 (patch)
treea4147ab36c2da852630af346103c2c9572c60f1f
parentcae84991790976387aa4d4b7afae90094a876b25 (diff)
downloadembassy-4fd831e4a88fdba14751c8a71ae45fc0eac92c66.zip
rp async i2c: raise the tx_empty threshold
Assert "tx_empty" interrupt a little early so there's time to wake up and start refilling the fifo before it drains. This avoids stalling the i2c bus if the tx fifo completely drains.
-rw-r--r--embassy-rp/src/i2c.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs
index f004c522..68cfc653 100644
--- a/embassy-rp/src/i2c.rs
+++ b/embassy-rp/src/i2c.rs
@@ -243,12 +243,18 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
if let abort_reason @ Err(_) = me.read_and_clear_abort_reason() {
Poll::Ready(abort_reason)
} else if !Self::tx_fifo_full() {
+ // resume if there's any space free in the tx fifo
Poll::Ready(Ok(()))
} else {
Poll::Pending
}
},
|_me| unsafe {
+ // Set tx "free" threshold a little high so that we get
+ // woken before the fifo completely drains to minimize
+ // transfer stalls.
+ p.ic_tx_tl().write(|w| w.set_tx_tl(1));
+
p.ic_intr_mask().modify(|w| {
w.set_m_tx_empty(true);
w.set_m_tx_abrt(true);