Skip to content

Commit 799f2b3

Browse files
authored
Correct issue with port speed not changing.
The current implementation will not change speed if Wire.setClock is called after begin() since the flags are only applied when the port is enabled from being disabled. Corrected that by adding 2 lines to disable the port, and then enable it again with the new settings. Tested and confirmed the new speed is applied.
1 parent 81100be commit 799f2b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

STM32F1/libraries/Wire/Wire.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void HardWire::setClock(uint32_t frequencyHz)
9797
dev_flags &= ~I2C_FAST_MODE;// clear FAST_MODE bit
9898
break;
9999
}
100-
100+
i2c_disable(sel_hard);
101+
i2c_master_enable(sel_hard, dev_flags);
101102
}
102103

103104
HardWire Wire(1);

0 commit comments

Comments
 (0)