diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 0b8fe02cd..56a5607e7 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- i2c: i2c1_handler used I2C0 register block by mistake (#1487) + ### Changed ### Removed diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs index 7b75de2c4..9eb407a2c 100644 --- a/esp-hal/src/i2c.rs +++ b/esp-hal/src/i2c.rs @@ -705,14 +705,12 @@ mod asynch { #[handler] pub(super) fn i2c0_handler() { - unsafe { &*crate::peripherals::I2C0::PTR } - .int_ena() + let regs = unsafe { &*crate::peripherals::I2C0::PTR }; + regs.int_ena() .modify(|_, w| w.end_detect().clear_bit().trans_complete().clear_bit()); #[cfg(not(any(esp32, esp32s2)))] - unsafe { &*crate::peripherals::I2C0::PTR } - .int_ena() - .modify(|_, w| w.txfifo_wm().clear_bit()); + regs.int_ena().modify(|_, w| w.txfifo_wm().clear_bit()); WAKERS[0].wake(); } @@ -720,14 +718,12 @@ mod asynch { #[cfg(i2c1)] #[handler] pub(super) fn i2c1_handler() { - unsafe { &*crate::peripherals::I2C1::PTR } - .int_ena() + let regs = unsafe { &*crate::peripherals::I2C1::PTR }; + regs.int_ena() .modify(|_, w| w.end_detect().clear_bit().trans_complete().clear_bit()); #[cfg(not(any(esp32, esp32s2)))] - unsafe { &*crate::peripherals::I2C0::PTR } - .int_ena() - .modify(|_, w| w.txfifo_wm().clear_bit()); + regs.int_ena().modify(|_, w| w.txfifo_wm().clear_bit()); WAKERS[1].wake(); }