From 42a907035b2191fb9cebbd0424ffa12e9c364354 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 18 Oct 2020 21:22:56 +0200 Subject: [PATCH] spi: incorporate change from GH issue feedback Signed-off-by: deadprogram --- apa102/apa102.go | 8 -------- spi.go | 6 ++++++ wifinina/wifinina.go | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/apa102/apa102.go b/apa102/apa102.go index a2d6ed9..4a8ab9a 100644 --- a/apa102/apa102.go +++ b/apa102/apa102.go @@ -29,14 +29,6 @@ type Device struct { Order int } -// The SPI interface specifies the minimum functionality that a bus -// implementation needs to provide for use by the APA102 driver. Hardware -// SPI from the TinyGo "machine" package implements this already. -// type SPI interface { -// Tx(w, r []byte) error -// Transfer(b byte) (byte, error) -// } - // New returns a new APA102 driver. Pass in a fully configured SPI bus. func New(b drivers.SPI) Device { return Device{bus: b, Order: BGR} diff --git a/spi.go b/spi.go index f908afe..aa9e410 100644 --- a/spi.go +++ b/spi.go @@ -2,6 +2,12 @@ package drivers // SPI represents a SPI bus. It is implemented by the machine.SPI type. type SPI interface { + // Tx transmits the given buffer w and receives at the same time the buffer r. + // The two buffers must be the same length. The only exception is when w or r are nil, + // in which case Tx only transmits (without receiving) or only receives (while sending 0 bytes). Tx(w, r []byte) error + + // Transfer writes a single byte out on the SPI bus and receives a byte at the same time. + // If you want to transfer multiple bytes, it is more efficient to use Tx instead. Transfer(b byte) (byte, error) } diff --git a/wifinina/wifinina.go b/wifinina/wifinina.go index 64f1129..a984ff3 100644 --- a/wifinina/wifinina.go +++ b/wifinina/wifinina.go @@ -269,7 +269,7 @@ type Device struct { ssids [10]string } -// New returns a new Wiifinina driver. +// New returns a new Wifinina driver. func New(bus drivers.SPI, csPin, ackPin, gpio0Pin, resetPin machine.Pin) *Device { return &Device{ SPI: bus,