|
|
|
@ -40,18 +40,27 @@ void SpiPort::Close()
|
|
|
|
|
|
|
|
|
|
int SpiPort::spi_transfer(unsigned char *txbuf, unsigned char *rxbuf, int bytes)
|
|
|
|
|
{
|
|
|
|
|
struct spi_ioc_transfer xfer[2];
|
|
|
|
|
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
struct spi_ioc_transfer xfer[2];
|
|
|
|
|
memset(xfer, 0, sizeof(xfer));
|
|
|
|
|
|
|
|
|
|
xfer[0].tx_buf = (__u64)txbuf;
|
|
|
|
|
xfer[0].rx_buf = (__u64)rxbuf;
|
|
|
|
|
xfer[0].len = bytes;
|
|
|
|
|
xfer[0].delay_usecs = 2;
|
|
|
|
|
|
|
|
|
|
status = ioctl(m_fd, SPI_IOC_MESSAGE(1), xfer);
|
|
|
|
|
#else
|
|
|
|
|
struct spi_ioc_transfer xfer;
|
|
|
|
|
memset(&xfer, 0, sizeof(xfer));
|
|
|
|
|
xfer.tx_buf = (__u64)txbuf;
|
|
|
|
|
xfer.rx_buf = (__u64)rxbuf;
|
|
|
|
|
xfer.len = bytes;
|
|
|
|
|
xfer.delay_usecs = 2;
|
|
|
|
|
|
|
|
|
|
status = ioctl(m_fd, SPI_IOC_MESSAGE(1), &xfer);
|
|
|
|
|
#endif
|
|
|
|
|
if (status < 0)
|
|
|
|
|
{
|
|
|
|
|
perror("SPI_IOC_MESSAGE");
|
|
|
|
|