how to access I2C device by i2c interface in arm-linux

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

charles0420
Posts: 1
Joined: Thu Sep 09, 2004 5:09 am

how to access I2C device by i2c interface in arm-linux

Thu Sep 09, 2004 5:37 am

I found I cannot access to I2C device through i2c interface.
Here below is my code: /* running in linux-2.4.19-rmk7 */
if (( fdI2C = open("/dev/i2c/0",O_RDWR)) < 0)
{
printf("Can't open /dev/i2c/0\n");
return;
}
int i2c_addr = 0x50;
if (ioctl(fdI2C,I2C_SLAVE,i2c_addr) < 0)
{
printf("Can't set address\n");
close(fdI2C);
return;
}
buf[0] = hi_addr;
buf[1] = lo_addr;
buf[2] = data2send;
if ((cnt = write (fdI2C, buf, 3)) < 0)
return;
close(fdI2C);

No any signal has been sent when i check the SDA and SCL lines from
Oscillscope. can anybody tell me what is the problem?? help????

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests