SPI/QSPI send-receive with 52259

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SPI/QSPI send-receive with 52259

跳至解决方案
3,323 次查看
Stefan_75
Contributor II

Hi,

 

I´m trying to send-receive with the SPI dirver (MQX 3.4).

 

I´m using following code:

 

--- start ---

  

/*init*/

 

 SPI_HW_st.SPI_fd = fopen ("spi0:", NULL);
 

 param = SPI_DEVICE_BIG_ENDIAN;
 error = ioctl (SPI_HW_st.SPI_fd, IO_IOCTL_SPI_SET_ENDIAN, &param);
 param = (SPI_DEVICE_MASTER_MODE);  
 error = ioctl(SPI_HW_st.SPI_fd, IO_IOCTL_SPI_SET_TRANSFER_MODE, &param);      

 param = SPI_CLK_POL_PHA_MODE1;
 error = ioctl (SPI_HW_st.SPI_fd, IO_IOCTL_SPI_SET_MODE, &param);
 param = 200000;

 error = ioctl(SPI_HW_st.SPI_fd, IO_IOCTL_SPI_SET_BAUD, &param);

 

/*code*/

 

UINT8 i [100];

 

write(SPI_HW_st.SPI_fd , i, 100);

 

-- end ---

 

There is no result in i.

 

At the beginning of the programm I don´t know exactly the length of the SPI chain. Therefore I have to detect it and compare the written results with the received.

 

How can I manage, that the result will written to i?

Does anybody knows where´s the QSPI driver from MQX 3.3 is gone?

 

The data are sent to the chain and also received at the QSPI-DIN pin. The chip-select signals are managed by GPIO pins.

 

Thanks for any hint.

 

 

Stefan

0 项奖励
回复
1 解答
1,142 次查看
Stefan_75
Contributor II

Hi,

 

it will work as requested with the read command.

 

The problem in understanding was, that I hadn´t recognised, that I´m not working on the QSPI buffer.

 

wrong:

 

  write(SPI_HW_st.SPI_fd , buffer, length);

  read(SPI_HW_st.SPI_fd , buffer, length);

 

right:

 

  read(SPI_HW_st.SPI_fd , buffer, length);

 

Therefore the write command isn´t necessary to send and get any data from the SPI chain.

 

Stefan 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,143 次查看
Stefan_75
Contributor II

Hi,

 

it will work as requested with the read command.

 

The problem in understanding was, that I hadn´t recognised, that I´m not working on the QSPI buffer.

 

wrong:

 

  write(SPI_HW_st.SPI_fd , buffer, length);

  read(SPI_HW_st.SPI_fd , buffer, length);

 

right:

 

  read(SPI_HW_st.SPI_fd , buffer, length);

 

Therefore the write command isn´t necessary to send and get any data from the SPI chain.

 

Stefan 

0 项奖励
回复
1,142 次查看
PetrM
Senior Contributor I

Hi,

 

yes, using SPI read() in master mode results in writing dummy bytes to do actual read (you are not receiving, what you have just sent, but what slave device passes through).

Regarding QSPI, it was merged to SPI driver, so in your code you always use SPI regardless of physical interface (QSPI, DSPI, SPI).

 

Regards,

PetrM

0 项奖励
回复