mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
spi: added write method to allow writing without transfer delays
This commit is contained in:
parent
c78563a341
commit
b6f5d8d640
@ -233,6 +233,13 @@ func (b *spiBus) ReceiveByte() (byte, error) {
|
|||||||
return byte(d[0]), nil
|
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 {
|
func (b *spiBus) Close() error {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
6
spi.go
6
spi.go
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
package embd
|
package embd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
spiCpha = 0x01
|
spiCpha = 0x01
|
||||||
spiCpol = 0x02
|
spiCpol = 0x02
|
||||||
@ -21,6 +25,8 @@ const (
|
|||||||
|
|
||||||
// SPIBus interface allows interaction with the SPI bus.
|
// SPIBus interface allows interaction with the SPI bus.
|
||||||
type SPIBus interface {
|
type SPIBus interface {
|
||||||
|
io.Writer
|
||||||
|
|
||||||
// TransferAndRecieveData transmits data in a buffer(slice) and receives into it.
|
// TransferAndRecieveData transmits data in a buffer(slice) and receives into it.
|
||||||
TransferAndRecieveData(dataBuffer []uint8) error
|
TransferAndRecieveData(dataBuffer []uint8) error
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user