[FEATURE REQUEST] Prepare+Execute semantics for SPI/I2C/I3C/UART/etc.

Open
#714 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Review the existing SPI, I2C, I3C, and UART bus traits and their DMA-related abstractions, if present. Determine whether prepare/execute semantics belong in bus-specific traits or a higher-level Stream trait; the issue names no files or tests, and completion would require an agreed API design and corresponding validation.

Written by the indexing model from the issue text.

Description

In short: I would like to propose - or ask why it hasn't been added yet, if there was an attempt already - a semantic that allows splitting a transaction into a prepare and an execute step.

Background
I am working on a nrf52 based device that pulls data from an IMU. I want the maximum possible sample rate and thus have to utilize the SPI bus as efficient as possible. For that I have set up the IMU in FIFO mode with a watermark interrupt so that I know exactly how many bytes I have to/can transfer from the FIFO in a single read operation.
On the nrf52 this is all implemented via DMA, which takes time to set up.

Proposal
If you know how many bytes you need to transfer but you "don't know" the exact time to start, having prepared the DMA request and the channel set up would allow to trigger the transfer after an GPIO interrupt (in software or via event peripheral) and await that DMA transfer complete event.
DMA setup + trigger + complete-event is a - as far as I have seen - very common architecture which would lend itself to a generic trait.

I am not sure whether such a trait would be a SPI/I2C/UART specific thing or a higher-level Stream-trait that needs some added methods in a bus-trait.

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.