SPI/QSPI send-receive with 52259

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

SPI/QSPI send-receive with 52259

Jump to solution
2,669 Views
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 Kudos
1 Solution
488 Views
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 

View solution in original post

0 Kudos
2 Replies
489 Views
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 Kudos
488 Views
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 Kudos