aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimofey Titovets <nefelim4ag@gmail.com>2024-10-10 02:00:38 +0200
committerGitHub <noreply@github.com>2024-10-09 20:00:38 -0400
commitb89d552387da9734292a182c7040c418996ca350 (patch)
treea324b500472b02b848466073e920672f5d84b854 /src
parent96cceed23efc7a3759ecfba0a228cdcb4d5244d3 (diff)
downloadkutter-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')
-rw-r--r--src/stm32/stm32f0_i2c.c7
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);