[i2c] i2c-dev driver
Arnold
abo_gwapo at yahoo.com
Tue Aug 29 08:53:39 CEST 2006
Hi Frodol,
I'm using an omap5912 and would like to write and
read
thru i2c. Below are the debug msg aswell as the
code.
Debug msg:
#./i2c_test
(OJ) adapter number = OMAP I2C adapter
Writing to i2c error: Remote I/O error
written -1 bytes
Code:
#define I2C_SLAVE 0x0703
#define BUFFER_SIZE 32
int adapter_nr = 0;
int addr = 0x40; /* The I2C address */
sprintf(filename,"/dev/i2c-%d",adapter_nr);
if ((file = open(filename,O_RDWR)) < 0) {
printf("Error Opening File\n");
exit(1);
}
if (ioctl(file,I2C_SLAVE,addr) < 0) {
exit(1);
}
if (write(file,buffer,sizeof(char) * BUFFER_SIZE) <
0)
{
perror("Error Writing:");
exit(1);
}
printf("written %d bytes\n",i);
memset(buffer,0,BUFFER_SIZE);
if(read(file,buffer,sizeof(char) * BUFFER_SIZE) <
0
) {
perror("Error Reading:");
exit(1);
}
printf("read %d bytes\n",i);
for(i=0;i<BUFFER_SIZE;i++)
{
printf("%c",buffer[i]);
}
printf("\n");
close(file);
I hope you could help me with my problem?
Thanks,
OJ
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the i2c
mailing list