I am using the i2c smbus protocol..
for(i=0;i<len+1;i++)
buf[i] = (char)(i);
len = i2c_eeprom_smbus(i2cdev,devAddr,offset,buf,len,0,offset);
break;
int i2c_eeprom_smbus(
int file,
unsigned short deviceAddr,
unsigned char offset,
char *buf,
int len,unsigned char rd_wr,unsigned char cmd)
{
struct i2c_smbus_ioctl_data smbusp;
union i2c_smbus_data smdata;
// struct i2c_msg i2cmsg;
int i;
//memset(&smbusp,0,sizeof(smbusp));
smbusp.read_write = rd_wr;
smbusp.command = cmd;
smbusp.size = len;
smbusp.data = &smdata;
smdata.byte = buf;
smdata.word = buf;
smdata.block[0] = len;
if((i=ioctl(file, I2C_SMBUS, &smbusp)) < 0)
{
perror("ioctl()");
fprintf(stderr, "ioctl returned %d\n",i);
return -1;
}
return len;
}
How do I populate these structures and unions: struct i2c_smbus_ioctl_data smbusp;
union i2c_smbus_data smdata;
here smdata has three fields - can u pl explain the significance of each field..
Kindly throw some light on this..
Thanks
Regards,
Abhijit