From 5f79be6c9bd0463824094b3aeb914bb0b193565a Mon Sep 17 00:00:00 2001 From: liebman Date: Mon, 22 Apr 2024 07:41:59 -0700 Subject: [PATCH] i2c: i2c1_handler used I2C0 register block by mistake (#1487) * i2c: i2c1_handler used I2C0 register block by mistake * update CHANGELOG --- esp-hal/CHANGELOG.md | 2 ++ esp-hal/src/i2c.rs | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) 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(); }