Skip to content

Commit 728a1c4

Browse files
committed
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
1 parent 6676533 commit 728a1c4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

targets/TARGET_STM/i2c_api.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,25 +381,33 @@ void i2c_frequency(i2c_t *obj, int hz)
381381

382382
// Enable the Fast Mode Plus capability
383383
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)
385386
if (obj_s->i2c == I2C_1) {
386387
HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C1);
387388
}
388389
#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)
390393
if (obj_s->i2c == I2C_2) {
391394
HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2);
392395
}
393396
#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)
395400
if (obj_s->i2c == I2C_3) {
396401
HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C3);
397402
}
398403
#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)
400407
if (obj_s->i2c == I2C_4) {
401408
HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C4);
402409
}
410+
#endif
403411
#endif
404412
}
405413
#endif //I2C_IP_VERSION_V2

0 commit comments

Comments
 (0)