diff options
author | Timofey Titovets <nefelim4ag@gmail.com> | 2024-10-10 02:00:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 20:00:38 -0400 |
commit | b89d552387da9734292a182c7040c418996ca350 (patch) | |
tree | a324b500472b02b848466073e920672f5d84b854 /src/stm32 | |
parent | 96cceed23efc7a3759ecfba0a228cdcb4d5244d3 (diff) | |
download | kutter-b89d552387da9734292a182c7040c418996ca350.tar.gz kutter-b89d552387da9734292a182c7040c418996ca350.tar.xz kutter-b89d552387da9734292a182c7040c418996ca350.zip |
stm32: allow 400Khz in stm32f0_i2c.c (#6694)
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Diffstat (limited to 'src/stm32')
-rw-r--r-- | src/stm32/stm32f0_i2c.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c index a45aa34b..b83ceb0f 100644 --- a/src/stm32/stm32f0_i2c.c +++ b/src/stm32/stm32f0_i2c.c @@ -153,6 +153,13 @@ i2c_setup(uint32_t bus, uint32_t rate, uint8_t addr) uint32_t sclh = 32; // 32 * 125ns = 4us uint32_t sdadel = 4; // 4 * 125ns = 500ns uint32_t scldel = 10; // 10 * 125ns = 1250ns + // Clamp the rate to 400Khz + if (rate >= 400000) { + scll = 10; // 10 * 125ns = 1250ns + sclh = 4; // 4 * 125 = 500ns + sdadel = 3; // 3 * 125 = 375ns + scldel = 4; // 4 * 125 = 500ns + } uint32_t pclk = get_pclock_frequency((uint32_t)i2c); uint32_t presc = DIV_ROUND_UP(pclk, nom_i2c_clock); |