graphlcd-base/glcddrivers/port.h
author root@rika
Thu, 23 Apr 2009 19:10:12 +0200
changeset 30 7fd00015f62f
parent 21 f1573dd6dace
permissions -rw-r--r--
several changes..
root@4
     1
/*
root@4
     2
 * GraphLCD driver library
root@4
     3
 *
root@4
     4
 * port.h  -  parallel port class with low level routines
root@4
     5
 *
root@4
     6
 * This file is released under the GNU General Public License. Refer
root@4
     7
 * to the COPYING file distributed with this package.
root@4
     8
 *
root@4
     9
 * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
root@4
    10
 */
root@4
    11
root@4
    12
#ifndef _GLCDDRIVERS_PORT_H_
root@4
    13
#define _GLCDDRIVERS_PORT_H_
root@4
    14
root@4
    15
namespace GLCD
root@4
    16
{
root@4
    17
root@4
    18
const int kForward = 0;
root@4
    19
const int kReverse = 1;
root@4
    20
root@4
    21
const unsigned char kStrobeHigh = 0x00; // Pin 1
root@4
    22
const unsigned char kStrobeLow  = 0x01;
root@4
    23
const unsigned char kAutoHigh   = 0x00; // Pin 14
root@4
    24
const unsigned char kAutoLow    = 0x02;
root@4
    25
const unsigned char kInitHigh   = 0x04; // Pin 16
root@4
    26
const unsigned char kInitLow    = 0x00;
root@4
    27
const unsigned char kSelectHigh = 0x00; // Pin 17
root@4
    28
const unsigned char kSelectLow  = 0x08;
root@4
    29
root@4
    30
class cParallelPort
root@4
    31
{
root@4
    32
private:
root@4
    33
    int fd;
root@4
    34
    int port;
root@4
    35
    bool usePPDev;
root@4
    36
root@4
    37
public:
root@4
    38
    cParallelPort();
root@4
    39
    ~cParallelPort();
root@4
    40
root@4
    41
    int Open(int port);
root@4
    42
    int Open(const char * device);
root@4
    43
    int Close();
root@4
    44
root@4
    45
    bool IsDirectIO() const { return (!usePPDev); }
root@4
    46
    int GetPortHandle() const { return ((usePPDev) ? fd : port); }
root@4
    47
root@4
    48
    void Claim();
root@4
    49
    void Release();
root@4
    50
root@4
    51
    void SetDirection(int direction);
root@4
    52
    unsigned char ReadControl();
root@4
    53
    void WriteControl(unsigned char values);
root@4
    54
    unsigned char ReadStatus();
root@4
    55
    unsigned char ReadData();
root@4
    56
    void WriteData(unsigned char data);
root@4
    57
};
root@4
    58
root@4
    59
class cSerialPort
root@4
    60
{
root@4
    61
private:
root@4
    62
    int fd;
root@4
    63
root@4
    64
public:
root@4
    65
    cSerialPort();
root@4
    66
    ~cSerialPort();
root@4
    67
cpresser@21
    68
    int Open(const char * device);
root@4
    69
    int Close();
root@4
    70
cpresser@8
    71
    int ReadData(unsigned char * data);
root@4
    72
    void WriteData(unsigned char data);
root@4
    73
    void WriteData(unsigned char * data, unsigned short length);
root@4
    74
};
root@4
    75
root@4
    76
} // end of namespace
root@4
    77
root@4
    78
#endif