This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 2928c1e36f34ca0854c132ba5d11330eaaa00e96
Author: raiden00pl <[email protected]>
AuthorDate: Sat Nov 21 10:12:10 2026 +0100

    arch/arm/src/common/stm32: fix STM32G4 I2C4 clock and reset
    
    On STM32G4 I2C4 sits in RCC_APB1ENR2/APB1RSTR2, but the driver set bit 1
    of APB1ENR1/APB1RSTR1 (TIM3), so I2C4 was never clocked.
    
    Assisted-by: Claude Code
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/common/stm32/stm32_i2c_v2.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/common/stm32/stm32_i2c_v2.c 
b/arch/arm/src/common/stm32/stm32_i2c_v2.c
index 4b0b5c783eb..92a9a158a0e 100644
--- a/arch/arm/src/common/stm32/stm32_i2c_v2.c
+++ b/arch/arm/src/common/stm32/stm32_i2c_v2.c
@@ -336,7 +336,12 @@
 #  define STM32_I2C2_RST_BIT      RCC_APB1RSTR_I2C2RST
 #  define STM32_I2C3_CLK_BIT      RCC_APB1ENR_I2C3EN
 #  define STM32_I2C3_RST_BIT      RCC_APB1RSTR_I2C3RST
-#  ifdef CONFIG_STM32_I2C4
+#  if defined(CONFIG_STM32_I2C4) && defined(RCC_APB1ENR2_I2C4EN)
+#    define STM32_I2C4_CLK_REG    STM32_RCC_APB1ENR2
+#    define STM32_I2C4_RST_REG    STM32_RCC_APB1RSTR2
+#    define STM32_I2C4_CLK_BIT    RCC_APB1ENR2_I2C4EN
+#    define STM32_I2C4_RST_BIT    RCC_APB1RSTR2_I2C4RST
+#  elif defined(CONFIG_STM32_I2C4)
 #    define STM32_I2C4_CLK_REG    STM32_RCC_APB1ENR
 #    define STM32_I2C4_RST_REG    STM32_RCC_APB1RSTR
 #    define STM32_I2C4_CLK_BIT    RCC_APB1ENR_I2C4EN

Reply via email to