Skip to content

Commit 6906fbb

Browse files
LMESTMadbridge
authored andcommitted
STM32 I2C: Initialize hz parameter before reset
The hz value is used to compute timeouts, and timeout are used in reset function, so the parameter needs to be initialized to its default value before being used.
1 parent 151a9ef commit 6906fbb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

targets/TARGET_STM/i2c_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,13 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
282282
}
283283
#endif
284284

285-
// Reset to clear pending flags if any
286-
i2c_reset(obj);
287-
288285
// I2C configuration
286+
// Default hz value used for timeout computation
289287
if(!obj_s->hz)
290288
obj_s->hz = 100000; // 100 kHz per default
289+
290+
// Reset to clear pending flags if any
291+
i2c_reset(obj);
291292
i2c_frequency(obj, obj_s->hz );
292293

293294
#if DEVICE_I2CSLAVE

0 commit comments

Comments
 (0)