I2C error
Hi,
I was wondering whether anyone using the scratchbox had issue with compiling a C code that includes <linux/i2c.h> header file.
I have a ADC connected to I2C peripheral on my Innovator OMAP5910 and I am trying to obtain some data from it. I created a simple
code that utilizes the IOCTL commands that are available in the <linux/i2c.h> and <linux/i2c-dev.h>. However, if I compile the code, then I get all different sorts of syntax errors in the headers that are included within the two headers listed above. The first few lines of errors that I get are:
In file included from /usr/include/linux/sched.h:12,
from /usr/include/linux/module.h:10,
from /usr/include/linux/i2c.h:31,
from myi2c.c:12:
/usr/include/linux/jiffies.h:16: error: parse error before "jiffies_64"
/usr/include/linux/jiffies.h:20: error: parse error before "get_jiffies_64"
In file included from /usr/include/linux/cpumask.h:8,
from /usr/include/linux/sched.h:15,
from /usr/include/linux/module.h:10,
from /usr/linclude/linux/i2c.h:31,
from myi2c.c:12:/usr/include/linux/bitmap.h: In function 'bitmap_empty':/usr/include/linux/bitmap.h:15: error: 'BITS_PER_LONG' undeclared (first use in this function)
......
The code myi2c.c ( i reduced the code down to minimum level)
...
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
int main()
{
int s;
int adapter_nr = 0; (I checked /sys/class/i2c-dev to find the number)
if(( s = open(filename, O_RDWR)) < 0) {
printf("Couldn't open the device\n");
exit(0);
}
int addr = 0x90;
if(ioctl(s, I2C_SLAVE, addr)<0) {
printf("Couldn't access the slave device\n");
exit(0); }
return 0;
}
compiling was done within the scratchbox environment using gcc -Wall -o test myi2c.c
I tried compiling the code without the <linux/i2c.h> and the only error that I get is that I2C_SLAVE is not defined.
Thus, if I include it, I get all different kind of errors.
I never accessed i2c peripheral from an OS before and I would appreciate any kind of help I can get.
Regards,
Louis