You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// for high/wait_high we have to differentiate between the chips
// as the EPS32 does not have a wait_high field
cfg_if::cfg_if! {
if #[cfg(not(esp32))]{
self.register_block().scl_high_period.write(|w| {
w.scl_high_period()
.bits(scl_high)
.scl_wait_high_period()
.bits(scl_wait_high)
});
}
else {
self.register_block().scl_high_period.write(|w| {
w.scl_high_period()
.bits(scl_high)
});
}
}
// we already did that above but on S2 we need this to make it work
#[cfg(esp32s2)]
self.register_block().scl_high_period.write(|w| {
w.scl_wait_high_period()
.bits(scl_wait_high)
.scl_high_period()
.bits(scl_high)
});
// sda sample
self.register_block()
.sda_hold
.write(|w| w.time().bits(sda_hold));
self.register_block()
.sda_sample
.write(|w| w.time().bits(sda_sample));
// setup
self.register_block()
.scl_rstart_setup
.write(|w| w.time().bits(setup));
self.register_block()
.scl_stop_setup
.write(|w| w.time().bits(setup));
// hold
self.register_block()
.scl_start_hold
.write(|w| w.time().bits(hold));
self.register_block()
.scl_stop_hold
.write(|w| w.time().bits(hold));
// The ESP32 variant does not have an enable flag for the
// timeout mechanism
cfg_if::cfg_if! {
if #[cfg(esp32)]{
// timeout
self.register_block()
.to
.write(|w| w.time_out().bits(tout.into()));
}
else {
// timeout
// FIXME: Enable timout for other chips!
self.register_block()
.to
.write(|w| w.time_out_en().clear_bit());
}
}
}
Ok(())
}
is hard to read and hard to maintain - i.e. we should be able to easily compare that with e.g. ESP-IDF (it differs from that apparently already)
Since those calculations are very different for each chip it would make more sense to have implementations per chip (some chips share the same - e.g. ESP32-C3 and ESP32-C2)
Apparently also some subtle bugs here cause problems like we have seen with MPU6050 and ESP32-C3
The text was updated successfully, but these errors were encountered:
The code in
esp-hal/esp-hal-common/src/i2c.rs
Lines 438 to 601 in 3e4710b
Since those calculations are very different for each chip it would make more sense to have implementations per chip (some chips share the same - e.g. ESP32-C3 and ESP32-C2)
Apparently also some subtle bugs here cause problems like we have seen with MPU6050 and ESP32-C3
The text was updated successfully, but these errors were encountered: