[PATCH] adding support for AAEON FWS-7600 LCM
Malte Pöggel <[email protected]>
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <[email protected]> |
Hi, i have patched the HD44780 driver to support the internal LCD module of the AAEON FWS-7600 Network Appliance. The display is connected to a special connector on the mainboard, but as its IO address is 0x378 this is a modified printer port ;-) Code examples in the manual describe how to use the display but there was no information on the keys. After analyzing the printer port inputs i finally figured out the connection. Everything works fine: http://www.maltepoeggel.de/public/aaeon-lcm.jpg The patch can be applied to 0.5.4 release but should also work on later versions. Malte _______________________________________________ LCDproc mailing list [email protected] http://lists.omnipotent.net/mailman/listinfo/lcdproc
aaeon-lcm.patch
(text/plain, 10.7 KB)
diff -NaurwB lcdproc-0.5.4/acinclude.m4 lcdproc-0.5.4-patch/acinclude.m4 --- lcdproc-0.5.4/acinclude.m4 2010-12-27 14:32:55.000000000 +0100 +++ lcdproc-0.5.4-patch/acinclude.m4 2011-03-23 11:21:15.000000000 +0100 @@ -198,7 +198,7 @@ hd44780) HD44780_DRIVERS="hd44780-hd44780-serial.o hd44780-hd44780-lis2.o hd44780-hd44780-usblcd.o" if test "$ac_cv_port_have_lpt" = yes ; then - HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-4bit.o hd44780-hd44780-ext8bit.o hd44780-lcd_sem.o hd44780-hd44780-winamp.o hd44780-hd44780-serialLpt.o" + HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-4bit.o hd44780-hd44780-ext8bit.o hd44780-hd44780-aaeon.o hd44780-lcd_sem.o hd44780-hd44780-winamp.o hd44780-hd44780-serialLpt.o" fi if test "$enable_libusb" = yes ; then HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-bwct-usb.o hd44780-hd44780-lcd2usb.o hd44780-hd44780-uss720.o hd44780-hd44780-usbtiny.o" diff -NaurwB lcdproc-0.5.4/server/drivers/hd44780-aaeon.c lcdproc-0.5.4-patch/server/drivers/hd44780-aaeon.c --- lcdproc-0.5.4/server/drivers/hd44780-aaeon.c 1970-01-01 01:00:00.000000000 +0100 +++ lcdproc-0.5.4-patch/server/drivers/hd44780-aaeon.c 2011-03-23 15:01:14.000000000 +0100 @@ -0,0 +1,195 @@ +/** \file server/drivers/hd44780-aaeon.c + * \c 8bit connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays. + * + * The LCD is operated in its 8 bit-mode to be connected to a single PC parallel port. + */ + +/* Copyright (c) 1999, 1995 Benjamin Tse <[email protected]> + * 2001 Joris Robijn <[email protected]> + * + * Changed connection for Aaeon FWS-7600 Network Appliance (internal LCM) + * 2011 Malte Pöggel <[email protected]> + * + * The connections are: + * printer port LCD + * D0 (2) D0 (7) + * D1 (3) D1 (8) + * D2 (4) D2 (9) + * D3 (5) D3 (10) + * D4 (6) D4 (11) + * D5 (7) D5 (12) + * D6 (8) D6 (13) + * D7 (9) D7 (14) + * SEL (1) RS (4) + * - RW (5) (pulled low) + * nLF (16) EN (6) + * + * + * Keypad connection: + * + * Key pressed: nACK (10) + * PE (12) nFAULT (15) + * Key ESC 0 0 + * Key Down 1 1 + * Key Up 0 1 + * Key Enter 1 0 + * Both bits seem to be latched (by bios?) they always stay + * in the state of the key pressed last. + * + * + * Created modular driver Dec 1999, Benjamin Tse <[email protected]> + * + * Based on the code in the lcdtime package which uses the LCD + * controller in its 8-bit mode. + * + * This file is released under the GNU General Public License. Refer to the + * COPYING file distributed with this package. + */ + +#include "hd44780-aaeon.h" +#include "hd44780-low.h" +#include "lpt-port.h" +#include "port.h" +#include "lcd_sem.h" +#include "report.h" + +#include <stdio.h> +#include <string.h> +#include <errno.h> + +// Generally, any function that accesses the LCD control lines needs to be +// implemented separately for each HW design. This is typically (but not +// restricted to): +// HD44780_senddata +// HD44780_readkeypad + +void aaeon_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch); +unsigned char aaeon_HD44780_scankeypad(PrivateData *p); +void aaeon_HD44780_output(PrivateData *p, int data); + +#define RS SEL +#define RW 0x00 +#define EN1 LF + +static int semid; + + +/** + * Initialize the driver. + * \param drvthis Pointer to driver structure. + * \retval 0 Success. + * \retval -1 Error. + */ +int +hd_init_aaeon(Driver *drvthis) +{ + PrivateData *p = (PrivateData*) drvthis->private_data; + HD44780_functions *hd44780_functions = p->hd44780_functions; + + semid = sem_get(); + + // Reserve the port registers + if (port_access_multiple(p->port,3)) { + report(RPT_ERR, "%s: cannot get IO-permission for 0x%03X: %s", + drvthis->name, p->port, strerror(errno)); + return -1; + } + + hd44780_functions->senddata = aaeon_HD44780_senddata; + hd44780_functions->scankeypad = aaeon_HD44780_scankeypad; + + // setup the lcd in 8 bit mode + hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT); + hd44780_functions->uPause(p, 4100); + hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT); + hd44780_functions->uPause(p, 100); + hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_8BIT | TWOLINE | SMALLCHAR); + hd44780_functions->uPause(p, 40); + + common_init (p, IF_8BIT); + + if (p->have_keypad) { + // Remember which input lines are stuck + p->stuckinputs = lcdtime_HD44780_readkeypad(p, 0); + } + // Writes new value to the "bargraph" latches + hd44780_functions->output = aaeon_HD44780_output; + return 0; +} + + +/** + * Send data or commands to the display. + * \param p Pointer to driver's private data structure. + * \param displayID ID of the display (or 0 for all) to send data to. + * \param flags Defines whether to end a command or data. + * \param ch The value to send. + */ +void +aaeon_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch) +{ + unsigned char enableLines = 0, portControl; + + // Only one controller is supported + enableLines = EN1; + + if (flags == RS_INSTR) + portControl = 0; + else // RS_DATA + portControl = RS; + + portControl |= p->backlight_bit; + + sem_wait(semid); + port_out(p->port + 2, portControl ^ OUTMASK); + port_out(p->port, ch); + if (p->delayBus) p->hd44780_functions->uPause(p, 1); + port_out(p->port + 2, (enableLines|portControl) ^ OUTMASK); + if (p->delayBus) p->hd44780_functions->uPause(p, 1); + port_out(p->port + 2, portControl ^ OUTMASK); + sem_signal(semid); +} + + +/** + * Read keypress. + * \param p Pointer to driver's private data structure. + * \return Bitmap of the pressed keys. + */ +unsigned char aaeon_HD44780_scankeypad(PrivateData *p) +{ + unsigned char readval; + + sem_wait(semid); + + // Read inputs + readval = ~ port_in(p->port + 1) ^ INMASK; + + sem_signal(semid); + + readval = ~readval; //reverse logic + + // Keys down? + if((readval & ACK) / ACK) + { + if(((readval & PAPEREND) / PAPEREND) && ((readval & FAULT) / FAULT)) return(0x24); //B + else if((readval & PAPEREND) / PAPEREND) return(0x44); //D + else if((readval & nFAULT) / nFAULT) return(0x34); //C + else return(0x14); //A + } else return('\0'); +} + + +/** + * Set output port. + * \param p Pointer to driver's private data structure. + * \param data Value the output port shall be set to. + */ +void aaeon_HD44780_output(PrivateData *p, int data) +{ + // Setup data bus + port_out(p->port, data); + // Strobe the latch (374 latches on rising edge, 3/574 on trailing. No matter) + port_out(p->port + 2, (p->backlight_bit) ^ OUTMASK); + if (p->delayBus) p->hd44780_functions->uPause(p, 1); +} diff -NaurwB lcdproc-0.5.4/server/drivers/hd44780-aaeon.h lcdproc-0.5.4-patch/server/drivers/hd44780-aaeon.h --- lcdproc-0.5.4/server/drivers/hd44780-aaeon.h 1970-01-01 01:00:00.000000000 +0100 +++ lcdproc-0.5.4-patch/server/drivers/hd44780-aaeon.h 2011-03-23 12:54:43.000000000 +0100 @@ -0,0 +1,9 @@ +#ifndef HD_AAEON_H +#define HD_AAEON_H + +#include "lcd.h" /* for Driver */ + +// initialise this particular driver +int hd_init_aaeon(Driver *drvthis); + +#endif diff -NaurwB lcdproc-0.5.4/server/drivers/hd44780-drivers.h lcdproc-0.5.4-patch/server/drivers/hd44780-drivers.h --- lcdproc-0.5.4/server/drivers/hd44780-drivers.h 2010-12-27 14:32:57.000000000 +0100 +++ lcdproc-0.5.4-patch/server/drivers/hd44780-drivers.h 2011-03-23 15:26:44.318174414 +0100 @@ -16,6 +16,7 @@ # include "hd44780-ext8bit.h" # include "hd44780-serialLpt.h" # include "hd44780-winamp.h" +# include "hd44780-aaeon.h" #endif #include "hd44780-serial.h" #include "hd44780-lis2.h" @@ -51,6 +52,7 @@ { "8bit", HD44780_CT_8BIT, IF_TYPE_PARPORT, hd_init_ext8bit }, { "serialLpt", HD44780_CT_SERIALLPT, IF_TYPE_PARPORT, hd_init_serialLpt }, { "winamp", HD44780_CT_WINAMP, IF_TYPE_PARPORT, hd_init_winamp }, + { "aaeon", HD44780_CT_AAEON, IF_TYPE_PARPORT, hd_init_aaeon }, #endif /* serial connection types */ { "picanlcd", HD44780_CT_PICANLCD, IF_TYPE_SERIAL, hd_init_serial }, diff -NaurwB lcdproc-0.5.4/server/drivers/hd44780-low.h lcdproc-0.5.4-patch/server/drivers/hd44780-low.h --- lcdproc-0.5.4/server/drivers/hd44780-low.h 2010-12-27 14:32:57.000000000 +0100 +++ lcdproc-0.5.4-patch/server/drivers/hd44780-low.h 2011-03-23 11:20:09.000000000 +0100 @@ -51,6 +51,7 @@ #define HD44780_CT_USS720 18 #define HD44780_CT_USBLCD 19 #define HD44780_CT_USBTINY 20 +#define HD44780_CT_AAEON 21 // symbolic names for interface types #define IF_TYPE_UNKNOWN 0 diff -NaurwB lcdproc-0.5.4/server/drivers/Makefile.am lcdproc-0.5.4-patch/server/drivers/Makefile.am --- lcdproc-0.5.4/server/drivers/Makefile.am 2010-12-27 14:32:57.000000000 +0100 +++ lcdproc-0.5.4-patch/server/drivers/Makefile.am 2011-03-23 11:20:52.000000000 +0100 @@ -87,7 +87,7 @@ glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h glk_SOURCES = lcd.h glk.c glk.h glkproto.c glkproto.h report.h hd44780_SOURCES = lcd.h lcd_lib.h hd44780.h hd44780.c hd44780-drivers.h hd44780-low.h hd44780-charmap.h report.h adv_bignum.h -EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-uss720.c hd44780-uss720.h hd44780-usblcd.c hd44780-usblcd.h port.h lpt-port.h timing.h +EXTRA_hd44780_SOURCES = hd44780-4bit.c hd44780-4bit.h hd44780-ext8bit.c hd44780-ext8bit.h hd44780-aaeon.c hd44780-aaenon.h lcd_sem.c lcd_sem.h hd44780-serialLpt.c hd44780-serialLpt.h hd44780-serial.c hd44780-serial.h hd44780-winamp.c hd44780-winamp.h hd44780-bwct-usb.c hd44780-bwct-usb.h hd44780-lcd2usb.c hd44780-lcd2usb.h hd44780-usbtiny.c hd44780-usbtiny.h hd44780-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h hd44780-ethlcd.c hd44780-ethlcd.h hd44780-uss720.c hd44780-uss720.h hd44780-usblcd.c hd44780-usblcd.h port.h lpt-port.h timing.h i2500vfd_SOURCES = lcd.h i2500vfd.c i2500vfd.h i2500vfdfm.c i2500vfdfm.h report.h icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.h report.h imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h