Failure to use the ADI SPI driver on ADuCM4050

Hi,
I have difficulties to use the SPI driver of the ADuCM4050:
In my system SPI1 is connected to ADXL362 (CS0) and SD card (CS1). SPI2 is connected to IS25LP128 (CS0, Flash memory).

Right now the SD card is not implemented and there is no card in the circuit.

Here is the function I use to generate the SPI transaction for both:

bool SPI_Action(ADI_SPI_HANDLE handle, uint16_t wr_len, const uint8_t *wr_data, uint16_t rd_len, void *rd_data)
{
ADI_SPI_TRANSCEIVER Mtransceive __attribute__((aligned(4)));
//uint8_t DummyRxBuffer[2] __attribute__((aligned(2)));

assert(((int)wr_data % 2 == 0) && ((int)rd_data % 2 == 0));

Mtransceive.pTransmitter = (uint8_t *)wr_data;
Mtransceive.TransmitterBytes = wr_len;
Mtransceive.nTxIncrement = 0;
Mtransceive.pReceiver = rd_data;
Mtransceive.ReceiverBytes = rd_len;
Mtransceive.nRxIncrement = 0;
Mtransceive.bDMA = true;
Mtransceive.bRD_CTL = (rd_len == 0) ? false : true; // Ignore the activity on MISO during write;

return (ADI_SPI_SUCCESS == adi_spi_MasterReadWrite(handle, (const ADI_SPI_TRANSCEIVER* const)&Mtransceive));
}

if I initialize Mtransceive.bRD_CTL = true, then writing 2 bytes and read 0 bytes from the ADXL362 causes the call to adi_spi_MasterReadWrite() to never ends.
if I initialize Mtransceive.bRD_CTL = false, then the previous problem is solved, but then I always read bytes of 0xFF from the flash IC...

This is how I finally arrived to the code I have just sent you that contains a strange condition on the value that is assigned to bRD_CTL field..., but I fail to understand what happens here.

My question is what is the exact role of the bRD_CTL and what is the source of the behavior I am observing?

Thanks,
Kobi

Parents Reply Children
No Data