diff --git a/targets/TARGET_STM/i2c_api.c b/targets/TARGET_STM/i2c_api.c index 995bda07cbf..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(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && 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(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && 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(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && 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(__HAL_SYSCFG_FASTMODEPLUS_ENABLE) && 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