@@ -381,25 +381,33 @@ void i2c_frequency(i2c_t *obj, int hz)
381
381
382
382
// Enable the Fast Mode Plus capability
383
383
if (hz == 1000000 ) {
384
- #if defined(I2C1_BASE ) && defined (I2C_FASTMODEPLUS_I2C1 )
384
+ #if defined(I2C1_BASE ) && defined(I2C_FASTMODEPLUS_I2C1 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
385
+ #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 )
385
386
if (obj_s -> i2c == I2C_1 ) {
386
387
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C1 );
387
388
}
388
389
#endif
389
- #if defined(I2C2_BASE ) && defined (I2C_FASTMODEPLUS_I2C2 )
390
+ #endif
391
+ #if defined(I2C2_BASE ) && defined(I2C_FASTMODEPLUS_I2C2 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
392
+ #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 )
390
393
if (obj_s -> i2c == I2C_2 ) {
391
394
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C2 );
392
395
}
393
396
#endif
394
- #if defined(I2C3_BASE ) && defined (I2C_FASTMODEPLUS_I2C3 )
397
+ #endif
398
+ #if defined(I2C3_BASE ) && defined (I2C_FASTMODEPLUS_I2C3 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
399
+ #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 )
395
400
if (obj_s -> i2c == I2C_3 ) {
396
401
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C3 );
397
402
}
398
403
#endif
399
- #if defined(I2C4_BASE ) && defined (I2C_FASTMODEPLUS_I2C4 )
404
+ #endif
405
+ #if defined(I2C4_BASE ) && defined (I2C_FASTMODEPLUS_I2C4 ) // sometimes I2C_FASTMODEPLUS_I2Cx is define even if not supported by the chip
406
+ #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 )
400
407
if (obj_s -> i2c == I2C_4 ) {
401
408
HAL_I2CEx_EnableFastModePlus (I2C_FASTMODEPLUS_I2C4 );
402
409
}
410
+ #endif
403
411
#endif
404
412
}
405
413
#endif //I2C_IP_VERSION_V2
0 commit comments