diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index 3b74d8501..ac0eac96d 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs @@ -414,7 +414,6 @@ impl<'d, T: Instance + 'd, M: Mode> I2c<'d, T, M> { let lcnt = period * 3 / 5; // spend 3/5 (60%) of the period low let hcnt = period - lcnt; // and 2/5 (40%) of the period high - warn!("cb:{} h:{:x} l:{:x}", clk_base, hcnt, lcnt); // Check for out-of-range divisors: if hcnt > 0xffff || lcnt > 0xffff { return Err(ConfigError::ClockTooFast); @@ -443,11 +442,10 @@ impl<'d, T: Instance + 'd, M: Mode> I2c<'d, T, M> { // fit in uint. Add 1 to avoid division truncation. ((clk_base * 3) / 25_000_000) + 1 }; - /* - if sda_tx_hold_count <= lcnt - 2 { - return Err(ConfigError::HoldCountOutOfRange); + + if sda_tx_hold_count > lcnt - 2 { + return Err(ConfigError::ClockTooSlow); } - */ p.ic_fs_scl_hcnt().write(|w| w.set_ic_fs_scl_hcnt(hcnt as u16)); p.ic_fs_scl_lcnt().write(|w| w.set_ic_fs_scl_lcnt(lcnt as u16)); diff --git a/embassy-rp/src/i2c_slave.rs b/embassy-rp/src/i2c_slave.rs index caebb0257..e1441947f 100644 --- a/embassy-rp/src/i2c_slave.rs +++ b/embassy-rp/src/i2c_slave.rs @@ -331,9 +331,9 @@ impl<'d, T: Instance> I2cSlave<'d, T> { }, |_me| { p.ic_intr_mask().write(|w| { + w.set_m_rx_done(true); w.set_m_tx_empty(true); w.set_m_tx_abrt(true); - w.set_m_rx_done(true); }) }, )