maxikrie opened a new pull request, #21007:
URL: https://github.com/apache/nuttx/pull/21007
## Summary
The nRF52 I2C (TWIM) driver ignores `I2C_M_NOSTOP`: every write ends in STOP
(`LASTTX -> STOP` shortcut). A register read, which is a write of the
register address with `I2C_M_NOSTOP` followed by a read from the same
address (as `i2c_writeread()` builds it), therefore goes out as two separate
transactions. Many devices require a repeated START between the two.
Found with an LSM6DSL accelerometer/gyroscope, whose datasheet (DocID028475,
tables 16 and 17) requires the repeated START for reads, while debugging
out-of-order words in FIFO burst reads through `/dev/i2c0`.
This PR runs such a pair as one TWIM transfer when a write with
`I2C_M_NOSTOP` is followed by a read from the same address and both carry
data:
- `RXD.PTR`/`RXD.MAXCNT` are set up for the read along with the write;
- `LASTTX -> STARTRX` makes the repeated START, `LASTRX -> STOP` ends the
transfer;
- the pair completes on a single `STOPPED` event, then the loop moves on two
messages.
Every other sequence (plain writes and reads, `I2C_M_NOSTART` combining,
zero-length transfers) is handled as before.
The first commit fixes the nxstyle errors already in `nrf52_i2c.c`
(case-label indentation of the frequency switch), whitespace only:
`nrf52-feather:i2c` builds to the same `nuttx.bin` before and after it.
## Impact
- nRF52 I2C masters: write-then-read sequences with `I2C_M_NOSTOP` now
produce
a repeated START instead of STOP + START, as `I2C_M_NOSTOP` asks for.
Devices that accepted STOP + START also accept a repeated START.
- Works in both interrupt-driven and `CONFIG_I2C_POLLED` mode: both wait for
`STOPPED`.
- No Kconfig, API or build changes. The nRF53 and nRF91 drivers have the same
structure and are not changed here.
## Testing
Host: Debian Linux (kernel 6.1), x86_64.
Toolchain: `arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1) 13.3.1 20240614`
Build (CMake/Ninja): `nrf52-feather:i2c`, interrupt-driven and with
`CONFIG_I2C_POLLED=y`, without warnings. Both commits pass
`tools/checkpatch.sh`.
Hardware: XIAO nRF52840 Sense, on-board LSM6DSL on TWIM0 at 400 kHz, read
from
user space through `/dev/i2c0` (`I2CIOC_TRANSFER` with a 1-byte register
write + read, FIFO bursts at 833 Hz drained every 10 ms). Eight boards have
run the change since 2026-10-21 on NuttX 12.13.0, with every register and
FIFO read answered and the FIFO words in order. (Those runs predate the "both
carry data" condition, which register reads always meet.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]