hi,

you need to use the sdk with the phrozen patch applied

John

--- In [email protected], "linu13x" <[EMAIL PROTECTED]> wrote:
>
> Thank you for the code.
> I have still one problem. When I want to compile, it cannot find the
> different types of the I2C_DATA and I2C_LCD structure: 
> 
> test1.c: In function `main':
> test1.c:33: `I2C_LCD' undeclared (first use in this function)
> test1.c:33: (Each undeclared identifier is reported only once
> test1.c:33: for each function it appears in.)
> test1.c:33: parse error before "i2clcd"
> test1.c:34: `i2clcd' undeclared (first use in this function)
> test1.c:38: `I2C_LCDINIT' undeclared (first use in this function)
> test1.c:39: `I2C_LCDPRINT' undeclared (first use in this function)
> test1.c:44: `I2C_DATA' undeclared (first use in this function)
> test1.c:44: parse error before "i2cdata"
> test1.c:45: `i2cdata' undeclared (first use in this function)
> test1.c:51: `I2C_READDATA' undeclared (first use in this function)
> make: *** [test1.o] Error 1
> 
> Do I have to make this structure by myself or what is the problem?
> 
> Regards Steff
> 
> --- In [email protected], john@ wrote:
> >
> > here is the code
> > 
> > #include "stdio.h"
> > #include "stdlib.h"
> > #include "unistd.h"
> > #include "sys/ioctl.h"
> > #include "fcntl.h"
> > #include "time.h"
> > #include "string.h"
> > #include <asm/etraxi2c.h>
> > 
> > // Global variables
> > int fd_i2c;
> > 
> > 
> > int I2C_Open(void) {
> >   fd_i2c = open("/dev/i2c", O_RDWR);
> >   if (fd_i2c <= 0) {
> >     printf("I2C: open error on /dev/i2c\n");
> >     return(-1);
> >   }
> > 
> >   return(0);
> > }
> > 
> > 
> > 
> > void I2C_Close(void) {
> >   close(fd_i2c);
> > }
> > 
> > int main(int argc, char **argv) {
> >     int retcode;
> > 
> >     retcode = I2C_Open();
> >     if (retcode != 0) {
> >             exit(1);
> >     }
> > 
> > 
> >     I2C_LCD i2clcd;
> >     i2clcd.slave=64;
> >     i2clcd.x = 1;
> >     i2clcd.y = 1;
> >     sprintf(i2clcd.text, "Hello World");
> >     ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_LCDINIT), &i2clcd);
> >     ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_LCDPRINT), &i2clcd);
> >     i2clcd.y = 2;
> >     i2clcd.x = 3;
> >     ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_LCDPRINT), &i2clcd);
> > 
> >     I2C_DATA i2cdata;
> >     i2cdata.length = 2;
> >     i2cdata.slave = 66;
> > 
> > 
> >     while(1){
> >             ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_READDATA), &i2cdata);
> >             printf("%d %d\n", i2cdata.data[0], i2cdata.data[1]);
> >     };
> > 
> > 
> >     I2C_Close();
> > 
> >     return(0);
> > } // end main()
> >
>


Reply via email to