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

spi: interdependent operations/operations sharing data #642

Open
jordens opened this issue Nov 25, 2024 · 0 comments
Open

spi: interdependent operations/operations sharing data #642

jordens opened this issue Nov 25, 2024 · 0 comments

Comments

@jordens
Copy link
Contributor

jordens commented Nov 25, 2024

There is currently no support for SPI operations (in a transaction slice) to mutably share data.

Use case: SPI devices often implement the following behavior (happy to provide numerous examples if this is in doubt) to implement an atomic update of several bits.

  • Load "active" bits into the SPI shift register (that sits between SDI and SDO) on CS assertion.
  • Load new bits from shift register into "active" register on CS deassertion.

The intention is to implement a read of the active bits without altering them (not even a transient alteration).

The approach would be to keep CS asserted accross a transaction of reading and writing the same values again.

let mut bits = [0; 4];
spi_device.transaction(&mut [Operation::Read(&mut bits), Operation::Write(&bits)]);

This is currently not possible with the Operation enum.

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

No branches or pull requests

1 participant