 |
|
| Linux Forum Index » Linux Development - Applications » I2C read write error in I2C User application... |
|
Page 1 of 1 |
|
| Author |
Message |
| kracks... |
Posted: Wed Oct 21, 2009 4:40 am |
|
|
|
Guest
|
Hi all,
I have a I2C based touch screen driver TSC2003 which i obtained
from open source.
Ref: http://lists.lm-sensors.org/pipermail/lm-sensors/2005-November/014227.html
I added the driver to kernel (2.6.10)tree and I2C communication in
hard ware is ok.
After booting the system i didnt find any device entry.
I manually created the device entry by
mknod i2c-0 -c 89 0
I am writing an application in which i am polling the I2C device
for reading X anf Y position.
The application source is as follows
int tscfd;
int res;
int addr = 0x48;
#define I2C_SLAVE 0x0703
if ((tscfd = open("/dev/i2c-0",O_RDWR)) < 0)
{
printf("Error Occured while opening Device File.!!
\n");
exit(1);
}
else
{
printf("Device File Opened Successfully !!\n");
}
res = ioctl(tscfd,I2C_SLAVE,addr);
if (res < 0)
{
printf("Error Occrued inside IOCTL");
exit(1);
}
There is no error in the above two functions.
It returns success.
I created a thread and inside that thread polling for i2c read
static void PollingTouchRead(void *arg)
{
char buf[5];
buf[0] = 0xc2; //Reads X position
int ret = 0;
while(1)
{
ret = write(tscfd,buf,1);
if(ret < 0)
{
perror("write ERROR");
}
ret = read(tscfd,buf,1);
if(ret < 0)
{
perror("Read ERROR");
}
}
}
I am getting Read and Write Error Always
When i monitor SCL and SDA i get pulse but the statement throws error
Suggest me if there is any error in the above stuffs,If problem is
there any other way to approach.
Regards
Kirthika |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Tue Dec 08, 2009 1:40 pm
|
|