This repository was archived by the owner on Mar 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSERIAL.H
115 lines (95 loc) · 2.35 KB
/
SERIAL.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* serial.h
Created 1/7/94, Modified 2/11/95
Copyright 1995 John Schultz
All Rights Reserved
*/
#ifndef SERIAL_H
#define SERIAL_H
#define SERIAL_PORT_COM1 0
#define SERIAL_PORT_COM2 1
#define SERIAL_PORT_COM3 2
#define SERIAL_PORT_COM4 3
#define SERIAL_PORT_NONE 4
#define USE_16550 (1<<0)
#define SER_OK 0
#define SER_NO_PORT -1
#define SER_NO_MEMORY -2
#define SER_NO_CHAR -1
#define UART_NONE 0
#define UART_8250 1
#define UART_16550 2
#define FLG_CALLED (1<<4)
#ifdef __WATCOMC__
#pragma pack(1)
#define FAR
#else
#define FAR __far
#endif
typedef void __interrupt __far (__far *s_ifunc)(void);
typedef struct
{
volatile short head;
volatile short tail;
volatile short count;
short size;
short seg;
} QUE;
typedef struct
{
short jmp;
short port;
volatile short flags;
QUE rxq;
QUE txq;
} BIH_STRUCT;
typedef struct serQueue {
QUE FAR *q;
char FAR *que;
short selector;
} serQueue;
typedef struct serialData {
serQueue tx,rx;
long checkCTS;
long fifoEnabled;
long port; /* Com1, com2, com3, or com4 */
long portNum; /* sdcom[4] index: 0..3 */
long intvec;
long intbit;
BIH_STRUCT FAR *bih;
unsigned short bihSel;
unsigned short wRmSel;
unsigned short wRmOfs;
unsigned short wPmSel;
unsigned long wPmOfs;
s_ifunc prevint;
long prevLineControl;
long prevModemControl;
long prevPicMask;
long prevIntEnable;
long prevFifo;
long prevBPS;
} serialData;
#ifdef __WATCOMC__
#pragma pack()
#endif
long initSerial(serialData * sd,long port,long flags,long txQsize,long rxQsize);
void deInitSerial(serialData * sd);
long setBPS(serialData * sd,long bpsRate);
long writeSer(serialData * sd,char ch);
void writeSerNoBuff(serialData * sd,char ch);
long readSer(serialData * sd);
long rxBuffEmpty(serialData * sd);
long txBuffEmpty(serialData * sd);
void flushRead(serialData * sd);
void flushWrite(serialData * sd);
void flushSer(serialData * sd);
void setCheckCTS(serialData * sd,long checkCTS);
void initDTR(serialData * sd);
void setDTR(serialData * sd,long state);
void setRTS(serialData * sd,long state);
long getDSR(serialData * sd);
long getDCD(serialData * sd);
long uartType(serialData * sd);
long serOpen(serialData * sd);
/* serial.h */
#endif