mirror of
https://github.com/kidoman/embd
synced 2024-12-22 12:50:19 +01:00
Merge branch 'master' of github.com:kidoman/embd
This commit is contained in:
commit
c3462ff178
@ -38,7 +38,7 @@ func (m *MCP3008) AnalogValueAt(chanNum int) (int, error) {
|
||||
data[2] = 0
|
||||
|
||||
glog.V(2).Infof("mcp3008: sendingdata buffer %v", data)
|
||||
if err := m.Bus.TransferAndRecieveData(data[:]); err != nil {
|
||||
if err := m.Bus.TransferAndReceiveData(data[:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ func (b *spiBus) setDelay() {
|
||||
b.spiTransferData.delayus = delay
|
||||
}
|
||||
|
||||
func (b *spiBus) TransferAndRecieveData(dataBuffer []uint8) error {
|
||||
func (b *spiBus) TransferAndReceiveData(dataBuffer []uint8) error {
|
||||
if err := b.init(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -205,7 +205,7 @@ func (b *spiBus) ReceiveData(len int) ([]uint8, error) {
|
||||
}
|
||||
|
||||
data := make([]uint8, len)
|
||||
if err := b.TransferAndRecieveData(data); err != nil {
|
||||
if err := b.TransferAndReceiveData(data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
@ -217,7 +217,7 @@ func (b *spiBus) TransferAndReceiveByte(data byte) (byte, error) {
|
||||
}
|
||||
|
||||
d := [1]uint8{uint8(data)}
|
||||
if err := b.TransferAndRecieveData(d[:]); err != nil {
|
||||
if err := b.TransferAndReceiveData(d[:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return d[0], nil
|
||||
@ -229,7 +229,7 @@ func (b *spiBus) ReceiveByte() (byte, error) {
|
||||
}
|
||||
|
||||
var d [1]uint8
|
||||
if err := b.TransferAndRecieveData(d[:]); err != nil {
|
||||
if err := b.TransferAndReceiveData(d[:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return byte(d[0]), nil
|
||||
|
@ -20,7 +20,7 @@ func main() {
|
||||
|
||||
dataBuf := [3]uint8{1, 2, 3}
|
||||
|
||||
if err := spiBus.TransferAndRecieveData(dataBuf[:]); err != nil {
|
||||
if err := spiBus.TransferAndReceiveData(dataBuf[:]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func getSensorValue(bus embd.SPIBus) (uint16, error) {
|
||||
data := [3]uint8{1, 128, 0}
|
||||
|
||||
var err error
|
||||
err = bus.TransferAndRecieveData(data[:])
|
||||
err = bus.TransferAndReceiveData(data[:])
|
||||
if err != nil {
|
||||
return uint16(0), err
|
||||
}
|
||||
|
4
spi.go
4
spi.go
@ -27,8 +27,8 @@ const (
|
||||
type SPIBus interface {
|
||||
io.Writer
|
||||
|
||||
// TransferAndRecieveData transmits data in a buffer(slice) and receives into it.
|
||||
TransferAndRecieveData(dataBuffer []uint8) error
|
||||
// TransferAndReceiveData transmits data in a buffer(slice) and receives into it.
|
||||
TransferAndReceiveData(dataBuffer []uint8) error
|
||||
|
||||
// ReceiveData receives data of length len into a slice.
|
||||
ReceiveData(len int) ([]uint8, error)
|
||||
|
Loading…
x
Reference in New Issue
Block a user