hd44780 driver: new ConnectionType ftdi (Thomas Jarosch)
This commit is contained in:
@@ -239,6 +239,7 @@ Thien Vu
|
|||||||
Thomas Jarosch
|
Thomas Jarosch
|
||||||
- support reporting in hd44780's ConnectionType functions
|
- support reporting in hd44780's ConnectionType functions
|
||||||
- build-system clean up: use pkg-config for some libs
|
- build-system clean up: use pkg-config for some libs
|
||||||
|
- HD44780 connection type for a USB connection via a FTDI FT2232D chip
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ v.0.5dev (ongoing development)
|
|||||||
+ hd44780 driver: get/set contrast & brightness support for lcd2usb (M. Dolze)
|
+ hd44780 driver: get/set contrast & brightness support for lcd2usb (M. Dolze)
|
||||||
+ hd44780 driver: reporting in ConnectionType functions (Thomas Jarosch)
|
+ hd44780 driver: reporting in ConnectionType functions (Thomas Jarosch)
|
||||||
* clean up build system (T. Jarosch, with tests/fixes by M. Dolze)
|
* clean up build system (T. Jarosch, with tests/fixes by M. Dolze)
|
||||||
|
+ hd44780 driver: new ConnectionType ftdi (Thomas Jarosch)
|
||||||
|
|
||||||
v.0.5.2
|
v.0.5.2
|
||||||
* fix switching on/off the Load screen in lcdproc client using the menu
|
* fix switching on/off the Load screen in lcdproc client using the menu
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ dnl else
|
|||||||
if test "$enable_libusb" = yes ; then
|
if test "$enable_libusb" = yes ; then
|
||||||
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-bwct-usb.o hd44780-hd44780-lcd2usb.o"
|
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-bwct-usb.o hd44780-hd44780-lcd2usb.o"
|
||||||
fi
|
fi
|
||||||
|
if test "$enable_libftdi" = yes ; then
|
||||||
|
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-ftdi.o"
|
||||||
|
fi
|
||||||
AC_CHECK_HEADER(linux/i2c-dev.h,
|
AC_CHECK_HEADER(linux/i2c-dev.h,
|
||||||
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-i2c.o"
|
HD44780_DRIVERS="$HD44780_DRIVERS hd44780-i2c.o"
|
||||||
AC_DEFINE(HAVE_I2C,[1],[Define to 1 if you have the i2c headers])
|
AC_DEFINE(HAVE_I2C,[1],[Define to 1 if you have the i2c headers])
|
||||||
|
|||||||
@@ -163,6 +163,9 @@ Till Harbaum's open source/open hardware LCD2USB (http://www.harbaum.org/till/lc
|
|||||||
.TP
|
.TP
|
||||||
.B i2c
|
.B i2c
|
||||||
LCD in 4-bit mode driven by PCF8574(A) / PCA9554(A), connected via I2C bus
|
LCD in 4-bit mode driven by PCF8574(A) / PCA9554(A), connected via I2C bus
|
||||||
|
.TP
|
||||||
|
.B ftdi
|
||||||
|
USB connection via a FTDI FT2232D chip in bitbang mode
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B icp_a106
|
.B icp_a106
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ It also supports the following connections:
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para>A PIC-an-LCD or LCD serializer connected to a serial port</para></listitem>
|
<listitem><para>A PIC-an-LCD or LCD serializer connected to a serial port</para></listitem>
|
||||||
<listitem><para>A I<superscript>2</superscript>C port expander connected to an I<superscript>2</superscript>C port</para></listitem>
|
<listitem><para>A I<superscript>2</superscript>C port expander connected to an I<superscript>2</superscript>C port</para></listitem>
|
||||||
|
<listitem><para>USB connection via a FTDI FT2232D chip in bitbang mode</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -1587,6 +1588,133 @@ that. The BL output below should be connected to the BL input in the
|
|||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
|
|
||||||
|
<sect3 id="hd44780-ftdi">
|
||||||
|
<title>FTDI FT2232D USB chip "ftdi"</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You can use a FTDI FT2232D dual channel USB <-> parallel FIFO chip
|
||||||
|
to connect a display via the USB bus. The chip is switched to bitbang mode
|
||||||
|
and drives both channels as outputs to control the display in 8bit mode.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<table id="hd44780-ftdi.base-mapping">
|
||||||
|
<title>HD44780: 8bit FTDI</title>
|
||||||
|
<tgroup cols="5" align="left">
|
||||||
|
<colspec colname="ftdi1"/>
|
||||||
|
<colspec colname="ftdi2" align="right"/>
|
||||||
|
<colspec colname="base" align="center"/>
|
||||||
|
<colspec colname="lcd1"/>
|
||||||
|
<colspec colname="lcd2"/>
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry namest="ftdi1" nameend="ftdi2" align="center">FTDI chip</entry>
|
||||||
|
<entry morerows="1"><-></entry>
|
||||||
|
<entry namest="lcd1" nameend="lcd2" align="center">LCD</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>name</entry>
|
||||||
|
<entry>pin</entry>
|
||||||
|
<entry>name</entry>
|
||||||
|
<entry>pin</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS0</entry>
|
||||||
|
<entry>24</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D0</entry>
|
||||||
|
<entry>7</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS1</entry>
|
||||||
|
<entry>23</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D1</entry>
|
||||||
|
<entry>8</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS2</entry>
|
||||||
|
<entry>22</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D2</entry>
|
||||||
|
<entry>9</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS3</entry>
|
||||||
|
<entry>21</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D3</entry>
|
||||||
|
<entry>10</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS4</entry>
|
||||||
|
<entry>20</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D4</entry>
|
||||||
|
<entry>11</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS5</entry>
|
||||||
|
<entry>19</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D5</entry>
|
||||||
|
<entry>12</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS6</entry>
|
||||||
|
<entry>18</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D6</entry>
|
||||||
|
<entry>13</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>ADBUS7</entry>
|
||||||
|
<entry>17</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>D7</entry>
|
||||||
|
<entry>14</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>BDBUS0</entry>
|
||||||
|
<entry>40</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>RS</entry>
|
||||||
|
<entry>4</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>BDBUS1</entry>
|
||||||
|
<entry>39</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>RW</entry>
|
||||||
|
<entry>5</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>BDBUS2</entry>
|
||||||
|
<entry>38</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>E</entry>
|
||||||
|
<entry>6</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>BDBUS3</entry>
|
||||||
|
<entry>37</entry>
|
||||||
|
<entry></entry>
|
||||||
|
<entry>BL</entry>
|
||||||
|
<entry>Backlight (optional)</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You can configure the USB vendor/product ID in LCDd.conf.
|
||||||
|
The wiring of the control lines can optionally be reconfigured,
|
||||||
|
please look at the driver source if you really need that.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</sect3>
|
||||||
|
|
||||||
<sect3 id="hd44780-lis2">
|
<sect3 id="hd44780-lis2">
|
||||||
<title>LIS2 USB device "lis2"</title>
|
<title>LIS2 USB device "lis2"</title>
|
||||||
|
|
||||||
@@ -2162,6 +2290,7 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
|
|||||||
<arg choice="plain"><literal>lis2</literal></arg>
|
<arg choice="plain"><literal>lis2</literal></arg>
|
||||||
<arg choice="plain"><literal>mplay</literal></arg>
|
<arg choice="plain"><literal>mplay</literal></arg>
|
||||||
<arg choice="plain"><literal>i2c</literal></arg>
|
<arg choice="plain"><literal>i2c</literal></arg>
|
||||||
|
<arg choice="plain"><literal>ftdi</literal></arg>
|
||||||
</group>
|
</group>
|
||||||
</arg>
|
</arg>
|
||||||
</term>
|
</term>
|
||||||
@@ -2238,6 +2367,10 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
|
|||||||
<entry><literal><link linkend="hd44780-i2c">i2c</link></literal></entry>
|
<entry><literal><link linkend="hd44780-i2c">i2c</link></literal></entry>
|
||||||
<entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>
|
<entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><literal><link linkend="hd44780-ftdi">ftdi</link></literal></entry>
|
||||||
|
<entry>Display connected to a dual channel FTDI 2232D USB chip</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
@@ -2498,6 +2631,28 @@ This can be done by specifying <option>--enable-drivers=all</option> or by inclu
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command>VendorID=</command>
|
||||||
|
<arg choice="plain"><replaceable>VENDORID</replaceable></arg>
|
||||||
|
</term>
|
||||||
|
<listitem><para>
|
||||||
|
USB vendor ID to look for a FTDI chip.
|
||||||
|
Default: <literal>0x4003</literal>.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command>ProductID=</command>
|
||||||
|
<arg choice="plain"><replaceable>PRODUCTID</replaceable></arg>
|
||||||
|
</term>
|
||||||
|
<listitem><para>
|
||||||
|
USB product ID to look for a FTDI chip.
|
||||||
|
Default: <literal>0x6001</literal>.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ EXTRA_PROGRAMS = bayrad CFontz CFontz633 CFontzPacket curses CwLnx ea65 EyeboxOn
|
|||||||
noinst_LIBRARIES = libLCD.a libbignum.a
|
noinst_LIBRARIES = libLCD.a libbignum.a
|
||||||
|
|
||||||
IOWarrior_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
IOWarrior_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
hd44780_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
hd44780_CFLAGS = @LIBUSB_CFLAGS@ @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
||||||
g15_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
g15_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
lis_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
lis_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
||||||
picolcd_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
picolcd_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
@@ -37,7 +37,7 @@ curses_LDADD = @LIBCURSES@
|
|||||||
CwLnx_LDADD = libLCD.a libbignum.a
|
CwLnx_LDADD = libLCD.a libbignum.a
|
||||||
g15_LDADD = libLCD.a @LIBG15@
|
g15_LDADD = libLCD.a @LIBG15@
|
||||||
glcdlib_LDADD = libLCD.a @LIBGLCD@
|
glcdlib_LDADD = libLCD.a @LIBGLCD@
|
||||||
hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @LIBUSB_LIBS@ libbignum.a
|
hd44780_LDADD = libLCD.a @HD44780_DRIVERS@ @LIBUSB_LIBS@ @LIBFTDI_LIBS@ libbignum.a
|
||||||
hd44780_DEPENDENCIES = @HD44780_DRIVERS@
|
hd44780_DEPENDENCIES = @HD44780_DRIVERS@
|
||||||
icp_a106_LDADD = libLCD.a
|
icp_a106_LDADD = libLCD.a
|
||||||
imon_LDADD = libLCD.a
|
imon_LDADD = libLCD.a
|
||||||
@@ -77,7 +77,7 @@ g15_SOURCES = lcd.h lcd_lib.h g15.h g15-num.c g15.c report.h
|
|||||||
glcdlib_SOURCES = lcd.h lcd_lib.h glcdlib.h glcdlib.c report.h
|
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
|
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
|
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-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h port.h lpt-port.h timing.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-lis2.c hd44780-lis2.h hd44780-i2c.c hd44780-i2c.h hd44780-ftdi.c hd44780-ftdi.h port.h lpt-port.h timing.h
|
||||||
|
|
||||||
icp_a106_SOURCES = lcd.h lcd_lib.h icp_a106.c icp_a106.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
|
imon_SOURCES = lcd.h lcd_lib.h imon.h imon.c report.h
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
# include "hd44780-bwct-usb.h"
|
# include "hd44780-bwct-usb.h"
|
||||||
# include "hd44780-lcd2usb.h"
|
# include "hd44780-lcd2usb.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBFTDI
|
||||||
|
# include "hd44780-ftdi.h"
|
||||||
|
#endif
|
||||||
#ifdef HAVE_I2C
|
#ifdef HAVE_I2C
|
||||||
# include "hd44780-i2c.h"
|
# include "hd44780-i2c.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -55,6 +58,9 @@ static const ConnectionMapping connectionMapping[] = {
|
|||||||
{ "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb },
|
{ "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb },
|
||||||
{ "lcd2usb", HD44780_CT_I2C, IF_TYPE_USB, hd_init_lcd2usb },
|
{ "lcd2usb", HD44780_CT_I2C, IF_TYPE_USB, hd_init_lcd2usb },
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBFTDI
|
||||||
|
{ "ftdi", HD44780_CT_FTDI, IF_TYPE_USB, hd_init_ftdi },
|
||||||
|
#endif
|
||||||
#ifdef HAVE_I2C
|
#ifdef HAVE_I2C
|
||||||
{ "i2c", HD44780_CT_I2C, IF_TYPE_I2C, hd_init_i2c },
|
{ "i2c", HD44780_CT_I2C, IF_TYPE_I2C, hd_init_i2c },
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* FTDI/USB driver module for Hitachi HD44780 based LCD displays
|
||||||
|
* connected to a FT2232C/D chip in 8 bit mode.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007, Intra2net AG <opensource@intra2net.com>
|
||||||
|
*
|
||||||
|
* This file is released under the GNU General Public License. Refer to the
|
||||||
|
* COPYING file distributed with this package.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hd44780-ftdi.h"
|
||||||
|
|
||||||
|
#include "report.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <usb.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// initialize the driver
|
||||||
|
int
|
||||||
|
hd_init_ftdi(Driver *drvthis)
|
||||||
|
{
|
||||||
|
int vendor_id, product_id;
|
||||||
|
int f;
|
||||||
|
|
||||||
|
PrivateData *p = (PrivateData*) drvthis->private_data;
|
||||||
|
|
||||||
|
p->hd44780_functions->senddata = ftdi_HD44780_senddata;
|
||||||
|
p->hd44780_functions->backlight = ftdi_HD44780_backlight;
|
||||||
|
p->hd44780_functions->scankeypad = ftdi_HD44780_scankeypad;
|
||||||
|
p->hd44780_functions->close = ftdi_HD44780_close;
|
||||||
|
|
||||||
|
// Load config
|
||||||
|
vendor_id = drvthis->config_get_int(drvthis->name, "VendorID", 0, 0x0403);
|
||||||
|
product_id = drvthis->config_get_int(drvthis->name, "ProductID", 0, 0x6001);
|
||||||
|
|
||||||
|
p->ftdi_line_RS = drvthis->config_get_int(drvthis->name, "ftdi_line_RS", 0, 0x01);
|
||||||
|
p->ftdi_line_RW = drvthis->config_get_int(drvthis->name, "ftdi_line_RW", 0, 0x02);
|
||||||
|
p->ftdi_line_E = drvthis->config_get_int(drvthis->name, "ftdi_line_E", 0, 0x04);
|
||||||
|
p->ftdi_line_backlight = drvthis->config_get_int(drvthis->name, "ftdi_line_backlight", 0, 0x08);
|
||||||
|
|
||||||
|
// Init 1. channel: data
|
||||||
|
ftdi_init(&p->ftdic);
|
||||||
|
ftdi_set_interface(&p->ftdic, INTERFACE_A);
|
||||||
|
f = ftdi_usb_open(&p->ftdic, vendor_id, product_id);
|
||||||
|
if(f < 0 && f != -5) {
|
||||||
|
report(RPT_ERR, "unable to open ftdi device: %d (%s)", f, ftdi_get_error_string(&p->ftdic));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
debug(RPT_DEBUG, "ftdi open succeeded(channel 1): %d", f);
|
||||||
|
|
||||||
|
debug(RPT_DEBUG, "enabling bitbang mode(channel 1)\n");
|
||||||
|
ftdi_enable_bitbang(&p->ftdic, 0xFF);
|
||||||
|
|
||||||
|
// Init 2. channel: control
|
||||||
|
ftdi_init(&p->ftdic2);
|
||||||
|
ftdi_set_interface(&p->ftdic2, INTERFACE_B);
|
||||||
|
f = ftdi_usb_open(&p->ftdic2, vendor_id, product_id);
|
||||||
|
if(f < 0 && f != -5) {
|
||||||
|
report(RPT_ERR, "unable to open second ftdi device: %d (%s)", f, ftdi_get_error_string(&p->ftdic2));
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
debug(RPT_DEBUG, "ftdi open succeeded(channel 2): %d", f);
|
||||||
|
|
||||||
|
debug(RPT_DEBUG, "enabling bitbang mode (channel 2)");
|
||||||
|
ftdi_enable_bitbang(&p->ftdic2, 0xFF);
|
||||||
|
|
||||||
|
// FTDI bug: Sometimes first write gets lost on kernel 2.6, needs investigation.
|
||||||
|
ftdi_HD44780_senddata (p, 0, RS_INSTR, FUNCSET | IF_8BIT);
|
||||||
|
usleep (4100);
|
||||||
|
|
||||||
|
common_init(p, IF_8BIT);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ftdi_HD44780_senddata
|
||||||
|
void
|
||||||
|
ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||||
|
{
|
||||||
|
// Output data on first channel
|
||||||
|
int f = ftdi_write_data(&p->ftdic, &ch, 1);
|
||||||
|
if (f < 0) {
|
||||||
|
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic));
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup RS and R/W and E
|
||||||
|
ch = p->ftdi_line_E | p->backlight_bit;
|
||||||
|
if (flags == RS_DATA) {
|
||||||
|
ch |= p->ftdi_line_RS;
|
||||||
|
}
|
||||||
|
f = ftdi_write_data(&p->ftdic2, &ch, 1);
|
||||||
|
if (f < 0) {
|
||||||
|
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable E
|
||||||
|
ch = 0x00 | p->backlight_bit;
|
||||||
|
if (flags == RS_DATA) {
|
||||||
|
ch |= p->ftdi_line_RS;
|
||||||
|
}
|
||||||
|
f = ftdi_write_data(&p->ftdic2, &ch, 1);
|
||||||
|
if (f < 0) {
|
||||||
|
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ftdi_HD44780_backlight(PrivateData *p, unsigned char state)
|
||||||
|
{
|
||||||
|
int f;
|
||||||
|
|
||||||
|
p->backlight_bit = state ? p->ftdi_line_backlight : 0;
|
||||||
|
|
||||||
|
f = ftdi_write_data(&p->ftdic2, &state, 1);
|
||||||
|
if (f < 0) {
|
||||||
|
p->hd44780_functions->drv_report(RPT_ERR, "failed to write: %d (%s). Exiting", f, ftdi_get_error_string(&p->ftdic2));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char
|
||||||
|
ftdi_HD44780_scankeypad(PrivateData *p)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ftdi_HD44780_close(PrivateData *p)
|
||||||
|
{
|
||||||
|
ftdi_disable_bitbang(&p->ftdic);
|
||||||
|
ftdi_usb_close(&p->ftdic);
|
||||||
|
ftdi_deinit(&p->ftdic);
|
||||||
|
|
||||||
|
ftdi_disable_bitbang(&p->ftdic2);
|
||||||
|
ftdi_usb_close(&p->ftdic2);
|
||||||
|
ftdi_deinit(&p->ftdic2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef HD_FTDI_H
|
||||||
|
#define HD_FTDI_H
|
||||||
|
|
||||||
|
#include "lcd.h" /* for Driver */
|
||||||
|
#include "hd44780-low.h"
|
||||||
|
|
||||||
|
// initialise this particular driver
|
||||||
|
int hd_init_ftdi(Driver *drvthis);
|
||||||
|
|
||||||
|
void ftdi_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||||
|
void ftdi_HD44780_backlight(PrivateData *p, unsigned char state);
|
||||||
|
unsigned char ftdi_HD44780_scankeypad(PrivateData *p);
|
||||||
|
void ftdi_HD44780_close(PrivateData *p);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -25,6 +25,9 @@
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBFTDI
|
||||||
|
# include <ftdi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// symbolic names for connection types
|
// symbolic names for connection types
|
||||||
#define HD44780_CT_UNKNOWN 0
|
#define HD44780_CT_UNKNOWN 0
|
||||||
@@ -42,7 +45,8 @@
|
|||||||
#define HD44780_CT_MPLAY 12
|
#define HD44780_CT_MPLAY 12
|
||||||
#define HD44780_CT_BWCTUSB 13
|
#define HD44780_CT_BWCTUSB 13
|
||||||
#define HD44780_CT_LCDUSB 14
|
#define HD44780_CT_LCDUSB 14
|
||||||
#define HD44780_CT_I2C 15
|
#define HD44780_CT_FTDI 15
|
||||||
|
#define HD44780_CT_I2C 16
|
||||||
|
|
||||||
// symbolic names for interface types
|
// symbolic names for interface types
|
||||||
#define IF_TYPE_UNKNOWN 0
|
#define IF_TYPE_UNKNOWN 0
|
||||||
@@ -103,6 +107,16 @@ typedef struct driver_private_data {
|
|||||||
int usbIndex; /* USB interface index */
|
int usbIndex; /* USB interface index */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBFTDI
|
||||||
|
// FTDI connection type
|
||||||
|
struct ftdi_context ftdic, ftdic2;
|
||||||
|
|
||||||
|
int ftdi_line_RS;
|
||||||
|
int ftdi_line_RW;
|
||||||
|
int ftdi_line_E;
|
||||||
|
int ftdi_line_backlight;
|
||||||
|
#endif
|
||||||
|
|
||||||
int charmap;
|
int charmap;
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|||||||
Reference in New Issue
Block a user