hd44780: Added 'usbtiny' connection type (by Siarhei Herasimchuk).

This commit is contained in:
mmdolze
2010-11-22 20:01:10 +00:00
parent 23a7c6c6b0
commit 85c5e8c45a
8 changed files with 200 additions and 2 deletions
+1 -1
View File
@@ -84,7 +84,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
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-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 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
+2
View File
@@ -22,6 +22,7 @@
#ifdef HAVE_LIBUSB
# include "hd44780-bwct-usb.h"
# include "hd44780-lcd2usb.h"
# include "hd44780-usbtiny.h"
# include "hd44780-uss720.h"
#endif
#ifdef HAVE_LIBFTDI
@@ -65,6 +66,7 @@ static const ConnectionMapping connectionMapping[] = {
#ifdef HAVE_LIBUSB
{ "bwctusb", HD44780_CT_BWCTUSB, IF_TYPE_USB, hd_init_bwct_usb },
{ "lcd2usb", HD44780_CT_LCD2USB, IF_TYPE_USB, hd_init_lcd2usb },
{ "usbtiny", HD44780_CT_USBTINY, IF_TYPE_USB, hd_init_usbtiny },
{ "uss720", HD44780_CT_USS720, IF_TYPE_USB, hd_init_uss720 },
#endif
#ifdef HAVE_LIBFTDI
+1
View File
@@ -50,6 +50,7 @@
#define HD44780_CT_ETHLCD 17
#define HD44780_CT_USS720 18
#define HD44780_CT_USBLCD 19
#define HD44780_CT_USBTINY 20
// symbolic names for interface types
#define IF_TYPE_UNKNOWN 0
+139
View File
@@ -0,0 +1,139 @@
/** \file server/drivers/hd44780-usbtiny.c
* \c USBtiny connection type of \c hd44780 driver for Hitachi HD44780 based LCD displays.
*
* http://www.xs4all.nl/~dicks/avr/usbtiny/
*/
/*-
* Copyright (C) 2007 Peter Marschall <peter@adpm.de>
* 2010 Siarhei Herasimchuk <sergby@tut.by>
*
* This file is released under the GNU General Public License.
* Refer to the COPYING file distributed with this package.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <usb.h>
#include "hd44780-usbtiny.h"
#include "report.h"
/* connection type specific functions to be exposed using pointers in init() */
void usbtiny_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void usbtiny_HD44780_close(PrivateData *p);
/**
* Pseudo (empty) uPause function.
* Override the uPause function as a usbtiny device takes care of timing itself.
* \param p Pointer to PrivateData structure (unused)
* \param usecs Number of micro-seconds to sleep (ignored)
*/
void
usbtiny_HD44780_uPause(PrivateData *p, int usecs)
{
}
/**
* Initialize the driver.
* \param drvthis Pointer to driver structure.
* \retval 0 Success.
* \retval -1 Error.
*/
int
hd_init_usbtiny(Driver *drvthis)
{
PrivateData *p = (PrivateData *) drvthis->private_data;
struct usb_bus *bus;
p->hd44780_functions->senddata = usbtiny_HD44780_senddata;
p->hd44780_functions->close = usbtiny_HD44780_close;
/* try to find USB device */
usb_init();
usb_find_busses();
usb_find_devices();
p->usbHandle = NULL;
for (bus = usb_get_busses(); bus != NULL; bus = bus->next) {
struct usb_device *dev;
for (dev = bus->devices; dev != NULL; dev = dev->next) {
/* Check if this device is a usbtiny device */
if ((dev->descriptor.idVendor == USBTINY_VENDORID) &&
(dev->descriptor.idProduct == USBTINY_PRODUCTID)) {
/* USBtiny device found; try to open it */
p->usbHandle = usb_open(dev);
if (p->usbHandle == NULL) {
report(RPT_WARNING, "hd_init_usbtiny: unable to open device");
/*
* Do not exit here because other
* (possibly working) devices may be
* connected.
*/
}
else {
report(RPT_INFO, "hd_init_usbtiny: USBtiny device found");
}
}
}
}
/* No device found at all */
if (p->usbHandle == NULL) {
report(RPT_ERR, "hd_init_usbtiny: no (matching) USBtiny device found");
return -1;
}
common_init(p, IF_4BIT);
/* replace uPause with empty one after initialization */
p->hd44780_functions->uPause = usbtiny_HD44780_uPause;
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
usbtiny_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
{
int type = (flags == RS_DATA) ? USBTINY_DATA : USBTINY_INSTR;
char buffer[1];
buffer[0] = (char) ch;
usb_control_msg(p->usbHandle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, type, 0, 0, buffer, 1, 1000);
}
/**
* Close the driver (do necessary clean-up).
* \param p Pointer to driver's private data structure.
*/
void
usbtiny_HD44780_close(PrivateData *p)
{
if (p->usbHandle != NULL) {
usb_close(p->usbHandle);
p->usbHandle = NULL;
}
}
/* EOF */
+19
View File
@@ -0,0 +1,19 @@
#ifndef HD_USBTINY_H
#define HD_USBTINY_H
#include "lcd.h" /* for Driver */
#include "hd44780-low.h"
/* vendor and product id */
#define USBTINY_VENDORID 0x03EB
#define USBTINY_PRODUCTID 0x0002
/* Protocole IR/LCD */
#define USBTINY_INSTR 20
#define USBTINY_DATA 21
/* initialise this particular driver */
int hd_init_usbtiny(Driver *drvthis);
#endif