Skip to content

Commit 81a9dd9

Browse files
mpolojarstevew817
authored andcommitted
SiLabs: I2C: Always set master mode on initialization
If an I2C block was reused after being a slave the status would not be cleared completely, so explicitly initialize to master mode always.
1 parent 316e873 commit 81a9dd9

File tree

1 file changed

+3
-0
lines changed
  • libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+3
-0
lines changed

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
148148
/* We are assuming that there is only one master. So disable automatic arbitration */
149149
obj->i2c.i2c->CTRL |= _I2C_CTRL_ARBDIS_MASK;
150150

151+
/* Set to master (needed if this I2C block was used previously as slave) */
152+
i2c_slave_mode(obj, false);
153+
151154
/* Enable i2c */
152155
i2c_enable(obj, true);
153156
}

0 commit comments

Comments
 (0)