spi: interdependent operations/operations sharing data

Open
#642 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
embedded-iot

Research direction

Start by locating the Operation enum and the spi_device.transaction API referenced in the issue. Determine how a transaction could let a read buffer be reused by a later write while chip select remains asserted; done means the stated read-then-write use case is supported without altering the active bits.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Rust
Stars
2.7k
Forks
282
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-embedded/embedded-hal

All issues in rust-embedded/embedded-hal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.