Skip to content

Commit 9f630d9

Browse files
committed
reference/machine: add SPI DMA support
1 parent df4b869 commit 9f630d9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

content/docs/reference/machine.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,30 @@ The `Tx` performs the actual SPI transaction, and return an error if there was a
148148

149149
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.
150150

151+
```go
152+
func (spi SPI) IsAsync() bool
153+
```
154+
155+
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.
156+
157+
```go
158+
func (spi SPI) StartTx(w, r []byte) error
159+
```
160+
161+
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.
162+
163+
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.
164+
165+
If `IsAsync` returns false, this is an alias for `Tx`.
166+
167+
```go
168+
func (spi SPI) Wait() error
169+
```
170+
171+
Wait until all active transactions (started by `StartTx`) have finished. The buffers provided in `StartTx` will be available after calling `Wait`.
172+
173+
If `IsAsync` returns false, this is a no-op.
174+
151175

152176
## I2C
153177

0 commit comments

Comments
 (0)