Skip to content

Commit 9b927b2

Browse files
authored
Fix I2C handling of multiple Wire.begin() at libmaple level
Just skip the i2c_master_enable() code if the PE bit says it's already enabled This solves the problem of ASSERT() hang when Wire.begin() is called by multiple libraries
1 parent 91783ae commit 9b927b2

File tree

1 file changed

+2
-2
lines changed
  • STM32F1/cores/maple/libmaple

1 file changed

+2
-2
lines changed

STM32F1/cores/maple/libmaple/i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ void i2c_init(i2c_dev *dev) {
175175
* SDA/PB9.
176176
*/
177177
void i2c_master_enable(i2c_dev *dev, uint32 flags) {
178-
/* PE must be disabled to configure the device */
179-
ASSERT(!(dev->regs->CR1 & I2C_CR1_PE));
178+
/* If the device is already enabled, don't do it again */
179+
if(dev->regs->CR1 & I2C_CR1_PE) return;
180180

181181
/* Ugh */
182182
_i2c_handle_remap(dev, flags);

0 commit comments

Comments
 (0)