SPI connection between ADICUP3029 and an IMU

Hi there,

I'm having problems getting the SPI connection working between the ADICUP3029, the master device and the ADIS1640 IMU, the slave.

Before I can get the useful data from the IMU, I'm just trying to get the Product ID from the slave device so that I can confirm the SPI connection is working.

 

However I can't get any data back when I try to read the SPI register, I believe the issue could be when the adi_spi_MasterReadWrite function is called however I could be possibly missing a step or two somewhere!

I've attached the crosscore project folder and would greatly appreciate if someone would be able to take a look at the code, thanks in advance for your help.

Kind regards,

Matt

Main code is here:

/*****************************************************************************
 * ADIS16460.c
 *****************************************************************************/

#include <sys/platform.h>
#include "adi_initialize.h"
#include "ADIS16460.h"
#include "adi_initialize.h"
//#include <adi_timestamp.h>
#include "common.h"
#include "platform_drivers.h"
#include "ADIS16460.h"
#include "Timer.h"
#include "math.h"

#define AD7793_COMM_ADR(x)   (((x) & 0x07) << 3)

uint8_t reg_size[8] = {1, 2, 2, 3, 1, 1, 1, 1};

void ADIS16460_WriteRegister(uint8_t ui8address, uint32_t ui32data)
{
    /* Set value (write command + register address) to write in COMM
     * register */
    uint8_t ui8reg_adrr=0;

    /* Write register value */
    SPI_Write(ui8reg_adrr, ui32data,  2);
}

/**
   @brief Read register value

   @param ui8address - register address

   @return uint32_t - register value
**/
uint32_t ADIS16460_ReadRegister(uint8_t ui8address)
{
    /* Set value (read command + register address) to write in COMM register */
	//uint8_t ui8reg_adrr = ((1<<6) | AD7793_COMM_ADR(ui8address));

    /* Read and return register value */
    return SPI_Read(ui8address, 1);
}

int main(int argc, char *argv[])
{

	adi_initComponents();
	
	timer_start();

	/* Begin adding your custom code here */

	SPI_Init();

	//ADIS16460_WriteRegister(0xFF, 0x00);

	uint8_t PROD_ID = 0x56;
	ADIS16460_ReadRegister(PROD_ID);

	/* Set value (read command + register address) to write in COMM register */
	//  uint8_t ui8reg_adrr = (AD7793_COMM_READ | AD7793_COMM_ADR(ui8address));
	/* Read and return register value */
	//return SPI_Read(ui8reg_adrr, reg_size[ui8address]);



	//ADIS16460_WriteRegister(0xFF, 0x00);
	/* Write register value */
	//SPI_Write(ui8reg_adrr, ui32data,  reg_size[ui8address]);


	return 0;
}

SPI Read function:

uint32_t SPI_Read(uint8_t ui8address, uint8_t ui8bytes)
{
    uint32_t ui32AdcCodes = 0, status;
    uint8_t size = ui8bytes + 1;
    uint8_t ui8counter, rx_buff[size];
    uint8_t tx_buff[size];
    static uint8_t ui8read_rx;

    tx_buff[0] = ui8address;
    for(ui8counter = 1; ui8counter <= ui8bytes; ui8counter++)
        tx_buff[ui8counter] = 0x01;

    /* Configure SPI telegram */
    spi_telegram.pTransmitter		= tx_buff;
    spi_telegram.TransmitterBytes	= size; /* Transmit 1 byte of address*/
    spi_telegram.nTxIncrement		= 1; /* Address not incremented */
    spi_telegram.pReceiver 			= rx_buff;
    spi_telegram.ReceiverBytes 		= size;
    spi_telegram.nRxIncrement 		= 1; /* No data alignment */
    spi_telegram.bDMA 				= false; /* No DMA */
    spi_telegram.bRD_CTL 			= false; /* Full-duplex */

    /* Transmit register address and receive the read */
    status = adi_spi_MasterReadWrite(p_spi_device_handler,
                                     &spi_telegram);
    if(status != ADI_SPI_SUCCESS)
        return SPI_FAILURE;

    /* Compile data in an 32 bit unsigned integer format */
    for(ui8counter = 1; ui8counter <= ui8bytes; ui8counter++) {
        ui8read_rx = rx_buff[ui8counter];
        ui32AdcCodes = (uint32_t)((ui32AdcCodes << 8) | ui8read_rx);
    }

    return ui32AdcCodes;
}

.ADIS16460.zip