From 10ab31fa86dbf9875b5f6baa6ac59fefaaf86be3 Mon Sep 17 00:00:00 2001 From: andreas 'randy' weinberger Date: Sun, 21 Feb 2010 19:58:27 +0100 Subject: initial git upload, based on graphlcd-base-0.1.5 --- glcddrivers/port.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 glcddrivers/port.h (limited to 'glcddrivers/port.h') diff --git a/glcddrivers/port.h b/glcddrivers/port.h new file mode 100644 index 0000000..2920461 --- /dev/null +++ b/glcddrivers/port.h @@ -0,0 +1,78 @@ +/* + * GraphLCD driver library + * + * port.h - parallel port class with low level routines + * + * This file is released under the GNU General Public License. Refer + * to the COPYING file distributed with this package. + * + * (c) 2004 Andreas Regel + */ + +#ifndef _GLCDDRIVERS_PORT_H_ +#define _GLCDDRIVERS_PORT_H_ + +namespace GLCD +{ + +const int kForward = 0; +const int kReverse = 1; + +const unsigned char kStrobeHigh = 0x00; // Pin 1 +const unsigned char kStrobeLow = 0x01; +const unsigned char kAutoHigh = 0x00; // Pin 14 +const unsigned char kAutoLow = 0x02; +const unsigned char kInitHigh = 0x04; // Pin 16 +const unsigned char kInitLow = 0x00; +const unsigned char kSelectHigh = 0x00; // Pin 17 +const unsigned char kSelectLow = 0x08; + +class cParallelPort +{ +private: + int fd; + int port; + bool usePPDev; + +public: + cParallelPort(); + ~cParallelPort(); + + int Open(int port); + int Open(const char * device); + int Close(); + + bool IsDirectIO() const { return (!usePPDev); } + int GetPortHandle() const { return ((usePPDev) ? fd : port); } + + void Claim(); + void Release(); + + void SetDirection(int direction); + unsigned char ReadControl(); + void WriteControl(unsigned char values); + unsigned char ReadStatus(); + unsigned char ReadData(); + void WriteData(unsigned char data); +}; + +class cSerialPort +{ +private: + int fd; + +public: + cSerialPort(); + ~cSerialPort(); + + int Open(const char * device); + int Close(); + + int ReadData(unsigned char * data); + void WriteData(unsigned char data); + void WriteData(unsigned char * data, unsigned short length); +}; + +} // end of namespace + +#endif -- cgit v1.2.3