I had been trying to use SPI 0 port of QN9020 to interface with AD7793 ADC. I tried to use the drivers and spi example provided in QBLUE package.
I had issues in reading and writing into the slave device. The signals probed on the CRO looked perfect but the SPI read API was not working properly as expected. There is no help available on the internet. So had to spend a lot of time to figure out the issue.
Every write operation has to be followed by dummy read from the buffer. This will clear the RX fifo before reading the actual data.
For example, I have modified the tx function in driver_qn9020.h file as below ,
After I made this change, i was able to read properly all the data. Without this change if i want to read one byte from an address in the slave, then i have to call spi_read twice, and the result data would be JUNKBYTE+GOODBYTE
If i have to write a data first and then read ( WR_ADDR + DATA _W+ RD_DATA+DATA_R), then i had to read 4 times resulting JUNKBYTE+JUNKBYTE+JUNKBYTE+GOODBYTE.
So all the above JUNKBYTE are nothing but bytes pushed to RXFIFO during write operations, and they remain uncleared.
qblue should either fix this or give an API that will clear the RXFIFO.