commit | 63903b4f24e9122a53a5b0e5a86bb042fc5583fc | [log] [tgz] |
---|---|---|
author | Jonathon Reinhart <jrreinhart@google.com> | Thu Feb 15 21:11:37 2024 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Thu Feb 15 21:11:37 2024 +0000 |
tree | 01d77f1ee9d5ca41d1ed88ed7443bb65811a4298 | |
parent | ff7e7a78ce968db5401a6bdebbe7bdcc795193d3 [diff] |
pw_spi: Correct full-duplex behavior of linux_spi Prior to this change, LinuxInitiator::WriteRead() would always perform a compound transfer, sending write_buffer *then* receiving read_buffer, i.e. a half-duplex write-then-read operation. This corrects that behavior to match the interface which describes a full-duplex (simultaneous write and read) operation. Note that `struct spi_ioc_transfer` only has a single `len` field describing the number of bytes to send and receive in that transfer. Because write_buffer and read_buffer could have different sizes, this implementation will split the transaction into two transfers if necessary to transfer the longer of the two. Also add missing "override" to ~LinuxInitiator(), and remove a few extraneous #includes. Test: bazel test //pw_spi:linux_spi_test Test: Execute a test application on a Linux host connected to a SPI responder MCU programmed to send a fixed message with no dummy cycles. Test: Call WriteRead() with buffers of the same size. Verify message is received in read_buffer. Verify via logic analyzer that a single transaction is performed (no extra clock cycles). Test: Call WriteRead with write_buffer longer than read_buffer. Verify (partial) message is received in read_buffer. Verify via logic analyzer that two transfers were performed (indicated by inter-transfer delay with CS still active), and only write_buffer.size() bytes were transmitted. Test: Call WriteRead with read_buffer longer than write_buffer. Verify message is received in read_buffer. Verify via logic analyzer that two transfers were performed, and the transmitted data was zero-padded out to read_buffer.size(). Bug: b/316067628 Change-Id: I4bec1d46286384709eca052322a7cf3047d26296 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/192591 Reviewed-by: Mark Slevinsky <markslevinsky@google.com> Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Jonathon Reinhart <jrreinhart@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.