SPI Device with cgo
This commit is contained in:
parent
67daba17ef
commit
ea4fca9a65
1 changed files with 1 additions and 1 deletions
|
@ -107,7 +107,7 @@ func NewSPIDevice() (*SPIDevice, error) {
|
||||||
func (d *SPIDevice) Xfer(tx []byte) ([]byte, error) {
|
func (d *SPIDevice) Xfer(tx []byte) ([]byte, error) {
|
||||||
length := len(tx)
|
length := len(tx)
|
||||||
rx := make([]byte, length)
|
rx := make([]byte, length)
|
||||||
ret := C.spi_xfer(d.fd, unsafe.Pointer(&tx[0]), unsafe.Pointer(&rx[0]), C.int(length))
|
ret := C.spi_xfer(d.fd, (*C.char)(unsafe.Pointer(&tx[0])), (*C.char)(unsafe.Pointer(&rx[0])), C.int(length))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return nil, errors.New("could not xfer")
|
return nil, errors.New("could not xfer")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue