@@ -389,25 +389,33 @@ void i2c_frequency(i2c_t *obj, int hz)
389389
390390 // Enable the Fast Mode Plus capability
391391 if (hz == 1000000 ) {
392- #if defined(I2C1_BASE ) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE ) && defined (I2C_FASTMODEPLUS_I2C1 )
392+ #if defined(I2C1_BASE ) && defined(I2C_FASTMODEPLUS_I2C1 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
393+ #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 )
393394 if (obj_s -> i2c == I2C_1 ) {
394395 HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C1 );
395396 }
396397#endif
397- #if defined(I2C2_BASE ) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE ) && defined (I2C_FASTMODEPLUS_I2C2 )
398+ #endif
399+ #if defined(I2C2_BASE ) && defined(I2C_FASTMODEPLUS_I2C2 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
400+ #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 )
398401 if (obj_s -> i2c == I2C_2 ) {
399402 HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C2 );
400403 }
401404#endif
402- #if defined(I2C3_BASE ) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE ) && defined (I2C_FASTMODEPLUS_I2C3 )
405+ #endif
406+ #if defined(I2C3_BASE ) && defined (I2C_FASTMODEPLUS_I2C3 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
407+ #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 )
403408 if (obj_s -> i2c == I2C_3 ) {
404409 HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C3 );
405410 }
406411#endif
407- #if defined(I2C4_BASE ) && defined(__HAL_SYSCFG_FASTMODEPLUS_ENABLE ) && defined (I2C_FASTMODEPLUS_I2C4 )
412+ #endif
413+ #if defined(I2C4_BASE ) && defined (I2C_FASTMODEPLUS_I2C4 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
414+ #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 )
408415 if (obj_s -> i2c == I2C_4 ) {
409416 HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C4 );
410417 }
418+ #endif
411419#endif
412420 }
413421#endif //I2C_IP_VERSION_V2
0 commit comments