From a0983627f5d7631ca7d383924dfe417e2e8456ff Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Tue, 7 Feb 2023 15:04:48 +0800 Subject: [PATCH] bugfix: fix returning before disabling blocks --- components/esp_rom/patches/esp_rom_regi2c_esp32c6.c | 8 ++++++-- components/esp_rom/patches/esp_rom_regi2c_esp32h2.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/esp_rom/patches/esp_rom_regi2c_esp32c6.c b/components/esp_rom/patches/esp_rom_regi2c_esp32c6.c index 49eb6dcb48..2923aacb0a 100644 --- a/components/esp_rom/patches/esp_rom_regi2c_esp32c6.c +++ b/components/esp_rom/patches/esp_rom_regi2c_esp32c6.c @@ -129,9 +129,11 @@ uint8_t IRAM_ATTR esp_rom_regi2c_read(uint8_t block, uint8_t host_id, uint8_t re | (reg_add & REGI2C_RTC_ADDR_V) << REGI2C_RTC_ADDR_S; REG_WRITE(LP_I2C_ANA_MST_I2C0_CTRL_REG, temp); while (REG_GET_BIT(LP_I2C_ANA_MST_I2C0_CTRL_REG, LP_I2C_ANA_MST_I2C0_BUSY)); - return REG_GET_FIELD(LP_I2C_ANA_MST_I2C0_DATA_REG, LP_I2C_ANA_MST_I2C0_RDATA); + uint8_t ret = REG_GET_FIELD(LP_I2C_ANA_MST_I2C0_DATA_REG, LP_I2C_ANA_MST_I2C0_RDATA); regi2c_disable_block(block); + + return ret; } uint8_t IRAM_ATTR esp_rom_regi2c_read_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb) @@ -145,9 +147,11 @@ uint8_t IRAM_ATTR esp_rom_regi2c_read_mask(uint8_t block, uint8_t host_id, uint8 REG_WRITE(LP_I2C_ANA_MST_I2C0_CTRL_REG, temp); while (REG_GET_BIT(LP_I2C_ANA_MST_I2C0_CTRL_REG, LP_I2C_ANA_MST_I2C0_BUSY)); uint32_t data = REG_GET_FIELD(LP_I2C_ANA_MST_I2C0_DATA_REG, LP_I2C_ANA_MST_I2C0_RDATA); - return (uint8_t)((data >> lsb) & (~(0xFFFFFFFF << (msb - lsb + 1)))); + uint8_t ret = (uint8_t)((data >> lsb) & (~(0xFFFFFFFF << (msb - lsb + 1)))); regi2c_disable_block(block); + + return ret; } void IRAM_ATTR esp_rom_regi2c_write(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data) diff --git a/components/esp_rom/patches/esp_rom_regi2c_esp32h2.c b/components/esp_rom/patches/esp_rom_regi2c_esp32h2.c index 57a6d9d00f..08e0745b5c 100644 --- a/components/esp_rom/patches/esp_rom_regi2c_esp32h2.c +++ b/components/esp_rom/patches/esp_rom_regi2c_esp32h2.c @@ -128,9 +128,11 @@ uint8_t IRAM_ATTR esp_rom_regi2c_read(uint8_t block, uint8_t host_id, uint8_t re | (reg_add & REGI2C_RTC_ADDR_V) << REGI2C_RTC_ADDR_S; REG_WRITE(I2C_MST_I2C0_CTRL_REG, temp); while (REG_GET_BIT(I2C_MST_I2C0_CTRL_REG, REGI2C_RTC_BUSY)); - return REG_GET_FIELD(I2C_MST_I2C0_CTRL_REG, REGI2C_RTC_DATA); + uint8_t ret = REG_GET_FIELD(I2C_MST_I2C0_CTRL_REG, REGI2C_RTC_DATA); regi2c_disable_block(block); + + return ret; } uint8_t IRAM_ATTR esp_rom_regi2c_read_mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb) @@ -144,9 +146,11 @@ uint8_t IRAM_ATTR esp_rom_regi2c_read_mask(uint8_t block, uint8_t host_id, uint8 REG_WRITE(I2C_MST_I2C0_CTRL_REG, temp); while (REG_GET_BIT(I2C_MST_I2C0_CTRL_REG, REGI2C_RTC_BUSY)); uint32_t data = REG_GET_FIELD(I2C_MST_I2C0_CTRL_REG, REGI2C_RTC_DATA); - return (uint8_t)((data >> lsb) & (~(0xFFFFFFFF << (msb - lsb + 1)))); + uint8_t ret = (uint8_t)((data >> lsb) & (~(0xFFFFFFFF << (msb - lsb + 1)))); regi2c_disable_block(block); + + return ret; } void IRAM_ATTR esp_rom_regi2c_write(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data)