#include #define file_i2c "/dev/i2c-3"
#define BUFF_SIZE 32
#define I2C_SLAVE 0x0703 //IIC从器件的地址设置
#define I2C_RETRIES 0x0701
#define I2C_TIMEOUT 0x0702
#define I2C_RDWR 0x0707
#define I2C_M_TEN 0x0010
#define I2C_M_RD 0x0001
struct i2c_msg{
unsigned short addr;
unsigned short flags;
unsigned short len;
unsigned char *buf;
};
struct i2c_rdwr_ioctl_data{
struct i2c_msg *msgs;
int nmsgs; /* nmsgs这个数量决定了有多少开始信号,对于“单开始时序”,取1*/
};
int main(void)
{
unsigned int fd_i2c,ret;
struct i2c_rdwr_ioctl_data e2prom_data;
fd_i2c = open(file_i2c,O_RDWR);
if(fd_i2c<0){
printf("open error \n");
exit(0);
}
e2prom_