Skip to content

Commit f9b4f11

Browse files
committed
STM32WB: Adapt I2C timings
for now based on L4+ cubeMX inputs
1 parent bb2aea4 commit f9b4f11

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

targets/TARGET_STM/TARGET_STM32WB/i2c_device.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,37 @@ extern "C" {
4747
#define I2CAPI_I2C1_CLKSRC RCC_I2C1CLKSOURCE_SYSCLK
4848
#define I2CAPI_I2C2_CLKSRC RCC_I2C2CLKSOURCE_SYSCLK
4949
#define I2CAPI_I2C3_CLKSRC RCC_I2C3CLKSOURCE_SYSCLK
50-
#define I2CAPI_I2C4_CLKSRC RCC_I2C4CLKSOURCE_SYSCLK
5150

5251
/* Provide the suitable timing depending on requested frequency */
5352
static inline uint32_t get_i2c_timing(int hz)
5453
{
5554
uint32_t tim = 0;
56-
if (SystemCoreClock == 80000000) {
57-
// Common settings: I2C clock = 80 MHz, Analog filter = ON, Digital filter coefficient = 0
55+
if (SystemCoreClock == 64000000) {
56+
// Common settings: I2C clock = 64 MHz, Analog filter = ON, Digital filter coefficient = 0
5857
switch (hz) {
5958
case 100000:
60-
tim = 0x30C14E6B; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
59+
tim = 0x10707DBC; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
6160
break;
6261
case 400000:
63-
tim = 0x10D1143A; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
62+
tim = 0x00602173; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
6463
break;
6564
case 1000000:
66-
tim = 0x00810E27; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
65+
tim = 0x00300B29; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
6766
break;
6867
default:
6968
break;
7069
}
71-
} else if (SystemCoreClock == 48000000) {
72-
// Common settings: I2C clock = 48 MHz, Analog filter = ON, Digital filter coefficient = 0
70+
} else if (SystemCoreClock == 32000000) {
71+
// Common settings: I2C clock = 32 MHz, Analog filter = ON, Digital filter coefficient = 0
7372
switch (hz) {
7473
case 100000:
75-
tim = 0x20A03E55; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
74+
tim = 0x00707CBB; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
7675
break;
7776
case 400000:
78-
tim = 0x10800C21; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
77+
tim = 0x00300F38; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
7978
break;
8079
case 1000000:
81-
tim = 0x00500816; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
80+
tim = 0x00100413; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
8281
break;
8382
default:
8483
break;

0 commit comments

Comments
 (0)