embed-linux version:linux-2.6.39-exp
vmware-linux:ubuntu14.04
hardware: core chip at91sam9x25
cross-compile:arm-none-linux-gnueabi-gcc 4.5.2
code:
#include stdio.h
#include stdlib.h
#include unistd.h
#include sys/ioctl.h
#include sys/types.h
#include sys/stat.h
#include fcntl.h
//#include sys/select.h
#include sys/time.h
#include errno.h
#define ioctl_test 1
#if ioctl_test
#define num 5
#define I2C_TENBIT 0x0704
#define I2C_RETRIES 0x0701
#define
I2C_SLAVE_FORCE 0x0706
#define I2C_ADDR 0x51
int main(int argc,char *argv[])
{
int fd,i,size,error,addr;
char data[num]={0};
addr=I2C_ADDR;
fd=open("/dev/i2c-0",O_RDWR);
if(fd<0) //打开memdev设备
{
p