From: Luis.F.Correia <Lui...@se...> - 2004-09-20 15:04:12
|
Hi! > -----Original Message----- > From: Michael Reinelt [mailto:re...@eu...] > Sent: Saturday, September 18, 2004 10:54 AM > To: lcd4linux-devel > Subject: [Lcd4linux-devel] HD44780 changes > > Hi List, especially Luis, > > I just checked in a new version of drv_HD44780.c. I did some code > cleanups, and separated the parport specific stuff from the display > specific stuff, and already wrote a framework for other > 'busses'. There > is support for a keyword 'bus' in the display section of > lcd4linux.conf, > which can be 'parport (default) or 'i2c'. There are already skeleton > functions for I2C access. > > So Luis can start filling these skeletion functions! > I will, once I get back from vacations, that is on the 29th... will look then what the changes are ;) Thanks! > But take care, I'm currently working on the HD44780 driver, too! So > update regularly! > > The reason on my side is that I got a Nexcom 19" blade server > donated by > OpenSystems, which has a 16x2 display, and four keys. > > Yes, keys! I'm working on keypad support for lcd4linux. > > stay tuned! > > -- > Michael Reinelt <re...@eu...> > http://members.eunet.at/reinelt > GPG-Key 0xDF13BA50 > ICQ #288386781 > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your > judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Lcd4linux-devel mailing list > Lcd...@li... > https://lists.sourceforge.net/lists/listinfo/lcd4linux-devel > |
From: Luis C. <lfc...@lf...> - 2004-10-08 23:04:10
|
Luis.F.Correia wrote: >Hi List, especially Luis, > >I just checked in a new version of drv_HD44780.c. I did some code >cleanups, and separated the parport specific stuff from the display >specific stuff, and already wrote a framework for other 'busses'. There >is support for a keyword 'bus' in the display section of lcd4linux.conf, >which can be 'parport (default) or 'i2c'. There are already skeleton >functions for I2C access. > >So Luis can start filling these skeletion functions! > >But take care, I'm currently working on the HD44780 driver, too! So >update regularly! > >The reason on my side is that I got a Nexcom 19" blade server donated by >OpenSystems, which has a 16x2 display, and four keys. > >Yes, keys! I'm working on keypad support for lcd4linux. > >stay tuned! > > > Ok, here it goes my first try to support I2C: This is a huge mess, because i'm working on a CVS version of some weeks ago. Since the functions were empty, I think i'm not stepping on anyone's toes. This reads the following config variables: Port '/dev/i2c-0' Device '70' and my config file looks like this: Display HD44780-I2C { Driver 'HD44780' Model 'WRAP1C-PCF8574' Port '/dev/i2c-0' Device '70' Bus 'i2c' Bits '4' Size '20x4' asc255bug 0 Icons 1 Wire { RW 'DB5' RS 'DB4' ENABLE 'DB6' GPO 'GND' } } ------------------------------------- includes at the top of the file: #include <linux/i2c.h> #include <linux/i2c-dev.h> global variable: /* handle for I2C device*/ static int i2c_device; Functions: /****************************************/ /*** i2c dependant functions ***/ /****************************************/ static void drv_HD_I2C_nibble (const unsigned char controller, const unsigned char nibble) { /* clear ENABLE */ /* put data on DB1..DB4 */ /* nibble already contains RS bit! */ i2c_smbus_write_byte_data(i2c_device, 0, nibble); /* Address set-up time */ ndelay(T_AS); /* rise ENABLE */ i2c_smbus_write_byte_data(i2c_device, 0, nibble | SIGNAL_ENABLE); /* Enable pulse width */ ndelay(T_PW); /* lower ENABLE */ i2c_smbus_write_byte_data(i2c_device, 0, nibble); /* Address hold time */ ndelay(T_H); } static void drv_HD_I2C_byte (const unsigned char controller, const unsigned char data) { /* send data with RS disabled */ /* send high nibble of the data */ drv_HD_I2C_nibble (controller, ((data>>4)&0x0f)|SIGNAL_RS); /* Make sure we honour T_CYCLE */ ndelay(T_CYCLE-T_AS-T_PW); /* send low nibble of the data */ drv_HD_I2C_nibble(controller, (data&0x0f)|SIGNAL_RS); } static void drv_HD_I2C_command (const unsigned char controller, const unsigned char cmd, const int delay) { /* send data with RS disabled */ drv_HD_I2C_byte (controller, cmd); /* wait for command completion */ udelay(delay); } static void drv_HD_I2C_data (const unsigned char controller, const char *string, const int len, const int delay) { int l = len; /* sanity check */ if (len<=0) return; while (l--) { /* send data with RS enabled */ drv_HD_I2C_byte (controller, *(string++)); /* wait for command completion */ udelay(delay); } } static int drv_HD_I2C_load (const char *section) { int dev; char *bus,*device; bus =cfg_get(section, "Port", NULL); device =cfg_get(section, "Device", NULL); dev =0x70; info("%s: initializing I2C bus %s",Name,bus); if ((i2c_device = open(bus,O_RDWR)) < 0) { error("%s: I2C bus %s open failed !\n",Name,bus); return -1; } info("%s: initializing I2C slave device 0x%x",Name,dev); if (ioctl(i2c_device,I2C_SLAVE, (dev>>1) ) < 0) { error("%s: error initializing device 0x%x\n",Name,dev); close(i2c_device); return -1; } info("%s: detecting I2C device 0x%x on bus %s ",Name,dev,bus); if (i2c_smbus_write_quick(i2c_device,I2C_SMBUS_WRITE) < 0) { error("%s: i2c slave-device 0x%x not found!\n",Name,dev); close(i2c_device); return -1; } if (cfg_number(section, "Bits", 8, 4, 8, &Bits)<0) return -1; if (Bits!=4) { error ("%s: bad %s.Bits '%d' from %s, should be '4' ", Name, section, Bits, cfg_source()); return -1; } info ("%s: using %d bit mode", Name, Bits); /* initialize *both* displays */ drv_HD_I2C_nibble (allControllers, 0x03); udelay(T_INIT1); /* 4 Bit mode, wait 4.1 ms */ drv_HD_I2C_nibble (allControllers, 0x03); udelay(T_INIT2); /* 4 Bit mode, wait 100 us */ drv_HD_I2C_nibble (allControllers, 0x03); udelay(T_INIT1); /* 4 Bit mode, wait 4.1 ms */ drv_HD_I2C_nibble (allControllers, 0x02); udelay(T_INIT2); /* 4 Bit mode, wait 100 us */ drv_HD_I2C_command (allControllers, 0x28, T_EXEC); /* 4 Bit mode, 1/16 duty cycle, 5x8 font */ info("%s: I2C initialization done", Name); return 0; } static void drv_HD_I2C_stop (void) { /* clear all signals */ // drv_generic_i2c_data (0); /* close port */ // drv_generic_i2c_close(); close(i2c_device); } ------------------------------------- Michael, please feel free to redirect that SCUD missile you have to my email address :) Cheers! Luis Correia |
From: Michael R. <re...@eu...> - 2004-10-17 09:32:13
|
Hi Luis, > Ok, here it goes my first try to support I2C: > This is a huge mess, because i'm working on a CVS version of some weeks > ago. > Since the functions were empty, I think i'm not stepping on anyone's toes. I tried to apply your "patch", it worked, but it does not compile. I'm afraid there's a problem with the i2c.h include. That's what I get when I do a make: gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/X11R6/include -D_GNU_SOURCE -Wall -W -g -O2 -c drv_HD44780.c 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 drv_HD44780.c:216: /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/include/linux/i2c.h:31, from drv_HD44780.c:216: /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) /usr/include/linux/bitmap.h:15: error: (Each undeclared identifier is reported only once /usr/include/linux/bitmap.h:15: error: for each function it appears in.) and so on... The first error is a missing "u64" declaration, which is defined in asm/types.h, but only if the symbol __KERNEL__ is defined (which is not in a userspace program) I commented out all failing sections in the driver with a #if 0, and checked in the driver. Maybe you want to have a look at it, and find out how to make it compile cleanly. bye, Michael -- Michael Reinelt <re...@eu...> http://members.eunet.at/reinelt GPG-Key 0xDF13BA50 ICQ #288386781 |