Skip to content

Commit 9bf6e99

Browse files
authored
Merge pull request #257 from facchinm/i2c_patch_unor4
UNOR4: rebuild libfsp with I2C patch
2 parents dfcf97a + 7f37ef4 commit 9bf6e99

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

Diff for: extras/fsp

Diff for: libraries/Wire/Wire.cpp

+18
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
/* -------------------------------------------------------------------------- */
@@ -486,6 +499,10 @@ uint8_t TwoWire::read_from(uint8_t address, uint8_t* data, uint8_t length, unsig
486499
if(bus_status == WIRE_STATUS_RX_COMPLETED) {
487500
return length;
488501
}
502+
503+
if(bus_status == WIRE_STATUS_UNSET) {
504+
m_abort(&m_i2c_ctrl);
505+
}
489506

490507
return 0; /* ???????? return value ??????? */
491508
}
@@ -518,6 +535,7 @@ uint8_t TwoWire::write_to(uint8_t address, uint8_t* data, uint8_t length, unsign
518535
}
519536
else if(bus_status == WIRE_STATUS_UNSET) {
520537
rv = END_TX_TIMEOUT;
538+
m_abort(&m_i2c_ctrl);
521539
}
522540
/* as far as I know is impossible to distinguish between NACK on ADDRESS and
523541
NACK on DATA */

Diff for: variants/MINIMA/libs/libfsp.a

-1.65 MB
Binary file not shown.

Diff for: variants/PORTENTA_C33/libs/libfsp.a

-4.05 MB
Binary file not shown.

Diff for: variants/UNOWIFIR4/libs/libfsp.a

-1.65 MB
Binary file not shown.

0 commit comments

Comments
 (0)