Hi,
I’m on a new problem,
I am currently trying to initialize my MAX9296 deserializer and my MAX9271 serializer in the userland with i2c tools.
firstly I would just like to know on which bus my serializer and deserialiser is located.
I browse the different buses and I look if at the address 0x40 ( infomration given by the datasheet), and I find my serializer on bus 4 but when I read the buffer I only see 0xff, I don’t think is normal.
Is there any other way to initialize my serializer and deserializer.
thank you for your time.
the code is below:
#include <unistd.h> //Needed for I2C port
#include <fcntl.h> //Needed for I2C port
#include <sys/ioctl.h> //Needed for I2C port
#include <linux/i2c-dev.h> //Needed for I2C port
#include <stdio.h>
int main(){
int file_i2c;
int value;
int length;
unsigned char buffer[60] = {0};
//----- OPEN THE I2C BUS -----
char *filename = (char*)"/dev/i2c-4";
if ((file_i2c = open(filename, O_RDWR)) < 0)
{
//ERROR HANDLING: you can check errno to see what went wrong
printf("Failed to open the i2c bus");
return 1;
}
int addr = 0x80; //<<<<<The I2C address of the slave
for(int i = 0x00 ; i<0xff ; i++ ){
if (ioctl(file_i2c, I2C_SLAVE, i) < 0)
{
printf("Failed to acquire bus access and/or talk to slave. ");
printf("adresse ko %d\n",i);
//ERROR HANDLING; you can check errno to see what went wrong
//return 1;
}
else {
length = 2;
printf("IOCTL OK adresse : %d ",i);
buffer[0] = (unsigned char)i;
buffer[1] = 0;
write(file_i2c, buffer , 2);
value = read(file_i2c, buffer, length);
printf("value return %d\n ",value);
if (value != -1){
for( int j= 0 ; j < 60 ; j++ )
{
printf("data lue[%d] = %x \n",j,buffer[j]);
}
}
}
}
//----- READ BYTES -----
//<<< Number of bytes to read
return 0;
}