Skip to content

Proposal: add DMA support to SPI #342

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

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
reference/machine: add SPI DMA support
  • Loading branch information
aykevl committed Nov 4, 2023
commit 9f630d94775a0f72ae1a55010a2533206eab8638
24 changes: 24 additions & 0 deletions content/docs/reference/machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,30 @@ The `Tx` performs the actual SPI transaction, and return an error if there was a

Some chips may also support mismatched lengths of `w` and `r`, in which case they will behave like above for the remaining bytes in the byte slice that's the longest of the two.

```go
func (spi SPI) IsAsync() bool
```

Return whether the SPI supports asynchronous operation (usually using [DMA](https://en.wikipedia.org/wiki/Direct_memory_access)). Asynchronous operation may be supported for some or all transfers, for example it may only be supported for send-only transfers.

```go
func (spi SPI) StartTx(w, r []byte) error
```

Start a SPI transmission in the background (usually, using DMA). This has the same effect as running `Tx` in a goroutine, but doesn't spawn a new goroutine. The `w` and `r` byte slices must not be used while the transmission is in progress, but must be stored somewhere outside the `StartTx` function to avoid garbage collecting them.

It is allowed to start multiple transactions without waiting for the first to finish. They will have the effect as if `Tx` was called multiple times in sequence. Lots of hardware won't support this however and will simply wait for the first to finish before starting a new transmission.

If `IsAsync` returns false, this is an alias for `Tx`.

```go
func (spi SPI) Wait() error
```

Wait until all active transactions (started by `StartTx`) have finished. The buffers provided in `StartTx` will be available after calling `Wait`.

If `IsAsync` returns false, this is a no-op.


## I2C

Expand Down