1 | // Header file for avr309.dll for c++ builder
|
2 | // 23.02.06 T. Hack
|
3 |
|
4 | #ifndef AVR309H
|
5 | #define AVR309H
|
6 |
|
7 | #include "windows.h"
|
8 |
|
9 | // return values from AVR309DLL functions:
|
10 | #define AVR309DLL "AVR309.dll"
|
11 | #define NO_ERROR 0 // silly
|
12 | #define DEVICE_NOT_PRESENT 1
|
13 | #define NO_DATA_AVAILABLE 2
|
14 | #define INVALID_BAUDRATE 3
|
15 | #define OVERRUN_ERROR 4
|
16 | #define INVALID_DATABITS 5
|
17 | #define INVALID_PARITY 6
|
18 | #define INVALID_STOPBITS 7
|
19 |
|
20 | // Handle to the DLL
|
21 | HINSTANCE DLLInstance;
|
22 |
|
23 | // Typedefs for importing the functions from the DLL (pX means pointer to X)
|
24 | typedef int (__stdcall *IMPFUNC_U) (unsigned char);
|
25 | typedef int (__stdcall *IMPFUNC_pU) (unsigned char *);
|
26 | typedef int (__stdcall *IMPFUNC_I) (int);
|
27 | typedef int (__stdcall *IMPFUNC_pI) (int *);
|
28 | typedef int (__stdcall *IMPFUNC_pUIpI) (unsigned char *, int, int *);
|
29 | typedef int (__stdcall *IMPFUNC_SU) (unsigned short, unsigned char);
|
30 | typedef int (__stdcall *IMPFUNC_SpU) (unsigned short, unsigned char *);
|
31 | typedef int (__stdcall *IMPFUNC_UpU) (unsigned char, unsigned char *);
|
32 | typedef int (__stdcall *IMPFUNC_UUUU) (unsigned char, unsigned char,
|
33 | unsigned char, unsigned char);
|
34 | typedef int (__stdcall *IMPFUNC_pUpUpUpU)(unsigned char *, unsigned char *,
|
35 | unsigned char *, unsigned char *);
|
36 |
|
37 | IMPFUNC_U DoSetDataPortDirection,
|
38 | DoSetOutDataPort,
|
39 | DoRS232Send,
|
40 | DoSetRS232DataBits,
|
41 | DoSetRS232Parity,
|
42 | DoSetRS232StopBits;
|
43 | IMPFUNC_pU DoGetDataPortDirection,
|
44 | DoGetOutDataPort,
|
45 | DoGetInDataPort,
|
46 | DoRS232Read,
|
47 | DoGetRS232DataBits,
|
48 | DoGetRS232Parity,
|
49 | DoGetRS232StopBits;
|
50 | IMPFUNC_I DoSetRS232Baud;
|
51 | IMPFUNC_pI DoGetRS232Baud;
|
52 | IMPFUNC_pUIpI DoGetInfraCode,
|
53 | DoGetRS232Buffer,
|
54 | DoRS232BufferSend;
|
55 | IMPFUNC_SU DoEEPROMWrite;
|
56 | IMPFUNC_SpU DoEEPROMRead;
|
57 | IMPFUNC_UUUU DoSetDataPortDirections,
|
58 | DoSetOutDataPorts;
|
59 | IMPFUNC_pUpUpUpU DoGetDataPortDirections,
|
60 | DoGetOutDataPorts,
|
61 | DoGetInDataPorts;
|
62 |
|
63 | int __stdcall AVR309Init()
|
64 | {
|
65 | int retval = 0;
|
66 | if (!DLLInstance) // already loaded?
|
67 | {
|
68 | if (!(DLLInstance = LoadLibrary(AVR309DLL))) retval = 0;
|
69 | else
|
70 | {
|
71 | DoSetDataPortDirection = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoSetDataPortDirection");
|
72 | DoSetOutDataPort = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoSetOutDataPort");
|
73 | DoRS232Send = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoRS232Send");
|
74 | DoSetRS232DataBits = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoSetRS232DataBits");
|
75 | DoSetRS232Parity = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoSetRS232Parity");
|
76 | DoSetRS232StopBits = (IMPFUNC_U) GetProcAddress (DLLInstance, "DoSetRS232StopBits");
|
77 | DoGetDataPortDirection = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetDataPortDirection");
|
78 | DoGetOutDataPort = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetOutDataPort");
|
79 | DoGetInDataPort = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetInDataPort");
|
80 | DoRS232Read = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoRS232Read");
|
81 | DoGetRS232DataBits = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetRS232DataBits");
|
82 | DoGetRS232Parity = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetRS232Parity");
|
83 | DoGetRS232StopBits = (IMPFUNC_pU) GetProcAddress (DLLInstance, "DoGetRS232StopBits");
|
84 | DoSetRS232Baud = (IMPFUNC_I) GetProcAddress (DLLInstance, "DoSetRS232Baud");
|
85 | DoGetRS232Baud = (IMPFUNC_pI) GetProcAddress (DLLInstance, "DoGetRS232Baud");
|
86 | DoGetInfraCode = (IMPFUNC_pUIpI) GetProcAddress (DLLInstance, "DoGetInfraCode");
|
87 | DoGetRS232Buffer = (IMPFUNC_pUIpI) GetProcAddress (DLLInstance, "DoGetRS232Buffer");
|
88 | DoRS232BufferSend = (IMPFUNC_pUIpI) GetProcAddress (DLLInstance, "DoRS232BufferSend");
|
89 | DoEEPROMWrite = (IMPFUNC_SU) GetProcAddress (DLLInstance, "DoEEPROMWrite");
|
90 | DoEEPROMRead = (IMPFUNC_SpU) GetProcAddress (DLLInstance, "DoEEPROMRead");
|
91 | DoSetDataPortDirections = (IMPFUNC_UUUU) GetProcAddress (DLLInstance, "DoSetDataPortDirections");
|
92 | DoSetOutDataPorts = (IMPFUNC_UUUU) GetProcAddress (DLLInstance, "DoSetOutDataPorts");
|
93 | DoGetDataPortDirections = (IMPFUNC_pUpUpUpU) GetProcAddress (DLLInstance, "DoGetDataPortDirections");
|
94 | DoGetOutDataPorts = (IMPFUNC_pUpUpUpU) GetProcAddress (DLLInstance, "DoGetOutDataPorts");
|
95 | DoGetInDataPorts = (IMPFUNC_pUpUpUpU) GetProcAddress (DLLInstance, "DoGetInDataPorts");
|
96 | retval = 1;
|
97 | }
|
98 | }
|
99 | return (retval);
|
100 | }
|
101 |
|
102 | void __stdcall AVR309Exit()
|
103 | {
|
104 | if (DLLInstance) FreeLibrary(DLLInstance);
|
105 | }
|
106 |
|
107 | /*
|
108 | # int __stdcall DoGetDataPortDirections(uchar * DataDirectionByteB, uchar * DataDirectionByteC, uchar * DataDirectionByteD, uchar * UsedPorts);
|
109 | # int __stdcall DoGetOutDataPorts(uchar * DataOutByteB, uchar * DataOutByteC, uchar * DataOutByteD, uchar * UsedPorts);
|
110 | # int __stdcall DoGetInDataPorts(uchar * DataInByteB, uchar * DataInByteC, uchar * DataInByteD, uchar * UsedPorts);
|
111 | # int __stdcall DoSetOutDataPorts(uchar DataOutByteB, uchar DataOutByteC, uchar DataOutByteD, uchar UsedPorts);
|
112 | # int __stdcall DoSetDataPortDirections(uchar DirectionByteB, uchar DirectionByte, uchar DirectionByte, uchar UsedPorts);
|
113 | # int __stdcall DoEEPROMRead(ushort Address, uchar * DataInByte);
|
114 | # int __stdcall DoEEPROMWrite(ushort Address, uchar DataOutByte);
|
115 | # int __stdcall DoGetRS232Buffer(uchar * RS232Buffer, int DummyInt, int * RS232BufferLength);
|
116 | # int __stdcall DoRS232BufferSend(uchar * RS232Buffer, int DummyInt, int * RS232BufferLength);
|
117 | # int __stdcall DoGetInfraCode(uchar * TimeCodeDiagram, int DummyInt, int * DiagramLength);
|
118 | # int __stdcall DoSetRS232Baud(int BaudRate);
|
119 | # int __stdcall DoGetRS232Baud(int * BaudRate);
|
120 | # int __stdcall DoSetDataPortDirection(uchar DirectionByte);
|
121 | # int __stdcall DoGetDataPortDirection(uchar * DataDirectionByte);
|
122 | # int __stdcall DoSetOutDataPort(uchar DataOutByte);
|
123 | # int __stdcall DoGetOutDataPort(uchar * DataOutByte);
|
124 | # int __stdcall DoGetInDataPort(uchar * DataInByte);
|
125 | # int __stdcall DoRS232Send(uchar DataOutByte);
|
126 | # int __stdcall DoRS232Read(uchar * DataInByte);
|
127 | # int __stdcall DoSetRS232DataBits(uchar DataBits);
|
128 | # int __stdcall DoGetRS232DataBits(uchar * DataBits);
|
129 | # int __stdcall DoSetRS232Parity(uchar Parity);
|
130 | # int __stdcall DoGetRS232Parity(uchar * Parity);
|
131 | # int __stdcall DoSetRS232StopBits(uchar StopBits);
|
132 | # int __stdcall DoGetRS232StopBits(uchar * StopBits);
|
133 | */
|
134 |
|
135 | #endif
|