From: Luis.F.Correia <Lui...@se...> - 2005-02-14 09:07:21
|
Hi! > -----Original Message----- > From: paul kamphuis [mailto:pau...@xs...] > Sent: Monday, February 14, 2005 7:51 AM > To: lcd...@li... > Subject: [Lcd4linux-devel] connecting i2c lcd > > Hi, > > First things first, my quick test last friday didn't work! Besides it > would have been to easy if it worked just like this. > > To investigate it a little further, I also did a test with a pcf8574 > driving some led's. (Sometimes you are just lucky to have > something like > that available). I used the following piece of C code to test it. > > char buf[1]; > buf[0] = 4; > file = open("\sys\bus\i2c\devices\0-0020\write",O_WRONLY); > write(file,buf,1) > > At power up the leds outputs are clearly in an undefined > state (some on, > some off) After running the above code all led's go off. So there is > activity, but not the desired. (note the strange code of 4 to > turn on a > led. There are 19 led's connected so it is encoded.) > > There is a different way to access a device, and it goes like this > through the command line: > > $ echo 4 > \sys\bus\i2c\devices\0-0020\write > This correctly turns on the desired led. For all that I know, this is the best way to drive something connected to a /sys/bus interface. All other methods should be used programatically. > Is there anyone who has an idea of the difference between the > C code and > the command line? Try to write some C code using the I2C api. > > Paul > Luis |