summaryrefslogtreecommitdiff
path: root/glcddrivers/port.h
diff options
context:
space:
mode:
authorandreas 'randy' weinberger <vdr@smue.org>2010-02-21 19:58:27 +0100
committerandreas 'randy' weinberger <vdr@smue.org>2010-02-21 19:58:27 +0100
commit10ab31fa86dbf9875b5f6baa6ac59fefaaf86be3 (patch)
tree60ad7c856565f03e145b2996d1bb5f9cd64c0532 /glcddrivers/port.h
downloadgraphlcd-base-10ab31fa86dbf9875b5f6baa6ac59fefaaf86be3.tar.gz
graphlcd-base-10ab31fa86dbf9875b5f6baa6ac59fefaaf86be3.tar.bz2
initial git upload, based on graphlcd-base-0.1.5
Diffstat (limited to 'glcddrivers/port.h')
-rw-r--r--glcddrivers/port.h78
1 files changed, 78 insertions, 0 deletions
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 <andreas.regel AT powarman.de>
+ */
+
+#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