Skip to content

Fix infinite recursion issue in SERCOM::startTransmissionWIRE #535

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

Closed
wants to merge 8 commits into from
Closed

Fix infinite recursion issue in SERCOM::startTransmissionWIRE #535

wants to merge 8 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 24, 2020

Andrew Cunningham added 2 commits June 24, 2020 10:21
* If a significant hardware issue is struck startTransmissionWIRE
  calls itself to restart sending the address+r/w byte. The stack
  can be blown very quickly in the event of a prolonged hardware
  issue that warrants transmission restarts. A restart limit has
  been added (currently set at 5) to fix this issue.

* This fixes issue #476 and it builds on work by @jrowberg in which
  a timeout was added addressing issue #439.

* Some code simplification and tidying has followed from #439 and #476
  being resolved.
* TwoWire::endTransmission layout changed to be more inline with
  TwoWire::requestFrom because they are essentially functioning in
  a similar way.

* Sending of stop condition moved to within block of successful start.
  Apon successful start but unsuccessful read/write, stop condition is
  also sent - regardless of whether stop has been requested at that time.
@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

* The aynchronous nature of the DRE and TXC interrupt flags
  causes issues (lockups) when the TX DATA register is empty on start
  and a flush is issued. Simply looking at the DRE prior to
  waiting for TXC is insufficient because the data register
  may well be empty but the shift register could still contain
  data, in this case SERCOM::flushUART() would return before TXC
  has been raised thus before flushing is complete.
* bool added to SERCOM.h to indicate when it is ok for
  SERCOM::flushUART() to wait for the TXC flag. This flag is
  set when any data is written to the data register via
  SERCOM::writeDataUART(). It is cleared when a flush is done.
@ghost ghost mentioned this pull request Apr 15, 2021
Andrew Cunningham and others added 5 commits April 16, 2021 11:02
…535

* Although the previous solution works, it doesn't respect the timeout
  limit imposed by @jrowberg setTimeout, and the restart limit was
  somewhat arbitrary. This solution does respect this hard limit and
  removes the self recursive nature (that tends to blow the stack) of
  the restarts implemented in the original source.
* Tested using Arduino Zero as Master and 128x64 OLED, BM280 and ATTiny85
  as slaves. SCL -> VCC, SCL -> GND, SDA -> VCC, SDA -> GND all recoverable.
  Multi-master tested in a similar way using 2x Arduino Zero's and 128x64 OLED,
  same results.
* Relates to issues #476, #439 and PR #535.
@ghost ghost closed this by deleting the head repository May 24, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant