Added SPIBus.Write to allow writing without transfer delays.

This commit is contained in:
Ben Delarre 2015-01-13 13:43:23 -08:00
parent 03b5f0ceb6
commit 9d108ee58f
2 changed files with 11 additions and 0 deletions

View File

@ -233,6 +233,14 @@ func (b *spiBus) ReceiveByte() (byte, error) {
return byte(d[0]), nil
}
func (b *spiBus) Write(data []uint8) (error) {
if err := b.init(); err != nil {
return err
}
_, err := b.file.Write(data)
return err
}
func (b *spiBus) Close() error {
b.mu.Lock()
defer b.mu.Unlock()

3
spi.go
View File

@ -33,6 +33,9 @@ type SPIBus interface {
// ReceiveByte receives a byte data.
ReceiveByte() (byte, error)
// WriteByte writes a buffer of data
Write([]uint8) (error)
// Close releases the resources associated with the bus.
Close() error
}