Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNOR4: rebuild libfsp with I2C patch #257

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extras/fsp
18 changes: 18 additions & 0 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,19 @@ void TwoWire::_begin(void) {
init_ok = false;
}
}

if (init_ok) {
// inspired by https://community.element14.com/products/roadtest/b/blog/posts/using-i2c-spi-and-dma-on-renesas-ra2l1-part-1
// abort previous transactions
if (!is_sci) {
for (int i = 0; i < 20; i++) {
m_i2c_ctrl.p_reg->ICCR1_b.CLO = 1;
while (m_i2c_ctrl.p_reg->ICCR1_b.CLO) {
}
}
}
m_abort(&m_i2c_ctrl);
}
}

/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -486,6 +499,10 @@ uint8_t TwoWire::read_from(uint8_t address, uint8_t* data, uint8_t length, unsig
if(bus_status == WIRE_STATUS_RX_COMPLETED) {
return length;
}

if(bus_status == WIRE_STATUS_UNSET) {
m_abort(&m_i2c_ctrl);
}

return 0; /* ???????? return value ??????? */
}
Expand Down Expand Up @@ -518,6 +535,7 @@ uint8_t TwoWire::write_to(uint8_t address, uint8_t* data, uint8_t length, unsign
}
else if(bus_status == WIRE_STATUS_UNSET) {
rv = END_TX_TIMEOUT;
m_abort(&m_i2c_ctrl);
}
/* as far as I know is impossible to distinguish between NACK on ADDRESS and
NACK on DATA */
Expand Down
Binary file modified variants/MINIMA/libs/libfsp.a
Binary file not shown.
Binary file modified variants/PORTENTA_C33/libs/libfsp.a
Binary file not shown.
Binary file modified variants/UNOWIFIR4/libs/libfsp.a
Binary file not shown.
Loading