Skip to content

spi: interdependent operations/operations sharing data #642

@jordens

Description

@jordens

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions