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 |
From: Luis.F.Correia <Lui...@se...> - 2005-02-15 08:50:42
|
Hi! (yes, i'm still reading) > -----Original Message----- > From: paul kamphuis [mailto:pau...@xs...] [snip] > > Now to the way on how to do it. (Luis are you still reading, > here comes your I2C API :-) ) > > file = open("/dev/i2c-0",O_RDWR); // open i2c bus > ioctl(file,I2C_SLAVE,0x26); // select device > struct i2c_smbus_ioctl_data args; > args.read_write = I2C_SMBUS_WRITE; > args.size = I2C_SMBUS_BYTE; > args.command = 0x03; // <- this is the byte to write!! > ioctl(file,I2C_SMBUS,&args); // write byte to selected device Ok then, did you found out which header files to include? It should be something like <i2c.h> and not <linux/12c.h> as I had before. It was even commented out because it did not really compile... Anyway, from my experiences, you must create a very static lcd4linux.conf file, just as a test. No bars, no scrollers no moving icons, just something like showing the Linux kernel version. This is necessary in order to reduce the amount of information that lcd4linux will force on the driver. At first I just got the .conf file from my router and the result was a very big mess... :) So please feel free to adapt my code to whatever you think doable. About the display connections, how did you wired it? In my driver I used the same type of connections that Martin Hejl uses in his GPIO driver for Soekris boards (http://soekris.hejl.de/wiring.gif) > There is hardly any documentation on this and it required > some digging in kernel source code to find that 'command' > should contain the byte write. But it does work, to write a > byte to the port. > > Now for the sad news. The display doesn't start yet. Of > course this can have several reasons, that I still have to > look into. It might even require bringing an oscilloscope > home from work. > > Luis, thanks for your feedback! > > Paul > Have fun! Luis Correia |
From: paul k. <pau...@xs...> - 2005-02-23 10:23:52
|
Hi, Sorry for the delay. I had some other things to care of. (work.. :-) ) >Ok then, did you found out which header files to include? >It should be something like <i2c.h> and not <linux/12c.h> as I had >before. It was even commented out because it did not really compile... > > > No i did include <linux/i2c.h> and <linux/i2c-dev.h>. I have no other i2c.h header files available. You need to include <linux/compiler.h> before them to make them compile correctly. But it is no longer possible to use the i2c_smbus functions. You need that ioctrl function for that now. >Anyway, from my experiences, you must create a very static >lcd4linux.conf file, just as a test. No bars, no scrollers no >moving icons, just something like showing the Linux kernel version. > > > I'll have to check on how to create such a config file. Is only a display configuration sufficient? >About the display connections, how did you wired it? In my driver >I used the same type of connections that Martin Hejl uses in his >GPIO driver for Soekris boards (http://soekris.hejl.de/wiring.gif) > > > No, I use a different wiring. I use a display unit from a project I did 2 years ago. It is from an ergometer (http://www.relitech.nl/nl/PAG16.HTM, it is in dutch from our 'old' company website. The new site is almost ready) It has to PCF8574 devices connected to the i2c bus. One for the display and the other for a Led-bar graph and 3 input control keys. I checked that I could control the PCF8574 by using the led-bar graph. The display is connected like this: PCF8574 Display P0 DB4 P1 DB5 P2 DB6 P3 DB7 P4 R/W P5 RS P6 E P7 - The display is powered by 5 V and and the PCF8574 by 3.3V (from the i2c interface on my VIA EPIA board). It could be that this is part of the problem. In the original design the PCF8574 was powered by 5 V. So the output might be to low voltage for the display to see it correctly. I verified the initialisation/command sequence in lcd4linux. It is nearly the same as I used on the original project. cheers, Paul |
From: paul k. <pau...@xs...> - 2005-02-15 08:34:18
|
I contacted the person (sorry the e-mail is currently unavailable so I am not sure about his name) responsible for the port of the pcf8574 module to kernel 2.6. He was so kind to answer my questions. first this code: char buf[1]; buf[0] = 4; file = open("\sys\bus\i2c\devices\0-0020\write",O_WRONLY); write(file,buf,1); Is correct, except that this file only accepts asci strings. So it should be something like this; char buf[1]; buf[0] = '4'; file = open("\sys\bus\i2c\devices\0-0020\write",O_WRONLY); write(file,buf,1); To send a byte to the I2C bus. Now to the way on how to do it. (Luis are you still reading, here comes your I2C API :-) ) file = open("/dev/i2c-0",O_RDWR); // open i2c bus ioctl(file,I2C_SLAVE,0x26); // select device struct i2c_smbus_ioctl_data args; args.read_write = I2C_SMBUS_WRITE; args.size = I2C_SMBUS_BYTE; args.command = 0x03; // <- this is the byte to write!! ioctl(file,I2C_SMBUS,&args); // write byte to selected device There is hardly any documentation on this and it required some digging in kernel source code to find that 'command' should contain the byte write. But it does work, to write a byte to the port. Now for the sad news. The display doesn't start yet. Of course this can have several reasons, that I still have to look into. It might even require bringing an oscilloscope home from work. Luis, thanks for your feedback! Paul Luis.F.Correia wrote: >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 > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >_______________________________________________ >Lcd4linux-devel mailing list >Lcd...@li... >https://lists.sourceforge.net/lists/listinfo/lcd4linux-devel > > > > |