Re: [PATCH] adding support for AAEON FWS-7600 LCM
Malte Pöggel <[email protected]>
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <[email protected]> |
Hi Markus, Am 23.03.2011 20:06, schrieb Markus Dolze: > 1. Please refrain from using the semaphore stuff. It is ancient code > used to mediate access between LCDproc and programs called > 'lcdtime' (and I think 'meter'). I did not know what the semaphore stuff was good for, so i left it in. I've now removed it and attatched the corrected patch and the schematics for the "aaeon" lcd and keypad wiring. > 2. I am a little reluctant adding drivers for ready-built cases > (especially if appliances are used for something else than > originally intended). [...] I developed this driver at work, we are using the appliances for a firewall system. The display was not used till now, but a uninitialized LCD seems to be very confusing to our customers and so i wrote the patch ;-) Malte _______________________________________________ LCDproc mailing list [email protected] http://lists.omnipotent.net/mailman/listinfo/lcdproc
aaeon-lcd.txt
(text/plain, 249 B)
HD44780: "aaeon" wiring 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)
aaeon-lcm.patch
(text/plain, 10.5 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-24 11:09:13.596069626 +0100 @@ -0,0 +1,184 @@ +/** \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 "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 + + +/** + * 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; + + // 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; + + 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); +} + + +/** + * 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; + + // Read inputs + readval = ~ port_in(p->port + 1) ^ INMASK; + + 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
aaeon-keys.txt
(text/plain, 1 KB)
HD44780: "aaeon" wiring - Keypad
5V printer port
o
| ___ Escape
+---o o------+----+----------------+-----------o nACK (10)
| _|_ _|_ |
| /_\ /_\ 4x 1N4148 |
| ___ Down | | |
+---o o------|----|-----+-----+ |
| | | _|_ _|_ |
| | | _\_/_ _\_/_ |
| ___ Up | | | | |
+---o o------|----+-----|-----+----|---+-------o nFAULT (15)
| | | | |
| | | | |
| ___ Enter| | | |
+---o o------+----------+----------|---|---+---o PE (12)
| | |
pin states: - - -
nACK PE nFAULT | | | | | | 3x 220R
Escape 1 0 0 | | | | | |
Down 1 1 1 - - -
Up 1 0 1 | | |
Enter 1 1 0 | | |
=== === === GND