mirror of
https://github.com/kidoman/embd
synced 2024-06-28 22:52:56 +02:00
spi: added write method to allow writing without transfer delays
This commit is contained in:
parent
c78563a341
commit
1efc3b632e
|
@ -233,6 +233,14 @@ func (b *spiBus) ReceiveByte() (byte, error) {
|
||||||
return byte(d[0]), nil
|
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 {
|
func (b *spiBus) Close() error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
3
spi.go
3
spi.go
|
@ -33,6 +33,9 @@ type SPIBus interface {
|
||||||
// ReceiveByte receives a byte data.
|
// ReceiveByte receives a byte data.
|
||||||
ReceiveByte() (byte, error)
|
ReceiveByte() (byte, error)
|
||||||
|
|
||||||
|
// WriteByte writes a buffer of data
|
||||||
|
Write([]uint8) (error)
|
||||||
|
|
||||||
// Close releases the resources associated with the bus.
|
// Close releases the resources associated with the bus.
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user