Skip to content

Commit 0e225f9

Browse files
authored
Merge pull request #13173 from jeromecoutant/PR_I2C_L4R
STM32L4: I2C init parameters for L4+ MCU
2 parents 9ad4aa5 + 0d277ee commit 0e225f9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

targets/TARGET_STM/TARGET_STM32L4/i2c_device.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define MBED_I2C_DEVICE_H
3232

3333
#include "cmsis.h"
34+
#include "mbed_error.h"
3435

3536
#ifdef __cplusplus
3637
extern "C" {
@@ -82,6 +83,23 @@ static inline uint32_t get_i2c_timing(int hz)
8283
default:
8384
break;
8485
}
86+
} else if (SystemCoreClock == 120000000) {
87+
// Common settings: I2C clock = 120 MHz, Analog filter = ON, Digital filter coefficient = 0
88+
switch (hz) {
89+
case 100000:
90+
tim = 0x107075B0; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
91+
break;
92+
case 400000:
93+
tim = 0x00501E6C; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
94+
break;
95+
case 1000000:
96+
tim = 0x00200A26; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
97+
break;
98+
default:
99+
break;
100+
}
101+
} else {
102+
error("get_i2c_timing error\n");
85103
}
86104
return tim;
87105
}

0 commit comments

Comments
 (0)