diff --git a/host/generic/spibus.go b/host/generic/spibus.go index e00150c..f682daa 100644 --- a/host/generic/spibus.go +++ b/host/generic/spibus.go @@ -233,6 +233,13 @@ func (b *spiBus) ReceiveByte() (byte, error) { return byte(d[0]), nil } +func (b *spiBus) Write(data []byte) (n int, err error) { + if err := b.init(); err != nil { + return 0, err + } + return b.file.Write(data) +} + func (b *spiBus) Close() error { b.mu.Lock() defer b.mu.Unlock() diff --git a/spi.go b/spi.go index e6aecb0..e7b9671 100644 --- a/spi.go +++ b/spi.go @@ -2,6 +2,10 @@ package embd +import ( + "io" +) + const ( spiCpha = 0x01 spiCpol = 0x02 @@ -21,6 +25,8 @@ const ( // SPIBus interface allows interaction with the SPI bus. type SPIBus interface { + io.Writer + // TransferAndRecieveData transmits data in a buffer(slice) and receives into it. TransferAndRecieveData(dataBuffer []uint8) error