AnsweredAssumed Answered

AD7175-8 driver usage

Question asked by juraa on Aug 1, 2018
Latest reply on Aug 1, 2018 by spopa

Hello, 

Found given example how to use AD7175-8 driver. But it looks like example describes older version of driver. 

/* Create a new driver instance */struct ad717x_device my_ad7176_2;struct ad717x_device *ad7176_2_handler = &my_ad7176_2; /* Other variables */long timeout = 1000;long ret;long sample;/* Initialize the driver instance and let's use the ad7176_2_regs array defined in ad7176_2_regs.h */#define AD7176_2_INITAD717X_Setup(ad7176_2_handler, AD7176_2_SLAVE_ID, (ad717x_st_reg *)&ad7176_2_regs,             sizeof(ad7176_2_regs) / sizeof(ad7176_2_regs[0])); /* Read data from the ADC */ret = AD717X_WaitForReady(ad7176_2_handler, timeout);if (ret < 0)    /* Something went wrong, check the value of ret! */  ret = AD717X_ReadData(ad7176_2_handler, &sample);if (ret < 0)        /* Something went wrong, check the value of ret! */

I am using version where instead of 

int32_t AD717X_Setup(struct ad717x_device *device, uint8_t slave_select, 
                                                        ad717x_st_reg *regs, uint8_t num_regs)
is

int32_t AD717X_Init(ad717x_dev **device,ad717x_init_param init_param)

and

int32_t AD717X_WaitForReady(struct ad717x_device *device, uint32_t timeout)
int32_t AD717X_ReadData(struct ad717x_device *device, int32_t* pData)

is

int32_t AD717X_WaitForReady(ad717x_dev *device, uint32_t timeout)
int32_t AD717X_ReadData(ad717x_dev *device, int32_t* pData)

My code to use driver:

 


ad717x_dev *pDevice;
ad717x_dev *ad7175_8_handler = pDevice;

ad717x_init_param init_param =
{
{GENERIC_SPI ,AD7175_8_SLAVE_ID,8000000,SPI_MODE_3,_LATB2 },//_LATB2
(ad717x_st_reg *)&ad7175_8_regs,
sizeof(ad7175_8_regs) / sizeof(ad7175_8_regs[0])
};

 

AD717X_Init(&pDevice, init_param);

long timeout = 1000;
long sample;

ret = AD717X_WaitForReady(ad7175_8_handler, timeout);
if (ret < 0) {printf ("ret1<0"); }

 

ret = AD717X_ReadData(ad7175_8_handler, &sample);
if (ret < 0) {printf ("ret2<0");}

 

I am not sure how to call AD717X_WaitForReady and AD717X_ReadData.

 

Thank you

Outcomes