1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/graphlcd-base/glcddrivers/port.h Wed Feb 06 17:32:55 2008 +0000
1.3 @@ -0,0 +1,78 @@
1.4 +/*
1.5 + * GraphLCD driver library
1.6 + *
1.7 + * port.h - parallel port class with low level routines
1.8 + *
1.9 + * This file is released under the GNU General Public License. Refer
1.10 + * to the COPYING file distributed with this package.
1.11 + *
1.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
1.13 + */
1.14 +
1.15 +#ifndef _GLCDDRIVERS_PORT_H_
1.16 +#define _GLCDDRIVERS_PORT_H_
1.17 +
1.18 +namespace GLCD
1.19 +{
1.20 +
1.21 +const int kForward = 0;
1.22 +const int kReverse = 1;
1.23 +
1.24 +const unsigned char kStrobeHigh = 0x00; // Pin 1
1.25 +const unsigned char kStrobeLow = 0x01;
1.26 +const unsigned char kAutoHigh = 0x00; // Pin 14
1.27 +const unsigned char kAutoLow = 0x02;
1.28 +const unsigned char kInitHigh = 0x04; // Pin 16
1.29 +const unsigned char kInitLow = 0x00;
1.30 +const unsigned char kSelectHigh = 0x00; // Pin 17
1.31 +const unsigned char kSelectLow = 0x08;
1.32 +
1.33 +class cParallelPort
1.34 +{
1.35 +private:
1.36 + int fd;
1.37 + int port;
1.38 + bool usePPDev;
1.39 +
1.40 +public:
1.41 + cParallelPort();
1.42 + ~cParallelPort();
1.43 +
1.44 + int Open(int port);
1.45 + int Open(const char * device);
1.46 + int Close();
1.47 +
1.48 + bool IsDirectIO() const { return (!usePPDev); }
1.49 + int GetPortHandle() const { return ((usePPDev) ? fd : port); }
1.50 +
1.51 + void Claim();
1.52 + void Release();
1.53 +
1.54 + void SetDirection(int direction);
1.55 + unsigned char ReadControl();
1.56 + void WriteControl(unsigned char values);
1.57 + unsigned char ReadStatus();
1.58 + unsigned char ReadData();
1.59 + void WriteData(unsigned char data);
1.60 +};
1.61 +
1.62 +class cSerialPort
1.63 +{
1.64 +private:
1.65 + int fd;
1.66 +
1.67 +public:
1.68 + cSerialPort();
1.69 + ~cSerialPort();
1.70 +
1.71 + int Open(const char * device);
1.72 + int Close();
1.73 +
1.74 + int ReadData(unsigned char * data);
1.75 + void WriteData(unsigned char data);
1.76 + void WriteData(unsigned char * data, unsigned short length);
1.77 +};
1.78 +
1.79 +} // end of namespace
1.80 +
1.81 +#endif