Skip to content

Commit ee9c8ac

Browse files
committed
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 ce9d252 commit ee9c8ac

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
@@ -270,12 +270,13 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
270270
}
271271
#endif
272272

273-
// Reset to clear pending flags if any
274-
i2c_reset(obj);
275-
276273
// I2C configuration
274+
// Default hz value used for timeout computation
277275
if(!obj_s->hz)
278276
obj_s->hz = 100000; // 100 kHz per default
277+
278+
// Reset to clear pending flags if any
279+
i2c_reset(obj);
279280
i2c_frequency(obj, obj_s->hz );
280281

281282
#if DEVICE_I2CSLAVE

0 commit comments

Comments
 (0)