Skip to content

Commit 7f37ef4

Browse files
committed
Wire: unlock the bus on begin()
1 parent 1da5171 commit 7f37ef4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: libraries/Wire/Wire.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,19 @@ void TwoWire::_begin(void) {
405405
init_ok = false;
406406
}
407407
}
408+
409+
if (init_ok) {
410+
// inspired by https://community.element14.com/products/roadtest/b/blog/posts/using-i2c-spi-and-dma-on-renesas-ra2l1-part-1
411+
// abort previous transactions
412+
if (!is_sci) {
413+
for (int i = 0; i < 20; i++) {
414+
m_i2c_ctrl.p_reg->ICCR1_b.CLO = 1;
415+
while (m_i2c_ctrl.p_reg->ICCR1_b.CLO) {
416+
}
417+
}
418+
}
419+
m_abort(&m_i2c_ctrl);
420+
}
408421
}
409422

410423
/* -------------------------------------------------------------------------- */

0 commit comments

Comments
 (0)