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

cpu/nrf52 i2c: Wait for complete transmission when writing NOSTOP #20299

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Jan 25, 2024

Contribution description

(Reviewers, beware that the first two commits are actually #20298, see below for details).

When #20282 which enabled continuation from NOSTOP writes on nRF52 I2C in the first place, my hope was that waiting for the LASTTX signal and then starting a read operation could rely on the hardware to synchronize -- after all, LASTTX indicates that the write was started, so the hardware would not cancel the write in progress when there is a subsequent read, especially when the hardware doesn't signal that the last transmission was completed in situations when NOSTOP is required, right?

Nope:

i2c

The capture shows that a write operation is started, the address is written with the W bit, ACKed, and then before the last byte (the only byte) containing the I2C device's register number is written, the bus already goes into a repeated start (Sr in PulseView's output) mode, and starts reading.

For lack of a signal from the TWIM (nRF52's dreaded I2C implementation), the finish function waits for the LASTTX signal, and then busy-loops until the number of bytes written matches the number of bytes that should be written.

Testing procedure

With a microbit-v2, I ran my lsm303agr-1.0-2 branch's SAUL test. Without this patch, its saul read 7 reports all zeros; with this patch, it should report around 1g of gravity depending on your location.

Issues/PRs references

This is a follow-up on #20282. The commit history also includes #20298 because the test depends on it. Those two are as independent as two PRs fixing stuff for the same peripheral can be.

@chrysn chrysn added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: cpu Area: CPU/MCU ports labels Jan 25, 2024
@chrysn chrysn requested review from benpicco and dylad January 25, 2024 15:52
@chrysn chrysn requested a review from aabadie as a code owner January 25, 2024 15:52
@github-actions github-actions bot added the Platform: ARM Platform: This PR/issue effects ARM-based platforms label Jan 25, 2024
@riot-ci
Copy link

riot-ci commented Jan 25, 2024

Murdock results

✔️ PASSED

790e808 cpu/nrf52 i2c: Wait for complete transmission when writing NOSTOP

Success Failures Total Runtime
1 0 1 01m:04s

Artifacts

@benpicco benpicco requested a review from maribu January 25, 2024 16:02
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 26, 2024
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash

@chrysn chrysn enabled auto-merge January 27, 2024 08:42
@chrysn chrysn added CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 27, 2024
@chrysn chrysn added this pull request to the merge queue Jan 27, 2024
@chrysn
Copy link
Member Author

chrysn commented Jan 27, 2024

Thanks for your review and fixes.

I've set "skip compile tests" due to clearly unrelated test failures (native:llvm tests/sys/ztimer_overhead), let's see if that actually works with the current CI setup.

Merged via the queue into RIOT-OS:master with commit 8f111a3 Jan 27, 2024
28 checks passed
@benpicco benpicco removed the CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs label Jan 27, 2024
@chrysn chrysn deleted the nrf52-spi-bugs-2 branch January 29, 2024 20:09
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants