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.
This commit is contained in:
Jeremy Fitzhardinge 2022-10-03 18:50:03 -07:00
parent cae8499179
commit 4fd831e4a8

View File

@ -243,12 +243,18 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
if let abort_reason @ Err(_) = me.read_and_clear_abort_reason() { if let abort_reason @ Err(_) = me.read_and_clear_abort_reason() {
Poll::Ready(abort_reason) Poll::Ready(abort_reason)
} else if !Self::tx_fifo_full() { } else if !Self::tx_fifo_full() {
// resume if there's any space free in the tx fifo
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} else { } else {
Poll::Pending Poll::Pending
} }
}, },
|_me| unsafe { |_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| { p.ic_intr_mask().modify(|w| {
w.set_m_tx_empty(true); w.set_m_tx_empty(true);
w.set_m_tx_abrt(true); w.set_m_tx_abrt(true);