Skip to contentSkip to conversation

i2c fo romap5912 help!

DISCUSSION 李玮 1 participant 1 message Dec 28, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

李玮

author
#1 lore raw

Hi,
I am using an osk5912 and would like to light the led D3
on the board thru the i2c driver.Now I have seen the dev file under the /dev and can open the file /dev/i2c,but when i use ioctl to set i2c, it says that Device or resoure busy.Please help me! thanks!
my test program is fellowed.

#define I2C_SLAVE 0x0703

int main(void)
{
int file;
int
int adapter_nr=0;
int addr = 0x48;
char filename[20] = {0};
sprintf(filename,"/dev/i2c-%d",adapter_nr);
if ((file = open("/dev/i2c/0",O_RDWR)) < 0);

 {
     perror("err");
     exit(1);
 }
 if(ioctl(file,I2C_SLAVE,addr) < 0 )
 {
      perror("err");

// exit(1);
}

int reg = 0x10;
char buf[10]={0};
buf[0] = reg;
buf[1] = 0x43;
buf[2] = 0x65;
abc = write(file,buf,3);
printf("the abc is %d\n",abc);
close(file);
return 0;
}