imx R/W SPI slave device

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx R/W SPI slave device

746 Views
宗標廖
Contributor V

Hello,Community

I want to R/W a spi slave device on imx6q board.

Could someone tell me the difference between the following code A and B.

Code A:

---------------------------------------------

struct spi_ioc_transfer tr[2] = {
     {
      .tx_buf = (unsigned long)tbuf,
      .len = bytes,
  },
 
  {
      .rx_buf = (unsigned long)rbuf,
      .len = bytes,
  }
};

ret = ioctl(fd, SPI_IOC_MESSAGE(2), tr);

-------------------------------------------------

Code B:

---------------------------------------------

struct spi_ioc_transfer tr[1] = {
     {
      .tx_buf = (unsigned long)tbuf,

      .rx_buf = (unsigned long)rbuf,
      .len = bytes,
    }
};

ret = ioctl(fd, SPI_IOC_MESSAGE(1), tr);

-------------------------------------------------

Thank you!

Best Regards!

Labels (2)
0 Kudos
1 Reply

453 Views
igorpadykov
NXP Employee
NXP Employee

Hi 宗標 廖

seems case B each transfer is half duplex (either direction), while case A

full duplex, with message SPI_IOC_MESSAGE(2) write is followed by a read.

http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/spi/spidev.h?v=2.6.25

Mobile Maniac: Linux - Accessing SPI Bus from User Space - Part II

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos