From ccf899585880fff0d3071e2063535d910f8430a0 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 12 Jul 2021 22:10:50 +0200 Subject: [PATCH] STM32 Fix i2c_compute_timing() API --- targets/TARGET_STM/i2c_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/TARGET_STM/i2c_api.c b/targets/TARGET_STM/i2c_api.c index 2676e19fd6f..5c1d8f1af59 100644 --- a/targets/TARGET_STM/i2c_api.c +++ b/targets/TARGET_STM/i2c_api.c @@ -1733,6 +1733,9 @@ uint32_t i2c_compute_timing(uint32_t clock_src_freq, uint32_t i2c_freq) uint32_t speed; uint32_t idx; + /* Reset valid timing count at the beginning of each new computation */ + I2c_valid_timing_nbr = 0; + if ((clock_src_freq != 0U) && (i2c_freq != 0U)) { for (speed = 0 ; speed <= (uint32_t)I2C_SPEED_FREQ_FAST_PLUS ; speed++) { if ((i2c_freq >= I2C_Charac[speed].freq_min) &&