@@ -389,25 +389,33 @@ void i2c_frequency(i2c_t *obj, int hz)
389
389
390
390
// Enable the Fast Mode Plus capability
391
391
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 )
393
394
if (obj_s -> i2c == I2C_1 ) {
394
395
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C1 );
395
396
}
396
397
#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 )
398
401
if (obj_s -> i2c == I2C_2 ) {
399
402
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C2 );
400
403
}
401
404
#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 )
403
408
if (obj_s -> i2c == I2C_3 ) {
404
409
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C3 );
405
410
}
406
411
#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 )
408
415
if (obj_s -> i2c == I2C_4 ) {
409
416
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C4 );
410
417
}
418
+ #endif
411
419
#endif
412
420
}
413
421
#endif //I2C_IP_VERSION_V2
0 commit comments