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

Test quinns patch #105

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft

Conversation

shuchitak
Copy link
Contributor

No description provided.

QuinnWang and others added 6 commits October 27, 2021 20:52
If the clock stretching happening, for example, the scl rising edge delays for 1 clock period, the original "tmr when timerafter(fall_time + delay) :> time" will not happen actually.
If the example above does happen, the timer value "time" in the original code is actually the scl rising edge time, then suggest to update the reference time point - fall_time - to a new value, set it to one low_period_ticks ago to be as an expected last scl fall edge time, and do the delay again to make sure the delay will indeed happen.

To verify, just take the last restart fix as an example, if the scl rising edge delays for 1 clock period, the delay code in the release_clock_and_wait doesn't do the delay actually, then the following drive SDA low will run right after the scl released by I2C slave to high, we can see the restart problem again, because the previous restart bug is just the compute_bus_off_ticks delay in the release_clock_and_wait is almost equal to the compute_low_period_ticks before calling release_clock_and_wait, then no sufficient time for between scl goes high and sda goes low.
With the changes, if go through/review with the clock stretching happening cases, since the delay should happen as expected, then no problem for the clock stretching cases.

And during understanding above, I found if changing the fall_time to last_scl_fall_edge_time, the readability of the code will become friendly and logic straight forward, then just changed as well.
Then found if following the original design idea that the fall_time is last_scl_fall_edge_time, the restart fix should need to be changed slightly, so updated in the propose changes too.
same idea as the i2c_master.xc changes to update the wait_for_clock_high
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.

3 participants