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
Merged
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
10 changes: 10 additions & 0 deletions cpu/nrf5x_common/periph/i2c_nrf52_nrf9160.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* As this implementation is based on the nRF5x TWIM peripheral, it can not
* issue a read following a read (or a write following a write) without
* creating a (repeated) start condition:
* <https://devzone.nordicsemi.com/f/nordic-q-a/66615/nrf52840-twim-how-to-write-multiple-buffers-without-repeated-start-condition>,

Check warning on line 25 in cpu/nrf5x_common/periph/i2c_nrf52_nrf9160.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* backed also by later experiments discussed in the [Rust embedded
* channel](https://matrix.to/#/!BHcierreUuwCMxVqOf:matrix.org/$JwNejRaeJx_tvqKgS88GenDG8ZNHrkTW09896dIehQ8?via=matrix.org&via=catircservices.org&via=tchncs.de).

Check warning on line 27 in cpu/nrf5x_common/periph/i2c_nrf52_nrf9160.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* Due to this shortcoming in the hardware, any operations with I2C_NOSTART
* fail.
*
Expand Down Expand Up @@ -126,6 +126,16 @@
DEBUG("[i2c] finish: stop event occurred\n");
}

if (inten_success_flag & TWIM_INTEN_LASTTX_Msk) {
/* The interrupt is raised already when the last TX is started, but we
* have to wait until it was actually transmitted lest the transmission
* would be suppressed immediately by the next following write --
* careful here: enabling DEBUG introduces enough latency that the
* issue doesn't show up any more. */
while (bus(dev)->TXD.AMOUNT != bus(dev)->TXD.MAXCNT &&
!bus(dev)->EVENTS_ERROR) {}
}

if (bus(dev)->EVENTS_ERROR) {
bus(dev)->EVENTS_ERROR = 0;
if (bus(dev)->ERRORSRC & TWIM_ERRORSRC_ANACK_Msk) {
Expand Down
Loading