spi: added write method to allow writing without transfer delays

This commit is contained in:
Ben Delarre 2015-01-13 13:43:23 -08:00 committed by Kunal Powar
parent c78563a341
commit b6f5d8d640
2 changed files with 13 additions and 0 deletions

View File

@ -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()

6
spi.go
View File

@ -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