From 66765332e09cc9ce6f386a49bcbee612a3c625fc Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Thu, 10 Oct 2019 10:24:54 +0200 Subject: [PATCH 1/2] STM32F767ZI - I2C FastModePlus not properly enabled Fixes #11659 --- targets/TARGET_STM/i2c_api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_STM/i2c_api.c b/targets/TARGET_STM/i2c_api.c index 995bda07cbf..0d1fa46b519 100644 --- a/targets/TARGET_STM/i2c_api.c +++ b/targets/TARGET_STM/i2c_api.c @@ -381,22 +381,22 @@ void i2c_frequency(i2c_t *obj, int hz) // Enable the Fast Mode Plus capability if (hz == 1000000) { -#if defined(I2C1_BASE) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && defined (I2C_FASTMODEPLUS_I2C1) +#if defined(I2C1_BASE) && defined (I2C_FASTMODEPLUS_I2C1) if (obj_s->i2c == I2C_1) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C1); } #endif -#if defined(I2C2_BASE) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && defined (I2C_FASTMODEPLUS_I2C2) +#if defined(I2C2_BASE) && defined (I2C_FASTMODEPLUS_I2C2) if (obj_s->i2c == I2C_2) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2); } #endif -#if defined(I2C3_BASE) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && defined (I2C_FASTMODEPLUS_I2C3) +#if defined(I2C3_BASE) && defined (I2C_FASTMODEPLUS_I2C3) if (obj_s->i2c == I2C_3) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C3); } #endif -#if defined(I2C4_BASE) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && defined (I2C_FASTMODEPLUS_I2C4) +#if defined(I2C4_BASE) && defined (I2C_FASTMODEPLUS_I2C4) if (obj_s->i2c == I2C_4) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C4); } From 728a1c438336f334ede2cdb4da24ff4644a3aed6 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 15 Oct 2019 13:46:29 +0200 Subject: [PATCH 2/2] STM32F767ZI - I2C FastModePlus not properly enabled 2/2 Warning: sometimes I2C_FASTMODEPLUS_I2Cx is defined, even if not supported by some chip within the family --- targets/TARGET_STM/i2c_api.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_STM/i2c_api.c b/targets/TARGET_STM/i2c_api.c index 0d1fa46b519..379b294ba48 100644 --- a/targets/TARGET_STM/i2c_api.c +++ b/targets/TARGET_STM/i2c_api.c @@ -381,25 +381,33 @@ void i2c_frequency(i2c_t *obj, int hz) // Enable the Fast Mode Plus capability if (hz == 1000000) { -#if defined(I2C1_BASE) && defined (I2C_FASTMODEPLUS_I2C1) +#if defined(I2C1_BASE) && defined(I2C_FASTMODEPLUS_I2C1) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip +#if defined(SYSCFG_CFGR1_I2C_FMP_I2C1) || defined(SYSCFG_CFGR1_I2C1_FMP) || defined(SYSCFG_PMC_I2C1_FMP) || defined(SYSCFG_PMCR_I2C1_FMP) || defined(SYSCFG_CFGR2_I2C1_FMP) if (obj_s->i2c == I2C_1) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C1); } #endif -#if defined(I2C2_BASE) && defined (I2C_FASTMODEPLUS_I2C2) +#endif +#if defined(I2C2_BASE) && defined(I2C_FASTMODEPLUS_I2C2) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip +#if defined(SYSCFG_CFGR1_I2C_FMP_I2C2) || defined(SYSCFG_CFGR1_I2C2_FMP) || defined(SYSCFG_PMC_I2C2_FMP) || defined(SYSCFG_PMCR_I2C2_FMP) || defined(SYSCFG_CFGR2_I2C2_FMP) if (obj_s->i2c == I2C_2) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2); } #endif -#if defined(I2C3_BASE) && defined (I2C_FASTMODEPLUS_I2C3) +#endif +#if defined(I2C3_BASE) && defined (I2C_FASTMODEPLUS_I2C3) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip +#if defined(SYSCFG_CFGR1_I2C_FMP_I2C3) || defined(SYSCFG_CFGR1_I2C3_FMP) || defined(SYSCFG_PMC_I2C3_FMP) || defined(SYSCFG_PMCR_I2C3_FMP) || defined(SYSCFG_CFGR2_I2C3_FMP) if (obj_s->i2c == I2C_3) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C3); } #endif -#if defined(I2C4_BASE) && defined (I2C_FASTMODEPLUS_I2C4) +#endif +#if defined(I2C4_BASE) && defined (I2C_FASTMODEPLUS_I2C4) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip +#if defined(SYSCFG_CFGR1_I2C_FMP_I2C4) || defined(SYSCFG_CFGR1_I2C4_FMP) || defined(SYSCFG_PMC_I2C4_FMP) || defined(SYSCFG_PMCR_I2C4_FMP) || defined(SYSCFG_CFGR2_I2C4_FMP) if (obj_s->i2c == I2C_4) { HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C4); } +#endif #endif } #endif //I2C_IP_VERSION_V2